From c4b81058edab13dee03de7fbc1bb95b2eb9ce71a Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 4 Feb 2021 20:14:06 +0300 Subject: [PATCH] fix tests --- contracts/TornadoTrees.sol | 23 ++++++++++------------- test/tornadoTrees.test.js | 5 +---- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/contracts/TornadoTrees.sol b/contracts/TornadoTrees.sol index 0850dbe..e10935e 100644 --- a/contracts/TornadoTrees.sol +++ b/contracts/TornadoTrees.sol @@ -87,10 +87,11 @@ contract TornadoTrees is EnsResolve { uint256 i = depositLeaf; - todo deposits.length = _tornadoTreesV1.deposits.length + // todo deposits.length = _tornadoTreesV1.deposits.length while (true) { - (bool success, bytes memory data) = address(_tornadoTreesV1).call(abi.encodeWithSignature("deposits(uint256)", i)); - // console.log("success", success); + (bool success, bytes memory data) = address(_tornadoTreesV1).staticcall{ gas: 3000 }( // todo define more specise gas value. + abi.encodeWithSignature("deposits(uint256)", i) + ); if (!success) { break; } @@ -99,23 +100,19 @@ contract TornadoTrees is EnsResolve { deposits.push(deposit); } - uint256 j = withdrawalLeaf; + i = withdrawalLeaf; while (true) { - (bool success1, bytes memory data1) = address(_tornadoTreesV1).staticcall( - abi.encodeWithSignature("withdrawals(uint256)", j) + (bool success, bytes memory data) = address(_tornadoTreesV1).staticcall{ gas: 3000 }( + abi.encodeWithSignature("withdrawals(uint256)", i) ); - // console.log("success", success); - // console.logBytes(data); - if (!success1) { + if (!success) { break; } - bytes32 withdrawal = abi.decode(data1, (bytes32)); - // console.logBytes32(withdrawal); - j++; + bytes32 withdrawal = abi.decode(data, (bytes32)); + i++; withdrawals.push(withdrawal); } - console.log("end"); } function registerDeposit(address _instance, bytes32 _commitment) external onlyTornadoProxy onlyInitialized { diff --git a/test/tornadoTrees.test.js b/test/tornadoTrees.test.js index d32f356..6e8aa1a 100644 --- a/test/tornadoTrees.test.js +++ b/test/tornadoTrees.test.js @@ -16,8 +16,6 @@ async function register(note, tornadoTrees, from) { ) } -const toEns = (addr) => toFixedHex(addr, 20).padEnd(66, '0') - const levels = 20 const CHUNK_TREE_HEIGHT = 2 @@ -78,7 +76,6 @@ describe('TornadoTrees', function () { tornadoProxy.address, tornadoTreesV1.address, verifier.address, - // { gasLimit: 30e6 }, ) await tornadoTrees.migrate(depositEvents, withdrawalEvents) }) @@ -90,7 +87,7 @@ describe('TornadoTrees', function () { expect(solHash).to.be.equal(args[0]) }) - it.only('should prove snark', async () => { + it('should prove snark', async () => { const { input, args } = controller.batchTreeUpdate(tree, depositEvents) const proof = await controller.prove(input, './artifacts/circuits/BatchTreeUpdate') await tornadoTrees.updateDepositTree(proof, ...args)