Skip to content

Commit 3185c6f

Browse files
marioevzfselmo
authored andcommitted
feat(fixtures/specs): Add fixture config objects
1 parent e4e2dfc commit 3185c6f

20 files changed

+446
-22
lines changed

docs/consuming_tests/blockchain_test.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ For each [`Fixture`](#fixture) test object in the JSON fixture file, perform the
5454

5555
#### - `network`: [`Fork`](./common_types.md#fork)
5656

57+
##### TO BE DEPRECATED
58+
5759
Fork configuration for the test.
5860

61+
This field is going to be replaced by the value contained in `config.network`.
62+
5963
#### - `pre`: [`Alloc`](./common_types.md#alloc-mappingaddressaccount)
6064

6165
Starting account allocation for the test. State root calculated from this allocation must match the one in the genesis block.
@@ -84,6 +88,16 @@ Account allocation for verification after all the blocks have been processed.
8488

8589
Deprecated: Seal engine used to mine the blocks.
8690

91+
#### - `config`: [`FixtureConfig`](#fixtureconfig)
92+
93+
Chain configuration object to be applied to the client running the blockchain test.
94+
95+
### `FixtureConfig`
96+
97+
#### - `network`: [`Fork`](./common_types.md#fork)
98+
99+
Fork configuration for the test. It is guaranteed that this field contains the same value as the root field `network`.
100+
87101
### `FixtureHeader`
88102

89103
#### - `parentHash`: [`Hash`](./common_types.md#hash)

docs/consuming_tests/blockchain_test_engine.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ For each [`HiveFixture`](#hivefixture) test object in the JSON fixture file, per
4545

4646
#### - `network`: [`Fork`](./common_types.md#fork)
4747

48+
##### TO BE DEPRECATED
49+
4850
Fork configuration for the test.
4951

52+
This field is going to be replaced by the value contained in `config.network`.
53+
5054
#### - `genesisBlockHeader`: [`FixtureHeader`](./blockchain_test.md#fixtureheader)
5155

5256
Genesis block header.
@@ -63,10 +67,24 @@ Version of the `engine_forkchoiceUpdatedVX` directive to use to set the head of
6367

6468
Starting account allocation for the test. State root calculated from this allocation must match the one in the genesis block.
6569

70+
#### - `lastblockhash`: [`Hash`](./common_types.md#hash)
71+
72+
Hash of the last valid block, or the genesis block hash if the list of blocks is empty, or contains a single invalid block.
73+
6674
#### - `post`: [`Alloc`](./common_types.md#alloc-mappingaddressaccount)
6775

6876
Account allocation for verification after all the blocks have been processed.
6977

78+
#### - `config`: [`FixtureConfig`](#fixtureconfig)
79+
80+
Chain configuration object to be applied to the client running the blockchain engine test.
81+
82+
### `FixtureConfig`
83+
84+
#### - `network`: [`Fork`](./common_types.md#fork)
85+
86+
Fork configuration for the test. It is guaranteed that this field contains the same value as the root field `network`.
87+
7088
### `FixtureEngineNewPayload`
7189

7290
#### - `executionPayload`: [`FixtureExecutionPayload`](#fixtureexecutionpayload)

docs/consuming_tests/state_test.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ Transaction to be executed.
6060

6161
Mapping of lists of post for verification per fork, where each element represents a single possible outcome of the transaction execution after being applied to the `pre`.
6262

63+
#### - `config`: [`FixtureConfig`](#fixtureconfig)
64+
65+
Chain configuration object.
66+
67+
### `FixtureConfig`
68+
69+
At the moment, this object is an empty dictionary and contains no fields.
70+
6371
### `FixtureEnvironment`
6472

6573
#### - `currentCoinbase`: [`Address`](./common_types.md#address)

src/ethereum_test_fixtures/blockchain.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ def without_rlp(self) -> FixtureBlockBase:
396396
)
397397

398398

399+
class FixtureConfig(CamelModel):
400+
"""Chain configuration for a fixture."""
401+
402+
fork: str = Field(..., alias="network")
403+
404+
399405
class InvalidFixtureBlock(CamelModel):
400406
"""Representation of an invalid Ethereum block within a test Fixture."""
401407

@@ -412,6 +418,7 @@ class BlockchainFixtureCommon(BaseFixture):
412418
pre: Alloc
413419
post_state: Alloc | None = Field(None)
414420
last_block_hash: Hash = Field(..., alias="lastblockhash") # FIXME: lastBlockHash
421+
config: FixtureConfig
415422

416423
def get_fork(self) -> str | None:
417424
"""Return fork of the fixture as a string."""

src/ethereum_test_fixtures/state.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ class FixtureForkPost(CamelModel):
8686
expect_exception: TransactionExceptionInstanceOrList | None = None
8787

8888

89+
class FixtureConfig(CamelModel):
90+
"""Chain configuration for a fixture."""
91+
92+
pass
93+
94+
8995
class StateFixture(BaseFixture):
9096
"""Fixture for a single StateTest."""
9197

@@ -96,6 +102,7 @@ class StateFixture(BaseFixture):
96102
pre: Alloc
97103
transaction: FixtureTransaction
98104
post: Mapping[str, List[FixtureForkPost]]
105+
config: FixtureConfig
99106

100107
def get_fork(self) -> str | None:
101108
"""Return fork of the fixture as a string."""

src/ethereum_test_specs/blockchain.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from ethereum_test_fixtures.blockchain import (
3131
FixtureBlock,
3232
FixtureBlockBase,
33+
FixtureConfig,
3334
FixtureEngineNewPayload,
3435
FixtureHeader,
3536
FixtureTransaction,
@@ -573,14 +574,18 @@ def make_fixture(
573574
)
574575

575576
self.verify_post_state(t8n, t8n_state=alloc)
577+
network_info = self.network_info(fork, eips)
576578
return BlockchainFixture(
577-
fork=self.network_info(fork, eips),
579+
fork=network_info,
578580
genesis=genesis.header,
579581
genesis_rlp=genesis.rlp,
580582
blocks=fixture_blocks,
581583
last_block_hash=head,
582584
pre=pre,
583585
post_state=alloc,
586+
config=FixtureConfig(
587+
fork=network_info,
588+
),
584589
)
585590

586591
def make_hive_fixture(
@@ -666,15 +671,19 @@ def make_hive_fixture(
666671
error_code=None,
667672
)
668673

674+
network_info = self.network_info(fork, eips)
669675
return BlockchainEngineFixture(
670-
fork=self.network_info(fork, eips),
676+
fork=network_info,
671677
genesis=genesis.header,
672678
payloads=fixture_payloads,
673679
fcu_version=fcu_version,
674680
pre=pre,
675681
post_state=alloc,
676682
sync_payload=sync_payload,
677683
last_block_hash=head_hash,
684+
config=FixtureConfig(
685+
fork=network_info,
686+
),
678687
)
679688

680689
def generate(

src/ethereum_test_specs/state.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
StateFixture,
1818
)
1919
from ethereum_test_fixtures.state import (
20+
FixtureConfig,
2021
FixtureEnvironment,
2122
FixtureForkPost,
2223
FixtureTransaction,
@@ -173,6 +174,7 @@ def make_state_test_fixture(
173174
]
174175
},
175176
transaction=FixtureTransaction.from_transaction(tx),
177+
config=FixtureConfig(),
176178
)
177179

178180
def generate(

src/ethereum_test_specs/tests/fixtures/blockchain_london_invalid_filled.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"000/my_blockchain_test/London": {
33
"_info": {
4-
"hash": "0x4de3f84e3cb1e678141d81ce96ce75edb53f1824a708e26098b610c3c1030e66",
4+
"hash": "0x76838b666ca44a330fcf031ae20392647c3251ad54f29e995890bd608948b915",
55
"fixture_format": "blockchain_test"
66
},
77
"network": "London",
@@ -539,6 +539,9 @@
539539
"storage": {}
540540
}
541541
},
542-
"sealEngine": "NoProof"
542+
"sealEngine": "NoProof",
543+
"config": {
544+
"network": "London"
545+
}
543546
}
544547
}

