6363 },
6464 Type : AccessListTxType ,
6565 }
66+ eip1559Receipt = & Receipt {
67+ Status : ReceiptStatusFailed ,
68+ CumulativeGasUsed : 1 ,
69+ Logs : []* Log {
70+ {
71+ Address : common .BytesToAddress ([]byte {0x11 }),
72+ Topics : []common.Hash {common .HexToHash ("dead" ), common .HexToHash ("beef" )},
73+ Data : []byte {0x01 , 0x00 , 0xff },
74+ },
75+ {
76+ Address : common .BytesToAddress ([]byte {0x01 , 0x11 }),
77+ Topics : []common.Hash {common .HexToHash ("dead" ), common .HexToHash ("beef" )},
78+ Data : []byte {0x01 , 0x00 , 0xff },
79+ },
80+ },
81+ Type : DynamicFeeTxType ,
82+ }
6683)
6784
6885func TestDecodeEmptyTypedReceipt (t * testing.T ) {
@@ -273,6 +290,24 @@ func TestReceiptMarshalBinary(t *testing.T) {
273290 if ! bytes .Equal (have , accessListWant ) {
274291 t .Errorf ("encoded RLP mismatch, got %x want %x" , have , accessListWant )
275292 }
293+
294+ // 1559 Receipt
295+ buf .Reset ()
296+ eip1559Receipt .Bloom = CreateBloom (Receipts {eip1559Receipt })
297+ have , err = eip1559Receipt .MarshalBinary ()
298+ if err != nil {
299+ t .Fatalf ("marshal binary error: %v" , err )
300+ }
301+ eip1559Receipts := Receipts {eip1559Receipt }
302+ eip1559Receipts .EncodeIndex (0 , buf )
303+ haveEncodeIndex = buf .Bytes ()
304+ if ! bytes .Equal (have , haveEncodeIndex ) {
305+ t .Errorf ("BinaryMarshal and EncodeIndex mismatch, got %x want %x" , have , haveEncodeIndex )
306+ }
307+ eip1559Want := common .FromHex ("02f901c58001b9010000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000010000080000000000000000000004000000000000000000000000000040000000000000000000000000000800000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000f8bef85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100fff85d940000000000000000000000000000000000000111f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff" )
308+ if ! bytes .Equal (have , eip1559Want ) {
309+ t .Errorf ("encoded RLP mismatch, got %x want %x" , have , eip1559Want )
310+ }
276311}
277312
278313func TestReceiptUnmarshalBinary (t * testing.T ) {
@@ -297,6 +332,17 @@ func TestReceiptUnmarshalBinary(t *testing.T) {
297332 if ! reflect .DeepEqual (gotAccessListReceipt , accessListReceipt ) {
298333 t .Errorf ("receipt unmarshalled from binary mismatch, got %v want %v" , gotAccessListReceipt , accessListReceipt )
299334 }
335+
336+ // 1559 Receipt
337+ eip1559RctBinary := common .FromHex ("02f901c58001b9010000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000010000080000000000000000000004000000000000000000000000000040000000000000000000000000000800000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000f8bef85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100fff85d940000000000000000000000000000000000000111f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff" )
338+ got1559Receipt := new (Receipt )
339+ if err := got1559Receipt .UnmarshalBinary (eip1559RctBinary ); err != nil {
340+ t .Fatalf ("unmarshal binary error: %v" , err )
341+ }
342+ eip1559Receipt .Bloom = CreateBloom (Receipts {eip1559Receipt })
343+ if ! reflect .DeepEqual (got1559Receipt , eip1559Receipt ) {
344+ t .Errorf ("receipt unmarshalled from binary mismatch, got %v want %v" , got1559Receipt , eip1559Receipt )
345+ }
300346}
301347
302348func clearComputedFieldsOnReceipts (t * testing.T , receipts Receipts ) {
0 commit comments