Skip to content

Commit

Permalink
fix: indentation and proper test for accountbound
Browse files Browse the repository at this point in the history
  • Loading branch information
yum0e committed Dec 6, 2022
1 parent f6f7ec4 commit 70bfa2d
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions test/unit/attesters/hydra-s1/hydra-s1-accountbound-attester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,27 +609,39 @@ describe('Test HydraS1 Accountbound Attester contract', () => {
destinationSigner.address
)
).to.be.true;
});

it("should get the nullifier and burn count from attestation's extra data", async () => {
const attestationExtraData = await attestationsRegistry.getAttestationExtraData(
group.properties.groupIndex,
destinationSigner.address
);
it("should get the nullifier and burn count from attestation's extra data", async () => {
const attestationExtraData = await attestationsRegistry.getAttestationExtraData(
(
await hydraS1AccountboundAttester.AUTHORIZED_COLLECTION_ID_FIRST()
).add(group.properties.groupIndex),
destinationSigner.address
);

expect(attestationExtraData).to.be.eql(
encodeAccountBoundAttestationExtraData({
nullifier: inputs.publicInputs.nullifier,
burnCount: 0,
})
);

expect(
await hydraS1AccountboundAttester.getNullifierFromExtraData(attestationExtraData)
).to.be.eql(inputs.publicInputs.nullifier);
expect(
await hydraS1AccountboundAttester.getBurnCountFromExtraData(attestationExtraData)
).to.be.eql(0);
});
expect(attestationExtraData).to.be.eql(
encodeAccountBoundAttestationExtraData({
nullifier: inputs.publicInputs.nullifier,
burnCount: 0,
})
);

expect(
await hydraS1AccountboundAttester.getNullifierFromExtraData(
ethers.utils.defaultAbiCoder.encode(
['uint256', 'uint16'],
[inputs.publicInputs.nullifier, 0]
)
)
).to.be.eql(BigNumber.from(inputs.publicInputs.nullifier));
expect(
await hydraS1AccountboundAttester.getBurnCountFromExtraData(
ethers.utils.defaultAbiCoder.encode(
['uint256', 'uint16'],
[inputs.publicInputs.nullifier, 0]
)
)
).to.be.eql(0);
});

it('Should revert if the groupIndex has no cooldownDuration set', async () => {
Expand Down

0 comments on commit 70bfa2d

Please sign in to comment.