Skip to content

Commit

Permalink
Use patch.object instead of patch for mocking PoW.
Browse files Browse the repository at this point in the history
For some reason, pypy (and cpython on GitHub) cannot seem to correctly
patch the london hardfork using the `patch` function. I've switched to
using the `patch.object` function since you can explicitly provide the
object, bypassing the import error. I'm not 100% sure this is correct.
  • Loading branch information
SamWilsn committed Jan 9, 2024
1 parent 17ca634 commit cf4a223
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/helpers/load_state_tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib
import json
import os.path
import re
Expand Down Expand Up @@ -101,8 +102,12 @@ def add_block_to_chain(
if not mock_pow:
load.state_transition(chain, block)
else:
with patch(
f"ethereum.{load.fork_module}.fork.validate_proof_of_work",
fork_module = importlib.import_module(
f"ethereum.{load.fork_module}.fork"
)
with patch.object(
fork_module,
"validate_proof_of_work",
autospec=True,
) as mocked_pow_validator:
load.state_transition(chain, block)
Expand Down

0 comments on commit cf4a223

Please sign in to comment.