Skip to content

Commit f34f19c

Browse files
authored
feat(fixtures): Add state field to post in state tests (#1064)
* feat(fixtures): Add `postDecoded` field to state tests * rename field to `state`
1 parent d0e1236 commit f34f19c

File tree

7 files changed

+63
-4
lines changed

7 files changed

+63
-4
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Test fixtures for use by clients are available for each release on the [Github r
8787
- ✨ A new application-wide configuration manager provides access to environment and application configurations. ([#892](https://github.com/ethereum/execution-spec-tests/pull/892)).
8888
- 🐞 Use a local version of ethereum/execution-specs (EELS) when running the framework tests in CI ([#997](https://github.com/ethereum/execution-spec-tests/pull/997)).
8989
- ✨ Use self-hosted runners for fixture building in CI ([#1051](https://github.com/ethereum/execution-spec-tests/pull/1051)).
90+
-`StateTest` fixture format now contains `state` field in each network post result, containing the decoded post allocation that results from the transaction execution ([#1064](https://github.com/ethereum/execution-spec-tests/pull/1064)).
9091

9192
### 💥 Breaking Change
9293

docs/consuming_tests/state_test.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ Hash of the RLP representation of the state logs result of applying the transact
171171

172172
Exception that is expected to be thrown by the transaction execution (Field is missing if the transaction is expected to succeed)
173173

174+
#### - `state`: [`Alloc`](./common_types.md#alloc-mappingaddressaccount)
175+
176+
Dictionary that represents the allocation after execution of the transaction.
177+
174178
### `FixtureForkPostIndexes`
175179

176180
#### - `data`: `int`

src/ethereum_test_fixtures/state.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class FixtureForkPost(CamelModel):
8282
logs_hash: Hash = Field(..., alias="logs")
8383
tx_bytes: Bytes = Field(..., alias="txbytes")
8484
indexes: FixtureForkPostIndexes = Field(default_factory=FixtureForkPostIndexes)
85+
state: Alloc
8586
expect_exception: TransactionExceptionInstanceOrList | None = None
8687

8788

src/ethereum_test_fixtures/tests/test_state.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
state_root="0x00",
2020
logs_hash="0x01",
2121
tx_bytes="0x02",
22+
state={},
2223
),
2324
{
2425
"hash": Hash(0).hex(),
2526
"logs": Hash(1).hex(),
2627
"txbytes": Bytes(b"\x02").hex(),
2728
"indexes": {"data": 0, "gas": 0, "value": 0},
29+
"state": {},
2830
},
2931
id="state_fixture_fork_post",
3032
),
@@ -35,13 +37,15 @@
3537
logs_hash="0x01",
3638
tx_bytes="0x02",
3739
expect_exception=TransactionException.INITCODE_SIZE_EXCEEDED,
40+
state={},
3841
),
3942
{
4043
"hash": Hash(0).hex(),
4144
"logs": Hash(1).hex(),
4245
"txbytes": Bytes(b"\x02").hex(),
4346
"expectException": "TransactionException.INITCODE_SIZE_EXCEEDED",
4447
"indexes": {"data": 0, "gas": 0, "value": 0},
48+
"state": {},
4549
},
4650
id="state_fixture_fork_post_exception",
4751
),
@@ -53,13 +57,15 @@
5357
logs_hash="0x01",
5458
tx_bytes="0x02",
5559
expect_exception=[TransactionException.INITCODE_SIZE_EXCEEDED],
60+
state={},
5661
),
5762
{
5863
"hash": Hash(0).hex(),
5964
"logs": Hash(1).hex(),
6065
"txbytes": Bytes(b"\x02").hex(),
6166
"expectException": "TransactionException.INITCODE_SIZE_EXCEEDED",
6267
"indexes": {"data": 0, "gas": 0, "value": 0},
68+
"state": {},
6369
},
6470
id="state_fixture_fork_post_exception_list_1",
6571
),
@@ -73,6 +79,7 @@
7379
TransactionException.INITCODE_SIZE_EXCEEDED,
7480
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS,
7581
],
82+
state={},
7683
),
7784
{
7885
"hash": Hash(0).hex(),
@@ -81,6 +88,7 @@
8188
"expectException": "TransactionException.INITCODE_SIZE_EXCEEDED|"
8289
"TransactionException.INSUFFICIENT_ACCOUNT_FUNDS",
8390
"indexes": {"data": 0, "gas": 0, "value": 0},
91+
"state": {},
8492
},
8593
id="state_fixture_fork_post_exception_list_2",
8694
),

src/ethereum_test_specs/state.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def make_state_test_fixture(
167167
logs_hash=transition_tool_output.result.logs_hash,
168168
tx_bytes=tx.rlp,
169169
expect_exception=tx.error,
170+
state=transition_tool_output.alloc,
170171
)
171172
]
172173
},

src/ethereum_test_specs/tests/fixtures/chainid_paris_state_test.json

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"000/my_chain_id_test/Paris": {
33
"_info": {
4-
"hash": "0x9533310242d3fe15fca5ea1d31f97121f7db0f54843c9f2160c01f2468b10535",
4+
"hash": "0x14d892cf15f595cc7160e0e66020fa553252c33fc185c3b825bb018d4aac62b6",
55
"fixture_format": "state_test"
66
},
77
"env": {
@@ -53,9 +53,31 @@
5353
"data": 0,
5454
"gas": 0,
5555
"value": 0
56+
},
57+
"state": {
58+
"0x1000000000000000000000000000000000000000": {
59+
"nonce": "0x00",
60+
"balance": "0x00",
61+
"code": "0x4660015500",
62+
"storage": {
63+
"0x01": "0x01"
64+
}
65+
},
66+
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
67+
"balance": "0x01f923",
68+
"nonce": "0x00",
69+
"code": "0x",
70+
"storage": {}
71+
},
72+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
73+
"nonce": "0x01",
74+
"balance": "0x3635c9adc5de996c36",
75+
"code": "0x",
76+
"storage": {}
77+
}
5678
}
5779
}
5880
]
5981
}
6082
}
61-
}
83+
}

src/ethereum_test_specs/tests/fixtures/chainid_shanghai_state_test.json

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"000/my_chain_id_test/Shanghai": {
33
"_info": {
4-
"hash": "0xac10a919bea8bb3bc6b74cb291d92ce12549216dd78dde2d2bd6d94fd48897aa",
4+
"hash": "0x288556997e3809e7b3a3f97415a661600fdf3652e9fedf617264d70ce255893f",
55
"fixture_format": "state_test"
66
},
77
"env": {
@@ -53,9 +53,31 @@
5353
"data": 0,
5454
"gas": 0,
5555
"value": 0
56+
},
57+
"state": {
58+
"0x1000000000000000000000000000000000000000": {
59+
"nonce": "0x00",
60+
"balance": "0x00",
61+
"code": "0x4660015500",
62+
"storage": {
63+
"0x01": "0x01"
64+
}
65+
},
66+
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
67+
"balance": "0x01f923",
68+
"nonce": "0x00",
69+
"code": "0x",
70+
"storage": {}
71+
},
72+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
73+
"nonce": "0x01",
74+
"balance": "0x3635c9adc5de996c36",
75+
"code": "0x",
76+
"storage": {}
77+
}
5678
}
5779
}
5880
]
5981
}
6082
}
61-
}
83+
}

0 commit comments

Comments
 (0)