コード例 #1
0
        public async Task can_get_commit_after_commit_is_added()
        {
            SingleReleaseSpecProvider spec    = new SingleReleaseSpecProvider(ConstantinopleFix.Instance, 1);
            TestRpcBlockchain         testRpc = await TestRpcBlockchain.ForTest(SealEngineType.NethDev).Build(spec);

            BaselineModule baselineModule = CreateBaselineModule(testRpc);

            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;
            await testRpc.AddBlock();

            ReceiptForRpc receipt = (await testRpc.EthModule.eth_getTransactionReceipt(txHash)).Data;

            await baselineModule.baseline_insertCommit(TestItem.Addresses[1], receipt.ContractAddress, TestItem.KeccakH);

            await testRpc.AddBlock();

            await baselineModule.baseline_track(receipt.ContractAddress);

            var result = await baselineModule.baseline_getCommit(receipt.ContractAddress, 0);

            await testRpc.AddBlock();

            result.Result.ResultType.Should().Be(ResultType.Success);
            result.Result.Error.Should().Be(null);
            result.ErrorCode.Should().Be(0);
            result.Data.Hash.Should().NotBe(Keccak.Zero);
        }
コード例 #2
0
        public async Task can_get_commit_fails_on_wrong_index()
        {
            SingleReleaseSpecProvider spec    = new SingleReleaseSpecProvider(ConstantinopleFix.Instance, 1);
            TestRpcBlockchain         testRpc = await TestRpcBlockchain.ForTest(SealEngineType.NethDev).Build(spec);

            BaselineModule baselineModule = CreateBaselineModule(testRpc);

            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;

            await baselineModule.baseline_insertCommit(TestItem.Addresses[1], receipt.ContractAddress, TestItem.KeccakH);

            await testRpc.AddBlock();

            await baselineModule.baseline_track(receipt.ContractAddress);

            var result = await baselineModule.baseline_getCommit(receipt.ContractAddress, (UInt256)uint.MaxValue + 1);

            await testRpc.AddBlock();

            result.Result.ResultType.Should().Be(ResultType.Failure);
            result.ErrorCode.Should().Be(ErrorCodes.InvalidInput);
        }