tornadocash / tornado-core

Tornado cash. Non-custodial private transactions on Ethereum.
https://tornado.cash
GNU General Public License v3.0
1.49k stars 561 forks source link

npm run test failed with "Invalid withdraw proof" #70

Open mikoto10001 opened 3 years ago

mikoto10001 commented 3 years ago

I am following the readme.md to run test bellows:

npm install
cp .env.example .env
npm run build - this may take 10 minutes or more
npx ganache-cli
npm run test 

but it failed with error: Invalid withdraw proof

The proving_key in verifier sol file and ERC20Tornado.test.js is the same.
but the code returns false in https://github.com/tornadocash/tornado-core/blob/master/test/ETHTornado.test.js#L138

anyone have an idea where is the problem and how to fix this?

logs:

 1) Contract: ERC20Tornado
       #withdraw
         should work:
     Error: Returned error: VM Exception while processing transaction: revert Invalid withdraw proof -- Reason given: Invalid withdraw proof.
     at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:6:1)
      at TruffleContract.withdraw (node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:158:1)
      at Context.<anonymous> (test/ERC20Tornado.test.js:169:86)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

  2) Contract: ERC20Tornado
       #withdraw
         should return refund to the relayer is case of fail:
     Error: Returned error: VM Exception while processing transaction: revert Invalid withdraw proof -- Reason given: Invalid withdraw proof.
     at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:6:1)
      at TruffleContract.withdraw (node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:158:1)
      at Context.<anonymous> (test/ERC20Tornado.test.js:248:86)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

  3) Contract: ERC20Tornado
       #withdraw
         should reject with wrong refund value:

      AssertionError: expected 'Invalid withdraw proof' to equal 'Incorrect refund amount received by the contract'
      + expected - actual

      -Invalid withdraw proof
      +Incorrect refund amount received by the contract

      at Context.<anonymous> (test/ERC20Tornado.test.js:313:24)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

  4) Contract: ETHTornado
       snark proof verification on js side
         should detect tampering:

      AssertionError: expected false to equal true
      + expected - actual

      -false
      +true

      at Context.<anonymous> (test/ETHTornado.test.js:138:24)

  5) Contract: ETHTornado
       #withdraw
         should work:
     Error: Returned error: VM Exception while processing transaction: revert Invalid withdraw proof -- Reason given: Invalid withdraw proof.
     at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:6:1)
      at TruffleContract.withdraw (node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:158:1)
      at Context.<anonymous> (test/ETHTornado.test.js:217:71)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

  6) Contract: ETHTornado
       #withdraw
         should prevent double spend:
     AssertionError: expected promise to be fulfilled but it was rejected with 'Error: Returned error: VM Exception while processing transaction: revert Invalid withdraw proof -- Reason given: Invalid withdraw proof.'

  7) Contract: ETHTornado
       #withdraw
         should reject with tampered public inputs:
     AssertionError: expected promise to be fulfilled but it was rejected with 'Error: Returned error: VM Exception while processing transaction: revert Invalid withdraw proof -- Reason given: Invalid withdraw proof.'

  8) Contract: ETHTornado
       #withdraw
         should reject with non zero refund:

      AssertionError: expected 'Invalid withdraw proof' to equal 'Refund value is supposed to be zero for ETH instance'
      + expected - actual

      -Invalid withdraw proof
      +Refund value is supposed to be zero for ETH instance

      at Context.<anonymous> (test/ETHTornado.test.js:482:30)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

  9) Contract: ETHTornado
       #isSpent
         should work:
     Error: Returned error: VM Exception while processing transaction: revert Invalid withdraw proof -- Reason given: Invalid withdraw proof.
     at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:6:1)
      at TruffleContract.withdraw (node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:158:1)
      at Context.<anonymous> (test/ETHTornado.test.js:573:54)

npm ERR! code ELIFECYCLE
npm ERR! errno 9
npm ERR! circuits@1.0.0 test: `npx truffle test`
npm ERR! Exit status 9
npm ERR!
npm ERR! Failed at the circuits@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/hao/.npm/_logs/2021-01-25T07_28_46_486Z-debug.log
fc976d commented 2 years ago

In the place of npm run build, put npm run download. So in sequence:

npm install
cp .env.example .env
npm run download
npx ganache-cli
npm run test