public byte[] Serialize(ReceiptsMessage message)
 {
     if (message.TxReceipts == null)
     {
         return(Rlp.OfEmptySequence.Bytes);
     }
     return(Rlp.Encode(message.TxReceipts.Select(
                           b => b == null
             ? Rlp.OfEmptySequence
             : Rlp.Encode(
                               b.Select(
                                   n => n == null
                         ? Rlp.OfEmptySequence
                         : _decoder.Encode(n, _specProvider.GetSpec(n.BlockNumber).IsEip658Enabled ? RlpBehaviors.Eip658Receipts : RlpBehaviors.None)).ToArray())).ToArray()).Bytes);
 }
示例#2
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");
        }