From cf4a22382c81d8092501cf6677aea9f502dcf373 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Tue, 7 Nov 2023 13:29:30 -0500 Subject: [PATCH] Use patch.object instead of patch for mocking PoW. 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. --- tests/helpers/load_state_tests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/helpers/load_state_tests.py b/tests/helpers/load_state_tests.py index a99957fde2..eca2da7f22 100644 --- a/tests/helpers/load_state_tests.py +++ b/tests/helpers/load_state_tests.py @@ -1,3 +1,4 @@ +import importlib import json import os.path import re @@ -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)