public async Task call_should_invoke_blockchain_bridge_call_and_return_data() { Block head = Build.A.Block.TestObject; Transaction transaction = Build.A.Transaction.TestObject; byte[] data = new byte[] { 0, 1, 2 }; _blockchainBridge.HeadBlock.Returns(head); BlockchainBridge.CallOutput output = new BlockchainBridge.CallOutput(data, 0, null); _blockchainBridge.Call(head?.Header, transaction, default).Returns(output); byte[] result = await _ndmBridge.CallAsync(transaction); _blockchainBridge.Received().Call(head?.Header, transaction, default); result.Should().BeSameAs(data); }
public async Task call_should_invoke_blockchain_bridge_call_and_return_data() { var head = Build.A.BlockHeader.TestObject; var transaction = Build.A.Transaction.TestObject; var data = new byte[] { 0, 1, 2 }; _blockchainBridge.Head.Returns(head); var output = new BlockchainBridge.CallOutput(data, 0, null); _blockchainBridge.Call(head, transaction).Returns(output); var result = await _ndmBridge.CallAsync(transaction); _blockchainBridge.Received().Call(head, transaction); result.Should().BeSameAs(data); }
public async Task <UInt256> ReadDepositBalanceAsync(Address onBehalfOf, Keccak depositId) { var txData = _abiEncoder.Encode(AbiEncodingStyle.IncludeSignature, ContractData.DepositBalanceAbiSig, depositId.Bytes); Transaction transaction = new Transaction { Value = 0, Data = txData, To = _contractAddress, SenderAddress = onBehalfOf, GasLimit = 100000, GasPrice = 0.GWei(), Nonce = await _blockchainBridge.GetNonceAsync(onBehalfOf) }; var data = await _blockchainBridge.CallAsync(transaction); return(data.ToUInt256()); }
public async Task call_should_invoke_proxy_eth_call_with_transaction_argument() { var transaction = Build.A.Transaction.TestObject; var data = new byte[] { 0, 1, 2 }; var callModel = CallTransactionModel.FromTransaction(transaction); _proxy.eth_call(Arg.Is <CallTransactionModel>(x => x.From == callModel.From && x.To == callModel.To && x.Gas == callModel.Gas && x.GasPrice == callModel.GasPrice && x.Value == callModel.Value && x.Data.SequenceEqual(callModel.Data))) .Returns(RpcResult <byte[]> .Ok(data)); var result = await _ndmBridge.CallAsync(transaction); await _proxy.Received().eth_call(Arg.Any <CallTransactionModel>()); result.Should().BeSameAs(data); }