Skip to content

Commit

Permalink
add pagination unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Aug 8, 2023
1 parent 3cbc53b commit bed984b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions helpers/DeployHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,18 @@ export class DeployHelper {
return genesisUtilsWrapper;
}

async deployZKPVerifier(): Promise<{
address: string;
}> {

const ZKPVerifier = await ethers.getContractFactory(
"ZKPVerifier"
);
const zkpVerifier = await ZKPVerifier.deploy();
console.log("ZKPVerifier deployed to:", zkpVerifier.address);
return zkpVerifier;
}

async getDefaultIdType(): Promise<{defaultIdType: number, chainId: number}> {
const chainId = parseInt(await network.provider.send('eth_chainId'), 16);
const defaultIdType = chainIdDefaultIdTypeMap.get(chainId);
Expand Down
32 changes: 32 additions & 0 deletions test/verifier/zkp-verifier.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect } from "chai";
import { DeployHelper } from "../../helpers/DeployHelper";

describe("Atomic Sig Validator", function () {
let verifier: any, sig: any;

beforeEach(async () => {
const deployHelper = await DeployHelper.initialize(null, true);
verifier = await deployHelper.deployZKPVerifier();

const contracts = await deployHelper.deployValidatorContracts(
"VerifierSigWrapper",
"CredentialAtomicQuerySigValidator"
);
sig = contracts.validator;
});

it('test query param pagination', async () => {
for (let i = 0; i < 30; i++) {
await verifier.setZKPReques(i, 'metadataN' + i, sig.address, '0x00');
}
let queries = await verifier.getRequestQueries(5, 10);
expect(queries.length).to.be.equal(10);
expect(queries[0].metadata).to.be.equal('metadataN5');
expect(queries[9].metadata).to.be.equal('metadataN14');

queries = await verifier.getRequestQueries(15, 3);
expect(queries.length).to.be.equal(3);
expect(queries[0].metadata).to.be.equal('metadataN15');
expect(queries[2].metadata).to.be.equal('metadataN17');
});
});

0 comments on commit bed984b

Please sign in to comment.