diff --git a/cairo/tests/ethereum/cancun/test_state.py b/cairo/tests/ethereum/cancun/test_state.py index 2f99c7be..98a88def 100644 --- a/cairo/tests/ethereum/cancun/test_state.py +++ b/cairo/tests/ethereum/cancun/test_state.py @@ -35,6 +35,23 @@ from tests.utils.strategies import address, bytes32, code, state, transient_storage +def _state_deep_copy(state: State) -> State: + return State( + _main_trie=copy_trie(state._main_trie), + _storage_tries={ + addr: copy_trie(trie) for addr, trie in state._storage_tries.items() + }, + _snapshots=[ + ( + copy_trie(trie_tuple[0]), + {addr: copy_trie(trie) for addr, trie in trie_tuple[1].items()}, + ) + for trie_tuple in state._snapshots + ], + created_accounts=state.created_accounts, + ) + + @composite def state_and_address_and_optional_key( draw, state_strategy=state, address_strategy=address, key_strategy=None @@ -128,20 +145,7 @@ def test_move_ether( state, sender_address = data # We need to create a deep copy of the state to avoid mutating the original state # We can refactor it into a deep_copy State util if we ever need to do this again - python_state = State( - _main_trie=copy_trie(state._main_trie), - _storage_tries={ - addr: copy_trie(trie) for addr, trie in state._storage_tries.items() - }, - _snapshots=[ - ( - copy_trie(trie_tuple[0]), - {addr: copy_trie(trie) for addr, trie in trie_tuple[1].items()}, - ) - for trie_tuple in state._snapshots - ], - created_accounts=state.created_accounts, - ) + python_state = _state_deep_copy(state) try: move_ether(python_state, sender_address, recipient_address, amount)