Skip to content

Commit

Permalink
added anonymous service test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvelmer committed Sep 7, 2023
1 parent fa9c4ea commit e85a838
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/services/anonymous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ export class AnonymousService extends Service implements AnonymousServicePropert
ChainAPI.circuit(this.chainCircuits.wasmURI),
])
)
.then((files) => {
this.chainCircuits.zKeyData = files[0];
this.chainCircuits.vKeyData = files[1];
this.chainCircuits.wasmData = files[2];
.then(([zKeyData, vKeyData, wasmData]) => {
this.chainCircuits.zKeyData = zKeyData;
this.chainCircuits.vKeyData = vKeyData;
this.chainCircuits.wasmData = wasmData;
return this.checkCircuitsHashes();
});
}
Expand Down
29 changes: 29 additions & 0 deletions test/services/anonymous.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { AnonymousService, ChainCircuits } from '../../src';
// @ts-ignore
import { URL } from './util/client.params';
import { sha256 } from '@ethersproject/sha2';

describe('Anonymous Service tests', () => {
it('should have the correct type and properties', () => {
const service = new AnonymousService({});
expect(service).toBeInstanceOf(AnonymousService);
expect(service.url).toBeUndefined();
});
it('should have set the correct parameters', async () => {
const chainCircuits: ChainCircuits = {
zKeyData: new Uint8Array(),
zKeyHash: sha256(new Uint8Array()),
zKeyURI: '',
vKeyData: new Uint8Array(),
vKeyHash: sha256(new Uint8Array()),
vKeyURI: '',
wasmData: new Uint8Array(),
wasmHash: sha256(new Uint8Array()),
wasmURI: '',
};
const service = new AnonymousService({ url: URL, chainCircuits });
expect(service.url).toEqual(URL);
expect(service.chainCircuits).toEqual(chainCircuits);
expect(service.checkCircuitsHashes()).toBeTruthy();
});
});

0 comments on commit e85a838

Please sign in to comment.