fix tests

This commit is contained in:
Alexey 2021-02-04 20:14:06 +03:00
parent 780adf3626
commit c4b81058ed
2 changed files with 11 additions and 17 deletions

@ -87,10 +87,11 @@ contract TornadoTrees is EnsResolve {
uint256 i = depositLeaf; uint256 i = depositLeaf;
todo deposits.length = _tornadoTreesV1.deposits.length // todo deposits.length = _tornadoTreesV1.deposits.length
while (true) { while (true) {
(bool success, bytes memory data) = address(_tornadoTreesV1).call(abi.encodeWithSignature("deposits(uint256)", i)); (bool success, bytes memory data) = address(_tornadoTreesV1).staticcall{ gas: 3000 }( // todo define more specise gas value.
// console.log("success", success); abi.encodeWithSignature("deposits(uint256)", i)
);
if (!success) { if (!success) {
break; break;
} }
@ -99,23 +100,19 @@ contract TornadoTrees is EnsResolve {
deposits.push(deposit); deposits.push(deposit);
} }
uint256 j = withdrawalLeaf; i = withdrawalLeaf;
while (true) { while (true) {
(bool success1, bytes memory data1) = address(_tornadoTreesV1).staticcall( (bool success, bytes memory data) = address(_tornadoTreesV1).staticcall{ gas: 3000 }(
abi.encodeWithSignature("withdrawals(uint256)", j) abi.encodeWithSignature("withdrawals(uint256)", i)
); );
// console.log("success", success);
// console.logBytes(data);
if (!success1) { if (!success) {
break; break;
} }
bytes32 withdrawal = abi.decode(data1, (bytes32)); bytes32 withdrawal = abi.decode(data, (bytes32));
// console.logBytes32(withdrawal); i++;
j++;
withdrawals.push(withdrawal); withdrawals.push(withdrawal);
} }
console.log("end");
} }
function registerDeposit(address _instance, bytes32 _commitment) external onlyTornadoProxy onlyInitialized { function registerDeposit(address _instance, bytes32 _commitment) external onlyTornadoProxy onlyInitialized {

@ -16,8 +16,6 @@ async function register(note, tornadoTrees, from) {
) )
} }
const toEns = (addr) => toFixedHex(addr, 20).padEnd(66, '0')
const levels = 20 const levels = 20
const CHUNK_TREE_HEIGHT = 2 const CHUNK_TREE_HEIGHT = 2
@ -78,7 +76,6 @@ describe('TornadoTrees', function () {
tornadoProxy.address, tornadoProxy.address,
tornadoTreesV1.address, tornadoTreesV1.address,
verifier.address, verifier.address,
// { gasLimit: 30e6 },
) )
await tornadoTrees.migrate(depositEvents, withdrawalEvents) await tornadoTrees.migrate(depositEvents, withdrawalEvents)
}) })
@ -90,7 +87,7 @@ describe('TornadoTrees', function () {
expect(solHash).to.be.equal(args[0]) 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 { input, args } = controller.batchTreeUpdate(tree, depositEvents)
const proof = await controller.prove(input, './artifacts/circuits/BatchTreeUpdate') const proof = await controller.prove(input, './artifacts/circuits/BatchTreeUpdate')
await tornadoTrees.updateDepositTree(proof, ...args) await tornadoTrees.updateDepositTree(proof, ...args)