Skip to content

Commit 0322c04

Browse files
tests: isolated phase manager behaviour
1 parent 2e738ee commit 0322c04

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

src/ethereum_test_specs/blockchain.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,9 @@ class Block(Header):
240240
expected_post_state: Alloc | None = None
241241
"""Post state for verification after block execution in BlockchainTest"""
242242
block_access_list: Bytes | None = Field(None)
243-
"""
244-
EIP-7928: Block-level access lists (serialized).
245-
"""
243+
"""EIP-7928: Block-level access lists (serialized)."""
246244
test_phase: TestPhase | None = None
247-
"""
248-
Test phase for this block.
249-
"""
245+
"""Test phase for this block."""
250246

251247
def set_environment(self, env: Environment) -> Environment:
252248
"""

src/ethereum_test_types/tests/test_phase_manager.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,44 @@ def test_phase_switching_preserves_existing_data():
224224
assert exec_values == [100, 200, 300]
225225

226226

227+
def test_multiple_managers_phase_isolation():
228+
"""Test that phase dependence for managers is isolated."""
229+
manager1 = TestPhaseManager()
230+
manager2 = TestPhaseManager()
231+
232+
# Both managers should start in execution phase
233+
assert manager1.get_current_phase() == TestPhase.EXECUTION
234+
assert manager2.get_current_phase() == TestPhase.EXECUTION
235+
236+
# Change phase of manager1 to setup
237+
with manager1.setup():
238+
# manager1 should be in setup phase
239+
assert manager1.get_current_phase() == TestPhase.SETUP
240+
# manager2 should still be in execution phase
241+
assert manager2.get_current_phase() == TestPhase.EXECUTION
242+
243+
# Add transactions to verify phase isolation
244+
tx1 = Transaction(to=Address(0x100), value=100, gas_limit=21000)
245+
tx2 = Transaction(to=Address(0x200), value=200, gas_limit=21000)
246+
247+
manager1.add_transaction(tx1)
248+
manager2.add_transaction(tx2)
249+
250+
# Verify transactions are in correct phases
251+
assert tx1.test_phase == TestPhase.SETUP.value
252+
assert tx2.test_phase == TestPhase.EXECUTION.value
253+
254+
# After exiting setup context, manager1 should return to execution phase
255+
assert manager1.get_current_phase() == TestPhase.EXECUTION
256+
assert manager2.get_current_phase() == TestPhase.EXECUTION
257+
258+
# Verify final state
259+
assert len(manager1.setup_transactions) == 1
260+
assert len(manager1.execution_transactions) == 0
261+
assert len(manager2.setup_transactions) == 0
262+
assert len(manager2.execution_transactions) == 1
263+
264+
227265
@pytest.mark.parametrize(
228266
["manager_instance", "expected_phase"],
229267
[

0 commit comments

Comments
 (0)