Skip to content

Commit

Permalink
add poseidon test for 6-elements array
Browse files Browse the repository at this point in the history
  • Loading branch information
dev0x1 committed Oct 10, 2023
1 parent d7a3b26 commit 4a1fc29
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/contracts/test/hasher/PoseidonHasher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { BigNumber } from 'ethers';
import { contract, ethers } from 'hardhat';
import { PoseidonHasher } from '@webb-tools/anchors';
const assert = require('assert');
import { poseidon } from 'circomlibjs';

contract('Poseidon hasher', (accounts) => {
let hasherInstance: PoseidonHasher;
Expand All @@ -20,9 +21,18 @@ contract('Poseidon hasher', (accounts) => {
});

describe('#sponge-hash', () => {
it('should hash random values of array', async () => {
it('should hash random values of 6-elements array', async () => {
const inputs: any = [];
for (let i = 0; i < 13; i++) {
for (let i = 0; i < 6; i++) {
inputs.push(randomBN());
}
let contractResult = await hasherInstance.contract.hash6(inputs);
let result = poseidon(inputs);
assert.strictEqual(result.toString(), contractResult.toString());
});
it('should hash random values of 50-elements array', async () => {
const inputs: any = [];
for (let i = 0; i < 50; i++) {
inputs.push(randomBN());
}
let contractResult = await hasherInstance.contract.hash(inputs);
Expand Down

0 comments on commit 4a1fc29

Please sign in to comment.