Exemplo n.º 1
0
        public void get_transaction_returns_null_when_block_not_found()
        {
            var receipt = Build.A.Receipt.WithBlockHash(TestItem.KeccakB).TestObject;

            _receiptStorage.FindBlockHash(TestItem.KeccakA).Returns(TestItem.KeccakB);
            _blockchainBridge.GetTransaction(TestItem.KeccakA).Should().Be((null, null));
        }
Exemplo n.º 2
0
        private void TestAddAndGetReceipt(IReceiptStorage storage, IReceiptFinder receiptFinder = null)
        {
            bool recoverSender = receiptFinder is not null;

            receiptFinder ??= storage;

            var transaction = GetSignedTransaction();

            transaction.SenderAddress = null;
            var block   = GetBlock(transaction);
            var receipt = GetReceipt(transaction, block);

            storage.Insert(block, receipt);
            var blockHash = storage.FindBlockHash(transaction.Hash);

            blockHash.Should().Be(block.Hash);
            var fetchedReceipt = receiptFinder.Get(block).ForTransaction(transaction.Hash);

            receipt.StatusCode.Should().Be(fetchedReceipt.StatusCode);
            receipt.PostTransactionState.Should().Be(fetchedReceipt.PostTransactionState);
            receipt.TxHash.Should().Be(transaction.Hash);
            if (recoverSender)
            {
                receipt.Sender.Should().BeEquivalentTo(TestItem.AddressA);
            }
        }
        private void TestAddAndGetReceiptEip658(IReceiptStorage storage)
        {
            var transaction = GetSignedTransaction();
            var block       = GetBlock(transaction);
            var receipt     = GetReceipt(transaction, block);

            storage.Insert(block, receipt);
            var blockHash = storage.FindBlockHash(transaction.Hash);

            blockHash.Should().Be(block.Hash);
            var fetchedReceipt = storage.Get(block).ForTransaction(transaction.Hash);

            receipt.StatusCode.Should().Be(fetchedReceipt.StatusCode);
            receipt.PostTransactionState.Should().Be(fetchedReceipt.PostTransactionState);
            receipt.TxHash.Should().Be(transaction.Hash);
        }
Exemplo n.º 4
0
        public GethLikeTxTrace Trace(Keccak txHash, GethTraceOptions traceOptions)
        {
            Keccak blockHash = _receiptStorage.FindBlockHash(txHash);

            if (blockHash == null)
            {
                return(null);
            }

            Block block = _blockTree.FindBlock(blockHash, BlockTreeLookupOptions.RequireCanonical);

            if (block == null)
            {
                return(null);
            }

            return(Trace(block, txHash, traceOptions));
        }
Exemplo n.º 5
0
 public Keccak FindBlockHash(Keccak txHash) => _inStorage.FindBlockHash(txHash);
 public Keccak FindBlockHash(Keccak txHash) => _receiptStorage.FindBlockHash(txHash);