Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test TallyVotes.test.ts fails #1839

Open
Subway2023 opened this issue Sep 29, 2024 · 8 comments
Open

Test TallyVotes.test.ts fails #1839

Subway2023 opened this issue Sep 29, 2024 · 8 comments
Assignees

Comments

@Subway2023
Copy link

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)
@ctrlc03
Copy link
Collaborator

ctrlc03 commented Sep 30, 2024

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)

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

@Subway2023
Copy link
Author

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)

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

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.

@ctrlc03
Copy link
Collaborator

ctrlc03 commented Oct 1, 2024

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)

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

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.

@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?

@ctrlc03 ctrlc03 self-assigned this Oct 1, 2024
@Subway2023
Copy link
Author

cd circuits
npm install

npx jest TallyVotes.test.ts
1727767797569

commad (npx jest TallyVotes.test.ts) comes from the testing program in the project.

@ctrlc03
Copy link
Collaborator

ctrlc03 commented Oct 1, 2024

cd circuits
npm install

npx jest TallyVotes.test.ts
1727767797569 commad (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

@Subway2023
Copy link
Author

i just download this commit and perform above commands.

@ctrlc03
Copy link
Collaborator

ctrlc03 commented Oct 1, 2024

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

- sudo apt-get install -y libgmp-dev nlohmann-json3-dev nasm g++ build-essential libsodium-dev git

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

maci/.travis.yml

Lines 11 to 14 in 4bc217d

- npm i
- npm run bootstrap
- npm run build
- cd circuits

Then
npm run circom-helper &

Then ( no need for && ofc)
npx jest TallyVotes.test.ts &&

@ctrlc03
Copy link
Collaborator

ctrlc03 commented Oct 1, 2024

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.ts

however 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants