Skip to content

Commit e66b45d

Browse files
committed
fix(test-fixtures): emit chainId in state test fixture transaction (#3125)
1 parent 1dc3a0e commit e66b45d

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

docs/running_tests/test_formats/state_test.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ Excess blob gas of the block where the transaction is executed.
108108

109109
### `FixtureTransaction`
110110

111+
#### - `chainId`: [`ZeroPaddedHexNumber`](./common_types.md#zeropaddedhexnumber)
112+
113+
Chain id of the transaction; omitted for unprotected (non-EIP-155) type-0 transactions
114+
111115
#### - `nonce`: [`ZeroPaddedHexNumber`](./common_types.md#zeropaddedhexnumber)
112116

113117
Nonce of the account that sends the transaction

packages/testing/src/execution_testing/fixtures/state.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class FixtureTransaction(TransactionFixtureConverter):
4646
# via model_dump(), which includes many fields not in this model.
4747
model_config = CamelModel.model_config | {"extra": "ignore"}
4848

49+
chain_id: ZeroPaddedHexNumber | None = None
4950
nonce: ZeroPaddedHexNumber
5051
gas_price: ZeroPaddedHexNumber | None = None
5152
max_priority_fee_per_gas: ZeroPaddedHexNumber | None = None
@@ -69,6 +70,9 @@ def from_transaction(cls, tx: Transaction) -> "FixtureTransaction":
6970
exclude={"gas_limit", "value", "data", "access_list"},
7071
exclude_none=True,
7172
)
73+
if tx.ty == 0 and not tx.protected:
74+
# Unprotected legacy transactions encode no chain id.
75+
model_as_dict.pop("chain_id", None)
7276
model_as_dict["gas_limit"] = [tx.gas_limit]
7377
model_as_dict["value"] = [tx.value]
7478
model_as_dict["data"] = [tx.data]

packages/testing/src/execution_testing/specs/tests/fixtures/chainid_cancun_state_test_tx_type_1.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"000/my_chain_id_test/Cancun/tx_type_1": {
33
"_info": {
4-
"hash": "0x49130f37343fa73f364ed83e2a2e7146c4effa64cdb6b371f5f2bf3f2004fade",
4+
"hash": "0x0c9cdd9849022dfb46f20fc00a646394a58e0fc8847f6e3cf578dff67378e6bc",
55
"fixture_format": "state_test"
66
},
77
"env": {
@@ -39,6 +39,7 @@
3939
}
4040
},
4141
"transaction": {
42+
"chainId": "0x01",
4243
"accessLists": [
4344
[
4445
{

0 commit comments

Comments
 (0)