Skip to content

Commit b24b597

Browse files
committed
fixup: Correctly decode London dynamic-fee txns
1 parent 66adebe commit b24b597

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

tests/core/transaction-utils/test_receipt_encoding.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
TypedReceipt,
1717
)
1818

19-
RECOGNIZED_TRANSACTION_TYPES = {1}
19+
# The type of receipt is based on the type of the transaction. So we are
20+
# checking the type of the receipt against known transaction types.
21+
# Add recognized types here if any fork knows about it. Then,
22+
# add manual unrecognized types for older forks. For example,
23+
# (BerlinVM, to_bytes(2), UnrecognizedTransactionType) should be added explicitly.
24+
RECOGNIZED_TRANSACTION_TYPES = {1, 2}
2025

2126
UNRECOGNIZED_TRANSACTION_TYPES = tuple(
2227
(to_bytes(val), UnrecognizedTransactionType)
@@ -62,7 +67,7 @@
6267
),
6368
)
6469
)
65-
def test_transaction_decode(vm_class, encoded, expected):
70+
def test_receipt_decode(vm_class, encoded, expected):
6671
expected_encoding = expected.encode()
6772
assert encoded == expected_encoding
6873

@@ -83,8 +88,24 @@ def test_transaction_decode(vm_class, encoded, expected):
8388
+ UNRECOGNIZED_TRANSACTION_TYPES
8489
+ INVALID_TRANSACTION_TYPES
8590
)
86-
def test_transaction_decode_failure(vm_class, encoded, expected_failure):
87-
sedes = vm_class.get_transaction_builder()
91+
def test_receipt_decode_failure(vm_class, encoded, expected_failure):
92+
sedes = vm_class.get_receipt_builder()
93+
with pytest.raises(expected_failure):
94+
rlp.decode(encoded, sedes=sedes)
95+
96+
97+
@pytest.mark.parametrize(
98+
'vm_class, encoded, expected_failure',
99+
(
100+
(
101+
BerlinVM,
102+
to_bytes(2),
103+
UnrecognizedTransactionType,
104+
),
105+
)
106+
)
107+
def test_receipt_decode_failure_by_vm(vm_class, encoded, expected_failure):
108+
sedes = vm_class.get_receipt_builder()
88109
with pytest.raises(expected_failure):
89110
rlp.decode(encoded, sedes=sedes)
90111

tests/core/transaction-utils/test_transaction_encoding.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
LondonVM,
1414
)
1515

16-
RECOGNIZED_TRANSACTION_TYPES = {1}
16+
# Add recognized types here if any fork knows about it. Then,
17+
# add manual unrecognized types for older forks. For example,
18+
# (BerlinVM, to_bytes(2), UnrecognizedTransactionType) should be added explicitly.
19+
RECOGNIZED_TRANSACTION_TYPES = {1, 2}
1720

1821
UNRECOGNIZED_TRANSACTION_TYPES = tuple(
1922
(to_bytes(val), UnrecognizedTransactionType)
@@ -70,6 +73,22 @@ def test_transaction_decode(vm_class, encoded, expected):
7073
assert decoded == expected_txn
7174

7275

76+
@pytest.mark.parametrize(
77+
'vm_class, encoded, expected_failure',
78+
(
79+
(
80+
BerlinVM,
81+
to_bytes(2),
82+
UnrecognizedTransactionType,
83+
),
84+
)
85+
)
86+
def test_transaction_decode_failure_by_vm(vm_class, encoded, expected_failure):
87+
sedes = vm_class.get_transaction_builder()
88+
with pytest.raises(expected_failure):
89+
rlp.decode(encoded, sedes=sedes)
90+
91+
7392
@pytest.mark.parametrize('is_rlp_encoded', (True, False))
7493
def test_EIP2930_transaction_decode(typed_txn_fixture, is_rlp_encoded):
7594
signed_txn = decode_hex(typed_txn_fixture['signed'])

0 commit comments

Comments
 (0)