diff --git a/tests/fixtures.py b/tests/fixtures.py index ab38f1989..4b191ce80 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -19,6 +19,7 @@ from web3 import Web3 import tests from nucypher.blockchain.economics import Economics +from nucypher.blockchain.eth.actors import Operator from nucypher.blockchain.eth.clients import EthereumClient from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory from nucypher.blockchain.eth.registry import LocalContractRegistry @@ -341,6 +342,11 @@ def light_ursula(temp_dir_path, test_registry_source_manager, random_account, mo payment_method = SubscriptionManagerPayment( eth_provider=MOCK_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN ) + + mocker.patch.object( + Operator, "get_staking_provider_address", return_value=random_account.address + ) + ursula = Ursula( rest_host=LOOPBACK_ADDRESS, rest_port=select_test_port(), diff --git a/tests/integration/cli/test_ursula_local_keystore_cli_functionality.py b/tests/integration/cli/test_ursula_local_keystore_cli_functionality.py index b4fa95bcd..230e9a52f 100644 --- a/tests/integration/cli/test_ursula_local_keystore_cli_functionality.py +++ b/tests/integration/cli/test_ursula_local_keystore_cli_functionality.py @@ -1,5 +1,3 @@ - - import json import secrets from pathlib import Path @@ -30,7 +28,9 @@ def mock_account_password_keystore(tmp_path_factory): return account, password, keystore -@pytest.mark.usefixtures("test_registry_source_manager") +@pytest.mark.usefixtures( + "test_registry_source_manager", "monkeypatch_get_staking_provider_from_operator" +) def test_ursula_init_with_local_keystore_signer( click_runner, temp_dir_path, mocker, testerchain, mock_account_password_keystore ): diff --git a/tests/integration/config/test_character_configuration.py b/tests/integration/config/test_character_configuration.py index 1c22a001f..b6bd9c69d 100644 --- a/tests/integration/config/test_character_configuration.py +++ b/tests/integration/config/test_character_configuration.py @@ -37,6 +37,7 @@ all_configurations = tuple( ) +@pytest.mark.usefixtures("monkeypatch_get_staking_provider_from_operator") @pytest.mark.parametrize("character,configuration", characters_and_configurations) def test_development_character_configurations( character, configuration, test_registry_source_manager, mocker, testerchain diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 1d16cab38..a4e4c7b04 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -246,7 +246,6 @@ def mock_transacting_power(module_mocker, monkeymodule): @pytest.fixture(scope="module", autouse=True) def staking_providers(testerchain, test_registry, monkeymodule): - def faked(self, *args, **kwargs): return testerchain.stake_providers_accounts[testerchain.ursulas_accounts.index(self.transacting_power.account)] @@ -254,6 +253,15 @@ def staking_providers(testerchain, test_registry, monkeymodule): return testerchain.stake_providers_accounts +@pytest.fixture(scope="module") +def monkeypatch_get_staking_provider_from_operator(monkeymodule): + monkeymodule.setattr( + Operator, + "get_staking_provider_address", + lambda self: self.transacting_power.account, + ) + + @pytest.fixture(scope="session", autouse=True) def mock_condition_blockchains(session_mocker): """adds testerchain's chain ID to permitted conditional chains""" diff --git a/tests/integration/learning/test_discovery_phases.py b/tests/integration/learning/test_discovery_phases.py index c5b29d40d..cb83d9efd 100644 --- a/tests/integration/learning/test_discovery_phases.py +++ b/tests/integration/learning/test_discovery_phases.py @@ -1,9 +1,8 @@ import contextlib - -import pytest import time import maya +import pytest from nucypher_core.umbral import SecretKey, Signer from nucypher.characters.lawful import Ursula @@ -15,7 +14,7 @@ from tests.mock.performance_mocks import ( mock_message_verification, mock_metadata_validation, mock_secret_source, - mock_verify_node + mock_verify_node, ) from tests.utils.ursula import MOCK_KNOWN_URSULAS_CACHE @@ -38,6 +37,7 @@ performance bottlenecks. """ +@pytest.mark.usefixtures("monkeypatch_get_staking_provider_from_operator") def test_alice_can_learn_about_a_whole_bunch_of_ursulas(highperf_mocked_alice, test_registry_source_manager): # During the fixture execution, Alice verified one node. # TODO: Consider changing this - #1449 diff --git a/tests/integration/network/test_network_actors.py b/tests/integration/network/test_network_actors.py index 3b76d7424..a1aa7dc8a 100644 --- a/tests/integration/network/test_network_actors.py +++ b/tests/integration/network/test_network_actors.py @@ -41,6 +41,7 @@ def test_alice_finds_ursula_via_rest(alice, ursulas): assert ursula in alice.known_nodes +@pytest.mark.usefixtures("monkeypatch_get_staking_provider_from_operator") def test_vladimir_illegal_interface_key_does_not_propagate(ursulas, test_registry_source_manager): """ Although Ursulas propagate each other's interface information, as demonstrated above,