/* eslint-disable prettier/prettier */ import { expect } from 'chai'; import { ALT_BN128_F, asyncPoseidonHash, dpPoseidonHash, PoseidonHash } from '../src/'; import { poseidonTestCaseList } from './data/poseidon.testcase'; describe(`test poseidon hash`, function () { this.timeout(1000000); before(async function () { await asyncPoseidonHash; }) it('Number should in alt_bn128 field', function () { const hash = PoseidonHash([1n]); const hash2 = PoseidonHash([1n + ALT_BN128_F]); expect(hash).equal(18586133768512220936620570745912940619677854269274689475585506675881198879027n); expect(hash).equal(hash2); }); Object.entries(poseidonTestCaseList).forEach(([name, cases]) => { cases.forEach(({ args, expected }) => { it(`${name}[${args}]`, function () { const result = dpPoseidonHash(args.map(v => BigInt(v))); expect(result.toString()).equal(expected); }); }); }); });