src/ethereum_test_specs/tests/fixtures/blockchain_london_valid_filled.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"000/my_blockchain_test/London": {
33
"_info": {
4-
"hash": "0x91032fb245f4488b204198312cbf16429c121435705ac3f9c6eb3943ec0bc36d",
4+
"hash": "0x7694748a5d5e0ea1e5e914210fb8db7c8077f070dd29ffcb13774d526aee35de",
55
"fixture_format": "blockchain_test"
66
},
77
"network": "London",
@@ -417,6 +417,9 @@
417417
"storage": {}
418418
}
419419
},
420-
"sealEngine": "NoProof"
420+
"sealEngine": "NoProof",
421+
"config": {
422+
"network": "London"
423+
}
421424
}
422425
}

src/ethereum_test_specs/tests/fixtures/blockchain_shanghai_invalid_filled_engine.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"000/my_blockchain_test/Shanghai": {
33
"_info": {
4-
"hash": "0x107426e7483fe00d8db263f7522d523a6efbed5c93fd98006e65593ce496a1c4",
4+
"hash": "0x75f8ac4dbd5bfee6046a0edd5bec5448e23d1f249c10025a47bfb46ff7dab303",
55
"fixture_format": "blockchain_test_engine"
66
},
77
"lastblockhash": "0xfc75f11c05ec814a890141bef919bb7c20dd29245e37e9bcea66008dfde98526",
@@ -188,7 +188,6 @@
188188
"forkchoiceUpdatedVersion": "2"
189189
}
190190
],
191-
"lastblockhash": "0xfc75f11c05ec814a890141bef919bb7c20dd29245e37e9bcea66008dfde98526",
192191
"pre": {
193192
"0x000000000000000000000000000000000000c0de": {
194193
"nonce": "0x01",
@@ -313,6 +312,9 @@
313312
"code": "0x",
314313
"storage": {}
315314
}
315+
},
316+
"config": {
317+
"network": "Shanghai"
316318
}
317319
}
318320
}

0 commit comments

Comments
 (0)