maci
maci copied to clipboard
Test TallyVotes.test.ts fails
Steps to Reproduce
cd circuits
npm install
npx jest __tests__/TallyVotes.test.ts
Failure Logs
/mnt/sdd1/sbw/circom/ZKAP_docker/sbwTest/benchmarks/maci-4892ada0dc7bcc2f7710aea917e309f1553317c5/circuits/node_modules/@zk-kit/poseidon-cipher/dist/index.js:9
import { Fr, r } from '@zk-kit/baby-jubjub';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
at Object.<anonymous> (node_modules/maci-crypto/ts/hashing.ts:1:1)
Steps to Reproduce
cd circuits npm install npx jest __tests__/TallyVotes.test.tsFailure Logs
/mnt/sdd1/sbw/circom/ZKAP_docker/sbwTest/benchmarks/maci-4892ada0dc7bcc2f7710aea917e309f1553317c5/circuits/node_modules/@zk-kit/poseidon-cipher/dist/index.js:9 import { Fr, r } from '@zk-kit/baby-jubjub'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14) at Object.<anonymous> (node_modules/maci-crypto/ts/hashing.ts:1:1)
So those tests are not meant to be run with Jest, you can run that particular one using pnpm test:tallyVotes - lmk if that works @Subway2023
Also make sure you are using pnpm and installing and building before running tests. In the monorepo root: pnpm install && pnpm build
Steps to Reproduce
cd circuits npm install npx jest __tests__/TallyVotes.test.tsFailure Logs
/mnt/sdd1/sbw/circom/ZKAP_docker/sbwTest/benchmarks/maci-4892ada0dc7bcc2f7710aea917e309f1553317c5/circuits/node_modules/@zk-kit/poseidon-cipher/dist/index.js:9 import { Fr, r } from '@zk-kit/baby-jubjub'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14) at Object.<anonymous> (node_modules/maci-crypto/ts/hashing.ts:1:1)So those tests are not meant to be run with Jest, you can run that particular one using
pnpm test:tallyVotes- lmk if that works @Subway2023Also make sure you are using
pnpmand installing and building before running tests. In the monorepo root:pnpm install && pnpm build
According to your method, I still cannot run it, and the above error persists. I am running an older version of the project, which has a bug: Initial Conditions Are Not Properly Enforced so I want to conduct tests. The old version includes a jest.config.js file, so I suspect it uses the Jest framework. However, I still haven't successfully run TallyVotes.test.ts.
Steps to Reproduce
cd circuits npm install npx jest __tests__/TallyVotes.test.tsFailure Logs
/mnt/sdd1/sbw/circom/ZKAP_docker/sbwTest/benchmarks/maci-4892ada0dc7bcc2f7710aea917e309f1553317c5/circuits/node_modules/@zk-kit/poseidon-cipher/dist/index.js:9 import { Fr, r } from '@zk-kit/baby-jubjub'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14) at Object.<anonymous> (node_modules/maci-crypto/ts/hashing.ts:1:1)So those tests are not meant to be run with Jest, you can run that particular one using
pnpm test:tallyVotes- lmk if that works @Subway2023 Also make sure you are usingpnpmand installing and building before running tests. In the monorepo root:pnpm install && pnpm buildAccording to your method, I still cannot run it, and the above error persists. I am running an older version of the project, which has a bug: Initial Conditions Are Not Properly Enforced so I want to conduct tests. The old version includes a jest.config.js file, so I suspect it uses the Jest framework. However, I still haven't successfully run TallyVotes.test.ts.
@Subway2023 I see, but based on the stack trace it doesn't look like you are running that old version, at the time the project was not using @zk-kit/baby-jubjub so it could not error out there. Could you share the full instructions on how to reproduce it please?
cd circuits
npm install
npx jest TallyVotes.test.ts
commad (npx jest TallyVotes.test.ts) comes from the testing program in the project.
cd circuits npm install npx jest TallyVotes.test.tscommad (npx jest TallyVotes.test.ts) comes from the testing program in the project.
Let's take a step back, did you clone the repo and checked out to a specific commit, a pr? did you install the package from npm? Knowing that would allow me to try it out too
i just download this commit and perform above commands.
i just download this commit and perform above commands.
ok so first you need to install the packages and build the monorepo. Also you'd need to install these libraries https://github.com/privacy-scaling-explorations/maci/blob/4bc217db24f573c1da5e24ad0caca596637c3dc8/.travis.yml#L7
You can see the steps required to make that specific version working in this file https://github.com/privacy-scaling-explorations/maci/blob/4bc217db24f573c1da5e24ad0caca596637c3dc8/.travis.yml
You can https://github.com/privacy-scaling-explorations/maci/blob/4bc217db24f573c1da5e24ad0caca596637c3dc8/.travis.yml#L11-L14 Then https://github.com/privacy-scaling-explorations/maci/blob/4bc217db24f573c1da5e24ad0caca596637c3dc8/circuits/scripts/runTestsInCi.sh#L6 Then ( no need for && ofc) https://github.com/privacy-scaling-explorations/maci/blob/4bc217db24f573c1da5e24ad0caca596637c3dc8/circuits/scripts/runTestsInCi.sh#L10
my commands are as follows:
npm i npm run bootstrap npm run build cd circuits npm i npm run circom-helper & npx jest TallyVotes.test.tshowever there is still errors:
/mnt/sdd1/sbw/circom/ZKAP_docker/sbwTest/benchmarks/maci-4bc217db24f573c1da5e24ad0caca596637c3dc8/circuits/node_modules/@zk-kit/poseidon-cipher/dist/index.js:9 import { Fr, r } from '@zk-kit/baby-jubjub'; ^^^^^^
Please try and start from a clean checkout of that branch, make sure to remove any node_modules you might have. Cause that error is coming from a library that was introduced this year, but the code you are trying to run is from years ago so there must be something stored locally. Also do not run run again npm i after you cd circuits
Thank you very much! it works.
Why can't TallyVotes.test.ts pass the tests?
npx jest TallyVotes.test.ts
FAIL ts/__tests__/TallyVotes.test.ts (15.032 s)
TallyVotes circuit
1 user, 2 messages
✕ should produce the correct result commitments (4263 ms)
10 users, 10 messages
✕ should produce the correct state root and ballot root (8029 ms)
● TallyVotes circuit › 1 user, 2 messages › should produce the correct result commitments
Request failed with status code 503
However, if I get the generatedInputs from TallyVotes.test.ts, generate the witness, and perform the checks, it works successfully. Test is my test script
Why can't TallyVotes.test.ts pass the tests?
npx jest TallyVotes.test.ts FAIL ts/__tests__/TallyVotes.test.ts (15.032 s) TallyVotes circuit 1 user, 2 messages ✕ should produce the correct result commitments (4263 ms) 10 users, 10 messages ✕ should produce the correct state root and ballot root (8029 ms) ● TallyVotes circuit › 1 user, 2 messages › should produce the correct result commitments Request failed with status code 503However, if I get the generatedInputs from TallyVotes.test.ts, generate the witness, and perform the checks, it works successfully. Test is my test script
hey sorry just getting back to work today, will try and find some time to run through this. have you got any updates on this since 2 weeks ago?
Thank you for your reply. I currently have no new progress. My goal is to execute TallyVotes.test.ts to obtain the inputs for tallyVotes.circom in order to reproduce the vulnerability of Initial Conditions Are Not Properly Enforced. Please refer to the issue. I would greatly appreciate any help you can provide on this matter.
Hey sorry to come back to this so late. Have you managed to make any progress?
commad (npx jest TallyVotes.test.ts) comes from the testing program in the project.