public void Eth_get_transaction_receipt_returns_null_on_missing_receipt() { IBlockchainBridge bridge = Substitute.For <IBlockchainBridge>(); bridge.GetReceipt(Arg.Any <Keccak>()).Returns((TxReceipt)null); IEthModule module = new EthModule(NullLogManager.Instance, bridge); string serialized = RpcTest.TestSerializedRequest(EthModuleFactory.Converters, module, "eth_getTransactionReceipt", TestItem.KeccakA.ToString()); Assert.AreEqual("{\"id\":67,\"jsonrpc\":\"2.0\",\"result\":null}", serialized); }
public ResultWrapper <ReceiptForRpc> eth_getTransactionReceipt(Keccak txHash) { var receipt = _blockchainBridge.GetReceipt(txHash); if (receipt == null) { return(ResultWrapper <ReceiptForRpc> .Success(null)); } var receiptModel = new ReceiptForRpc(txHash, receipt); if (_logger.IsTrace) { _logger.Trace($"eth_getTransactionReceipt request {txHash}, result: {txHash}"); } return(ResultWrapper <ReceiptForRpc> .Success(receiptModel)); }
public void Eth_get_transaction_receipt() { IBlockchainBridge bridge = Substitute.For <IBlockchainBridge>(); var entries = new[] { Build.A.LogEntry.TestObject, Build.A.LogEntry.TestObject }; bridge.GetReceipt(Arg.Any <Keccak>()).Returns(Build.A.Receipt.WithBloom(new Bloom(entries, new Bloom())).WithAllFieldsFilled.WithLogs(entries).TestObject); IEthModule module = new EthModule(NullLogManager.Instance, bridge); string serialized = RpcTest.TestSerializedRequest(EthModuleFactory.Converters, module, "eth_getTransactionReceipt", TestItem.KeccakA.ToString()); Assert.AreEqual("{\"id\":67,\"jsonrpc\":\"2.0\",\"result\":{\"transactionHash\":\"0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760\",\"transactionIndex\":\"0x2\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"cumulativeGasUsed\":\"0x3e8\",\"gasUsed\":\"0x64\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"logs\":[{\"removed\":false,\"logIndex\":\"0x0\",\"transactionIndex\":\"0x2\",\"transactionHash\":\"0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"address\":\"0x0000000000000000000000000000000000000000\",\"data\":\"0x\",\"topics\":[\"0x0000000000000000000000000000000000000000000000000000000000000000\"]},{\"removed\":false,\"logIndex\":\"0x1\",\"transactionIndex\":\"0x2\",\"transactionHash\":\"0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"address\":\"0x0000000000000000000000000000000000000000\",\"data\":\"0x\",\"topics\":[\"0x0000000000000000000000000000000000000000000000000000000000000000\"]}],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"root\":\"0x1f675bff07515f5df96737194ea945c36c41e7b4fcef307b7cd4d0e602a69111\",\"status\":\"0x1\",\"error\":\"error\"}}", serialized); }
public ResultWrapper <ReceiptForRpc> eth_getTransactionReceipt(Keccak txHash) { try { _readerWriterLockSlim.EnterReadLock(); var receipt = _blockchainBridge.GetReceipt(txHash); if (receipt == null) { return(ResultWrapper <ReceiptForRpc> .Success(null)); } var receiptModel = new ReceiptForRpc(txHash, receipt); if (Logger.IsTrace) { Logger.Trace($"eth_getTransactionReceipt request {txHash}, result: {txHash}"); } return(ResultWrapper <ReceiptForRpc> .Success(receiptModel)); } finally { _readerWriterLockSlim.ExitReadLock(); } }