public void Can_do_roundtrip_root()
        {
            TransactionReceipt transactionReceipt = Build.A.Receipt.TestObject;

            transactionReceipt.BlockNumber = 1;
            transactionReceipt.BlockHash   = TestItem.KeccakA;
            transactionReceipt.Bloom       = new Bloom();
            transactionReceipt.Bloom.Set(Keccak.EmptyTreeHash.Bytes);
            transactionReceipt.ContractAddress      = TestItem.AddressA;
            transactionReceipt.Sender               = TestItem.AddressB;
            transactionReceipt.Recipient            = TestItem.AddressC;
            transactionReceipt.GasUsed              = 100;
            transactionReceipt.GasUsedTotal         = 1000;
            transactionReceipt.Index                = 2;
            transactionReceipt.PostTransactionState = TestItem.KeccakH;

            TransactionReceiptDecoder decoder = new TransactionReceiptDecoder();
            Rlp rlp = decoder.Encode(transactionReceipt);
            TransactionReceipt deserialized = decoder.Decode(rlp.Bytes.AsRlpContext());

            Assert.AreEqual(null, deserialized.BlockHash, "block hash");
            Assert.AreEqual(UInt256.Zero, deserialized.BlockNumber, "block number");
            Assert.AreEqual(0, deserialized.Index, "index");
            Assert.AreEqual(null, deserialized.ContractAddress, "contract");
            Assert.AreEqual(null, deserialized.Sender, "sender");
            Assert.AreEqual(0L, deserialized.GasUsed, "gas used");
            Assert.AreEqual(1000L, deserialized.GasUsedTotal, "gas used total");
            Assert.AreEqual(transactionReceipt.Bloom, deserialized.Bloom, "bloom");
            Assert.AreEqual(transactionReceipt.PostTransactionState, deserialized.PostTransactionState, "post transaction state");
            Assert.AreEqual(null, deserialized.Recipient, "recipient");
            Assert.AreEqual(transactionReceipt.StatusCode, deserialized.StatusCode, "status");
        }
        public void Can_do_roundtrip_storage()
        {
            TransactionReceipt receipt = Build.A.Receipt.TestObject;

            receipt.BlockNumber = 1;
            receipt.BlockHash   = TestObject.KeccakA;
            receipt.Bloom       = new Bloom();
            receipt.Bloom.Set(Keccak.EmptyTreeHash.Bytes);
            receipt.ContractAddress      = TestObject.AddressA;
            receipt.Sender               = TestObject.AddressB;
            receipt.Recipient            = TestObject.AddressC;
            receipt.GasUsed              = 100;
            receipt.GasUsedTotal         = 1000;
            receipt.Index                = 2;
            receipt.PostTransactionState = TestObject.KeccakH;

            TransactionReceiptDecoder decoder = new TransactionReceiptDecoder();
            Rlp rlp = decoder.Encode(receipt, RlpBehaviors.Storage);
            TransactionReceipt deserialized = decoder.Decode(rlp.Bytes.AsRlpContext(), RlpBehaviors.Storage);

            Assert.AreEqual(receipt.BlockHash, deserialized.BlockHash, "block hash");
            Assert.AreEqual(receipt.BlockNumber, deserialized.BlockNumber, "block number");
            Assert.AreEqual(receipt.Index, deserialized.Index, "index");
            Assert.AreEqual(receipt.ContractAddress, deserialized.ContractAddress, "contract");
            Assert.AreEqual(receipt.Sender, deserialized.Sender, "sender");
            Assert.AreEqual(receipt.GasUsed, deserialized.GasUsed, "gas used");
            Assert.AreEqual(receipt.GasUsedTotal, deserialized.GasUsedTotal, "gas used total");
            Assert.AreEqual(receipt.Bloom, deserialized.Bloom, "bloom");
            Assert.AreEqual(receipt.PostTransactionState, deserialized.PostTransactionState, "post transaction state");
            Assert.AreEqual(receipt.Recipient, deserialized.Recipient, "recipient");
            Assert.AreEqual(receipt.StatusCode, deserialized.StatusCode, "status");
        }
示例#3
0
        public void Can_do_roundtrip()
        {
            TransactionReceipt        receipt = Build.A.Receipt.TestObject;
            TransactionReceiptDecoder decoder = new TransactionReceiptDecoder();
            Rlp rlp = decoder.Encode(receipt);
            TransactionReceipt deserialized = decoder.Decode(rlp.Bytes.AsRlpContext());

            Assert.AreEqual(receipt.GasUsed, deserialized.GasUsed, "gas used");
            Assert.AreEqual(receipt.Bloom, deserialized.Bloom, "bloom");
            Assert.AreEqual(receipt.PostTransactionState, deserialized.PostTransactionState, "post transaction state");
            Assert.AreEqual(receipt.Recipient, deserialized.Recipient, "recipient");
            Assert.AreEqual(receipt.StatusCode, deserialized.StatusCode, "status");
        }