示例#1
0
        public void Can_do_roundtrip_with_receipt_message_and_tx_type_access_list()
        {
            TxReceipt txReceipt = Build.A.Receipt.TestObject;

            txReceipt.Bloom = new Bloom();
            txReceipt.Bloom.Set(Keccak.EmptyTreeHash.Bytes);
            txReceipt.GasUsedTotal         = 1000;
            txReceipt.PostTransactionState = TestItem.KeccakH;
            txReceipt.TxType = TxType.AccessList;

            ReceiptMessageDecoder decoder = new ReceiptMessageDecoder();

            byte[]    rlpStreamResult = decoder.Encode(txReceipt).Bytes;
            TxReceipt deserialized    = decoder.Decode(new RlpStream(rlpStreamResult));

            AssertMessageReceipt(txReceipt, deserialized);
        }
        public void Can_do_roundtrip_with_receipt_message_and_tx_type_access_list()
        {
            TxReceipt txReceipt = Build.A.Receipt.TestObject;

            txReceipt.Bloom = new Bloom();
            txReceipt.Bloom.Set(Keccak.EmptyTreeHash.Bytes);
            txReceipt.GasUsedTotal         = 1000;
            txReceipt.PostTransactionState = TestItem.KeccakH;
            txReceipt.TxType = TxType.AccessList;

            ReceiptMessageDecoder decoder = new ReceiptMessageDecoder();

            byte[]    rlpStreamResult = decoder.Encode(txReceipt).Bytes;
            TxReceipt deserialized    = decoder.Decode(new RlpStream(rlpStreamResult));

            Assert.AreEqual(txReceipt.Bloom, deserialized.Bloom, "bloom");
            Assert.AreEqual(txReceipt.GasUsedTotal, deserialized.GasUsedTotal, "gas used total");
            Assert.AreEqual(txReceipt.PostTransactionState, deserialized.PostTransactionState, "post transaction state");
            Assert.AreEqual(txReceipt.StatusCode, deserialized.StatusCode, "status");
            Assert.AreEqual(txReceipt.TxType, deserialized.TxType, "type");
        }
        public ReceiptsMessage Deserialize(RlpStream rlpStream)
        {
            TxReceipt[][] data = rlpStream.DecodeArray(itemContext =>
                                                       itemContext.DecodeArray(nestedContext => _decoder.Decode(nestedContext)) ?? new TxReceipt[0], true);
            ReceiptsMessage message = new ReceiptsMessage(data);

            return(message);
        }
        public ReceiptsMessage Deserialize(byte[] bytes)
        {
            if (bytes.Length == 0 || bytes[0] == Rlp.OfEmptySequence[0])
            {
                return(new ReceiptsMessage(null));
            }

            RlpStream rlpStream = bytes.AsRlpStream();

            TxReceipt[][] data = rlpStream.DecodeArray(itemContext =>
                                                       itemContext.DecodeArray(nestedContext => _decoder.Decode(nestedContext)) ?? new TxReceipt[0], true);
            ReceiptsMessage message = new ReceiptsMessage(data);

            return(message);
        }