public async Task insert_leaves_given_hash_is_emitting_an_event(int leafCount) { SingleReleaseSpecProvider spec = new SingleReleaseSpecProvider(ConstantinopleFix.Instance, 1); TestRpcBlockchain testRpc = await TestRpcBlockchain.ForTest(SealEngineType.NethDev).Build(spec); BaselineModule baselineModule = new BaselineModule( testRpc.TxPoolBridge, testRpc.LogFinder, testRpc.BlockTree, _abiEncoder, _fileSystem, new MemDb(), LimboLogs.Instance); await testRpc.AddFunds(TestItem.Addresses[0], 1.Ether()); Keccak txHash = (await baselineModule.baseline_deploy(TestItem.Addresses[0], "MerkleTreeSHA")).Data; await testRpc.AddBlock(); ReceiptForRpc receipt = (await testRpc.EthModule.eth_getTransactionReceipt(txHash)).Data; Keccak[] leaves = Enumerable.Repeat(TestItem.KeccakH, leafCount).ToArray(); Keccak insertLeavesTxHash = (await baselineModule.baseline_insertLeaves( TestItem.Addresses[1], receipt.ContractAddress, leaves)).Data; await testRpc.AddBlock(); ReceiptForRpc insertLeafReceipt = (await testRpc.EthModule.eth_getTransactionReceipt( insertLeavesTxHash)).Data; insertLeafReceipt.Logs.Should().HaveCount(1); insertLeafReceipt.Logs[0].Data.Length.Should().Be(128 + leafCount * 32); }
public async Task can_work_with_many_trees() { SingleReleaseSpecProvider spec = new SingleReleaseSpecProvider(ConstantinopleFix.Instance, 1); TestRpcBlockchain testRpc = await TestRpcBlockchain.ForTest(SealEngineType.NethDev).Build(spec); BaselineModule baselineModule = new BaselineModule( testRpc.TxSender, testRpc.StateReader, testRpc.LogFinder, testRpc.BlockTree, _abiEncoder, _fileSystem, new MemDb(), LimboLogs.Instance); await testRpc.AddFunds(TestItem.Addresses[0], 1.Ether()); await testRpc.AddFunds(TestItem.Addresses[1], 1.Ether()); Keccak txHash = (await baselineModule.baseline_deploy(TestItem.Addresses[0], "MerkleTreeSHA")).Data; Keccak txHash2 = (await baselineModule.baseline_deploy(TestItem.Addresses[0], "MerkleTreeSHA")).Data; Keccak txHash3 = (await baselineModule.baseline_deploy(TestItem.Addresses[0], "MerkleTreeSHA")).Data; await testRpc.AddBlock(); await testRpc.AddBlock(); await testRpc.AddBlock(); ReceiptForRpc receipt = (await testRpc.EthModule.eth_getTransactionReceipt(txHash)).Data; ReceiptForRpc receipt2 = (await testRpc.EthModule.eth_getTransactionReceipt(txHash2)).Data; ReceiptForRpc receipt3 = (await testRpc.EthModule.eth_getTransactionReceipt(txHash3)).Data; receipt.Status.Should().Be(1); receipt2.Status.Should().Be(1); receipt3.Status.Should().Be(1); await baselineModule.baseline_insertLeaves( TestItem.Addresses[1], receipt.ContractAddress, TestItem.KeccakG, TestItem.KeccakH); await baselineModule.baseline_insertLeaves( TestItem.Addresses[1], receipt2.ContractAddress, TestItem.KeccakE, TestItem.KeccakF); await baselineModule.baseline_insertLeaf( TestItem.Addresses[1], receipt3.ContractAddress, TestItem.KeccakG); await baselineModule.baseline_insertLeaf( TestItem.Addresses[1], receipt3.ContractAddress, TestItem.KeccakH); await testRpc.AddBlock(); await testRpc.AddBlock(); await baselineModule.baseline_track(receipt.ContractAddress); await baselineModule.baseline_track(receipt2.ContractAddress); await baselineModule.baseline_track(receipt3.ContractAddress); var result = await baselineModule.baseline_getSiblings(receipt.ContractAddress, 1); var result2 = await baselineModule.baseline_getSiblings(receipt2.ContractAddress, 1); var result3 = await baselineModule.baseline_getSiblings(receipt3.ContractAddress, 1); await testRpc.AddBlock(); result.Result.ResultType.Should().Be(ResultType.Success); result.Data.Should().HaveCount(32); result2.Result.ResultType.Should().Be(ResultType.Success); result2.Data.Should().HaveCount(32); result3.Result.ResultType.Should().Be(ResultType.Success); result3.Data.Should().HaveCount(32); for (int i = 1; i < 32; i++) { result.Data[i].Hash.Should().Be(Keccak.Zero); result2.Data[i].Hash.Should().Be(Keccak.Zero); result3.Data[i].Hash.Should().Be(Keccak.Zero); } result.Data[0].Hash.Should().NotBe(Keccak.Zero); result2.Data[0].Hash.Should().NotBe(Keccak.Zero); result3.Data[0].Hash.Should().NotBe(Keccak.Zero); result.Data[0].Hash.Should().NotBe(result2.Data[0].Hash); result.Data[0].Hash.Should().Be(result3.Data[0].Hash); }