From 499f903976684c685103ab09954f6f3448a143ff Mon Sep 17 00:00:00 2001 From: Kieran Prasch Date: Thu, 14 Sep 2023 19:00:24 +0200 Subject: [PATCH] Adapt tests and exmaples to merged Operator, without Ritualist. --- .../finnegans-wake-demo-l2.py | 8 +- examples/heartbeat_demo/alicia.py | 10 +- .../acceptance/actors/test_ritual_tracker.py | 58 +++--- .../acceptance/actors/test_ursula_operator.py | 4 +- .../characters/test_decentralized_grant.py | 9 +- tests/acceptance/cli/test_ursula_init.py | 4 +- tests/acceptance/cli/test_ursula_run.py | 165 +++++++++++------- tests/acceptance/conftest.py | 4 +- tests/conftest.py | 5 +- tests/fixtures.py | 23 ++- .../blockchain/test_ritual_tracker.py | 22 +-- tests/integration/cli/test_cli_config.py | 11 +- tests/integration/cli/test_mixed_config.py | 8 +- .../cli/test_ursula_cli_ip_detection.py | 6 +- .../integration/cli/test_ursula_config_cli.py | 31 ++-- ...ursula_local_keystore_cli_functionality.py | 4 +- .../config/test_character_configuration.py | 10 +- .../config/test_configuration_persistence.py | 4 +- .../config/test_keystore_integration.py | 10 +- tests/integration/config/test_storages.py | 24 +-- tests/metrics/grant_availability.py | 9 +- tests/unit/test_character_sign_and_verify.py | 2 +- tests/utils/config.py | 22 +-- 23 files changed, 259 insertions(+), 194 deletions(-) diff --git a/examples/finnegans_wake_demo/finnegans-wake-demo-l2.py b/examples/finnegans_wake_demo/finnegans-wake-demo-l2.py index 0594f1180..2e249a11b 100644 --- a/examples/finnegans_wake_demo/finnegans-wake-demo-l2.py +++ b/examples/finnegans_wake_demo/finnegans-wake-demo-l2.py @@ -76,8 +76,8 @@ wallet = Signer.from_signer_uri(SIGNER_URI) password = os.environ.get('DEMO_ALICE_PASSWORD') or getpass(f"Enter password to unlock Alice's wallet ({ALICE_ADDRESS[:8]}): ") wallet.unlock_account(account=ALICE_ADDRESS, password=password) -# This is Alice's payment method. -payment_method = SubscriptionManagerPayment( +# This is Alice's PRE payment method. +pre_payment_method = SubscriptionManagerPayment( network=L2_NETWORK, eth_provider=L2_PROVIDER ) @@ -88,7 +88,7 @@ alice = Alice( signer=wallet, domain=L1_NETWORK, eth_provider_uri=L1_PROVIDER, - payment_method=payment_method + pre_payment_method=pre_payment_method, ) # Alice puts her public key somewhere for Bob to find later... @@ -113,7 +113,7 @@ remote_bob = Bob.from_public_keys( # These are the policy details. expiration = maya.now() + datetime.timedelta(days=1) threshold, shares = 2, 3 -price = alice.payment_method.quote(expiration=expiration.epoch, shares=shares).value +price = alice.pre_payment_method.quote(expiration=expiration.epoch, shares=shares).value # Alice grants access to Bob... policy = alice.grant( diff --git a/examples/heartbeat_demo/alicia.py b/examples/heartbeat_demo/alicia.py index addd28f51..1d6c60e37 100644 --- a/examples/heartbeat_demo/alicia.py +++ b/examples/heartbeat_demo/alicia.py @@ -77,8 +77,8 @@ wallet = Signer.from_signer_uri(SIGNER_URI) password = os.environ.get('DEMO_ALICE_PASSWORD') or getpass(f"Enter password to unlock Alice's wallet ({ALICE_ADDRESS[:8]}): ") wallet.unlock_account(account=ALICE_ADDRESS, password=password) -# This is Alice's payment method. -payment_method = SubscriptionManagerPayment( +# This is Alice's PRE payment method. +pre_payment_method = SubscriptionManagerPayment( network=L2_NETWORK, eth_provider=L2_PROVIDER ) @@ -89,7 +89,7 @@ alicia = Alice( signer=wallet, domain=L1_NETWORK, eth_provider_uri=L1_PROVIDER, - payment_method=payment_method + pre_payment_method=pre_payment_method, ) # Alice puts her public key somewhere for Bob to find later... @@ -119,7 +119,7 @@ print( # that **don't exist yet**. # In this example, we create a local file with encrypted data, containing # heart rate measurements from a heart monitor -import heart_monitor +import heart_monitor # ruff:noqa:F402 heart_monitor.generate_heart_rate_samples(policy_pubkey, samples=50, @@ -129,7 +129,7 @@ heart_monitor.generate_heart_rate_samples(policy_pubkey, # Alicia now wants to share data associated with this label. # To do so, she needs the public key of the recipient. # In this example, we generate it on the fly (for demonstration purposes) -from doctor_keys import get_doctor_pubkeys +from doctor_keys import get_doctor_pubkeys # ruff:noqa:F402 doctor_pubkeys = get_doctor_pubkeys() diff --git a/tests/acceptance/actors/test_ritual_tracker.py b/tests/acceptance/actors/test_ritual_tracker.py index e1582e990..1d28a94fc 100644 --- a/tests/acceptance/actors/test_ritual_tracker.py +++ b/tests/acceptance/actors/test_ritual_tracker.py @@ -10,7 +10,7 @@ from eth_typing import ChecksumAddress from web3.contract.contract import ContractEvent from web3.datastructures import AttributeDict -from nucypher.blockchain.eth.actors import Ritualist +from nucypher.blockchain.eth.actors import Operator from nucypher.blockchain.eth.agents import CoordinatorAgent from nucypher.blockchain.eth.trackers.dkg import ActiveRitualTracker @@ -26,7 +26,7 @@ def cohort(ursulas): def test_action_required_not_participating(cohort): ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) participation_state = ActiveRitualTracker.ParticipationState( participating=False, # not participating @@ -59,7 +59,7 @@ def test_action_required_not_participating(cohort): def test_action_required_only_for_events_with_corresponding_actions(cohort): ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) participation_state = ActiveRitualTracker.ParticipationState( participating=True, # participating @@ -97,7 +97,7 @@ def test_action_required_only_for_events_with_corresponding_actions(cohort): def test_action_required_depending_on_participation_state(cohort): ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) participation_state = ActiveRitualTracker.ParticipationState( participating=True, @@ -161,7 +161,7 @@ def test_get_participation_state_start_ritual(cohort, get_random_checksum_addres args_dict = {"ritualId": ritual_id} ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) # StartRitual start_ritual_event = agent.contract.events.StartRitual() @@ -220,7 +220,7 @@ def test_get_participation_state_start_aggregation_round_participation_not_alrea args_dict = {"ritualId": ritual_id} ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) start_aggregation_round_event = agent.contract.events.StartAggregationRound() @@ -286,7 +286,7 @@ def test_get_participation_state_start_aggregation_round_participation_already_t args_dict = {"ritualId": ritual_id} ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) start_aggregation_round_event = agent.contract.events.StartAggregationRound() @@ -354,7 +354,7 @@ def test_get_participation_state_end_ritual_participation_not_already_tracked( args_dict = {"ritualId": ritual_id} ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) end_ritual_event = agent.contract.events.EndRitual() @@ -486,7 +486,7 @@ def test_get_participation_state_end_ritual_participation_already_tracked( args_dict = {"ritualId": ritual_id} ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) end_ritual_event = agent.contract.events.EndRitual() @@ -539,7 +539,7 @@ def test_get_participation_state_end_ritual_participation_already_tracked( def test_get_participation_state_unexpected_event_without_ritual_id_arg(cohort): ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) # TimeoutChanged timeout_changed_event = agent.contract.events.TimeoutChanged() @@ -563,7 +563,7 @@ def test_get_participation_state_unexpected_event_without_ritual_id_arg(cohort): def test_get_participation_state_unexpected_event_with_ritual_id_arg(cohort): ursula = cohort[0] agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) # create args data - faked to include ritual id arg args_dict = {"ritualId": 0, "oldTimeout": 1, "newTimeout": 2} @@ -598,7 +598,7 @@ def test_get_participation_state_purge_expired_cache_entries( with patch.object(agent, "get_timeout", return_value=faked_ritual_timeout): # fake timeout only needed for initialization - active_ritual_tracker = ActiveRitualTracker(ritualist=ursula) + active_ritual_tracker = ActiveRitualTracker(operator=ursula) now = maya.now() @@ -727,11 +727,11 @@ def test_handle_event_multiple_concurrent_rituals(cohort, get_random_checksum_ad ursula = cohort[0] - ritualist = Mock(spec=Ritualist) - ritualist.checksum_address = ursula.checksum_address - ritualist.coordinator_agent = ursula.coordinator_agent + operator = Mock(spec=Operator) + operator.checksum_address = ursula.checksum_address + operator.coordinator_agent = ursula.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ritualist) + active_ritual_tracker = ActiveRitualTracker(operator=operator) block_number = 17692417 # random block number - value doesn't matter @@ -776,17 +776,15 @@ def test_handle_event_multiple_concurrent_rituals(cohort, get_random_checksum_ad assert len(active_ritual_tracker._participation_states) == (i + 1) participation_state = active_ritual_tracker._participation_states[r_id] if r_id != ritual_id_4: - ritualist.perform_round_1.assert_called_with( + operator.perform_round_1.assert_called_with( ritual_id=r_id, initiator=ANY, participants=ANY, timestamp=ANY ) check_participation_state(participation_state, expected_participating=True) else: check_participation_state(participation_state, expected_participating=False) - assert ( - ritualist.perform_round_1.call_count == 3 - ) # participation and action required - assert ritualist.perform_round_2.call_count == 0 # nothing to do here + assert operator.perform_round_1.call_count == 3 # participation and action required + assert operator.perform_round_2.call_count == 0 # nothing to do here assert len(active_ritual_tracker._participation_states) == 4 # @@ -806,9 +804,9 @@ def test_handle_event_multiple_concurrent_rituals(cohort, get_random_checksum_ad d = active_ritual_tracker._handle_ritual_event(event_data, get_block_when) yield d - assert ritualist.perform_round_1.call_count == 3 # same count as before - assert ritualist.perform_round_2.call_count == 1 # nothing to do here - ritualist.perform_round_2.assert_called_with(ritual_id=ritual_id_2, timestamp=ANY) + assert operator.perform_round_1.call_count == 3 # same count as before + assert operator.perform_round_2.call_count == 1 # nothing to do here + operator.perform_round_2.assert_called_with(ritual_id=ritual_id_2, timestamp=ANY) check_participation_state( active_ritual_tracker._participation_states[ritual_id_1], @@ -842,8 +840,8 @@ def test_handle_event_multiple_concurrent_rituals(cohort, get_random_checksum_ad d = active_ritual_tracker._handle_ritual_event(event_data, get_block_when) yield d - assert ritualist.perform_round_1.call_count == 3 # same as before - assert ritualist.perform_round_2.call_count == 1 # same as before + assert operator.perform_round_1.call_count == 3 # same as before + assert operator.perform_round_2.call_count == 1 # same as before check_participation_state( active_ritual_tracker._participation_states[ritual_id_1], @@ -882,8 +880,8 @@ def test_handle_event_multiple_concurrent_rituals(cohort, get_random_checksum_ad d = active_ritual_tracker._handle_ritual_event(event_data, get_block_when) yield d - assert ritualist.perform_round_1.call_count == 3 # same as before - assert ritualist.perform_round_2.call_count == 1 # same as before + assert operator.perform_round_1.call_count == 3 # same as before + assert operator.perform_round_2.call_count == 1 # same as before assert len(active_ritual_tracker._participation_states) == 4 @@ -924,8 +922,8 @@ def test_handle_event_multiple_concurrent_rituals(cohort, get_random_checksum_ad d = active_ritual_tracker._handle_ritual_event(event_data, get_block_when) yield d - assert ritualist.perform_round_1.call_count == 3 # same as before - assert ritualist.perform_round_2.call_count == 1 # same as before + assert operator.perform_round_1.call_count == 3 # same as before + assert operator.perform_round_2.call_count == 1 # same as before check_participation_state( active_ritual_tracker._participation_states[ritual_id_1], diff --git a/tests/acceptance/actors/test_ursula_operator.py b/tests/acceptance/actors/test_ursula_operator.py index 29bcd9c52..745ff748d 100644 --- a/tests/acceptance/actors/test_ursula_operator.py +++ b/tests/acceptance/actors/test_ursula_operator.py @@ -10,7 +10,7 @@ from web3.middleware.simulate_unmined_transaction import ( unmined_receipt_simulator_middleware, ) -from nucypher.blockchain.eth.actors import Operator, Ritualist +from nucypher.blockchain.eth.actors import Operator from nucypher.blockchain.eth.constants import NULL_ADDRESS from nucypher.blockchain.eth.signers.software import Web3Signer from nucypher.blockchain.eth.trackers.pre import WorkTracker, WorkTrackerBase @@ -89,7 +89,7 @@ def test_ursula_operator_confirmation_autopilot( operator2 = testerchain.ursula_account(1) min_authorization = taco_application_agent.get_min_authorization() - confirmation_spy = mocker.spy(Ritualist, "set_provider_public_key") + confirmation_spy = mocker.spy(Operator, "set_provider_public_key") # TODO: WorkerTracker may no longer be needed replacement_confirmation_spy = mocker.spy( WorkTrackerBase, "_WorkTrackerBase__fire_replacement_commitment" diff --git a/tests/acceptance/characters/test_decentralized_grant.py b/tests/acceptance/characters/test_decentralized_grant.py index 7588d1124..9c0a19ec3 100644 --- a/tests/acceptance/characters/test_decentralized_grant.py +++ b/tests/acceptance/characters/test_decentralized_grant.py @@ -1,6 +1,7 @@ import datetime -import maya import os + +import maya from nucypher_core import EncryptedKeyFrag from nucypher.config.constants import TEMPORARY_DOMAIN @@ -28,8 +29,10 @@ def check(policy, bob, ursulas): def test_grant_subscription_manager(alice, bob, ursulas, test_registry_source_manager): - payment_method = SubscriptionManagerPayment(eth_provider=TEST_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN) - alice.payment_method = payment_method + pre_payment_method = SubscriptionManagerPayment( + eth_provider=TEST_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN + ) + alice.pre_payment_method = pre_payment_method policy = alice.grant( bob=bob, label=os.urandom(16), diff --git a/tests/acceptance/cli/test_ursula_init.py b/tests/acceptance/cli/test_ursula_init.py index 93ad43840..9b0f4da72 100644 --- a/tests/acceptance/cli/test_ursula_init.py +++ b/tests/acceptance/cli/test_ursula_init.py @@ -126,7 +126,7 @@ def test_ursula_and_local_keystore_signer_integration( "init", "--network", TEMPORARY_DOMAIN, - "--payment-network", + "--pre-payment-network", TEMPORARY_DOMAIN, "--operator-address", worker_account.address, @@ -134,7 +134,7 @@ def test_ursula_and_local_keystore_signer_integration( str(config_root_path.absolute()), "--eth-provider", TEST_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", TEST_POLYGON_PROVIDER_URI, "--rest-host", MOCK_IP_ADDRESS, diff --git a/tests/acceptance/cli/test_ursula_run.py b/tests/acceptance/cli/test_ursula_run.py index b08bdb36e..fabb2b852 100644 --- a/tests/acceptance/cli/test_ursula_run.py +++ b/tests/acceptance/cli/test_ursula_run.py @@ -1,8 +1,8 @@ +import time from unittest import mock import pytest import pytest_twisted as pt -import time from twisted.internet import threads from nucypher.blockchain.eth.actors import Operator @@ -37,45 +37,60 @@ def test_missing_configuration_file(_default_filepath_mock, click_runner): @pt.inlineCallbacks def test_ursula_run_with_prometheus_but_no_metrics_port(click_runner): - args = ('ursula', 'run', # Stat Ursula Command - '--debug', # Display log output; Do not attach console - '--dev', # Run in development mode (local ephemeral node) - '--dry-run', # Disable twisted reactor in subprocess - '--lonely', # Do not load seednodes - '--prometheus', # Specify collection of prometheus metrics - '--eth-provider', TEST_ETH_PROVIDER_URI, - '--payment-provider', TEST_POLYGON_PROVIDER_URI - ) + args = ( + "ursula", + "run", # Stat Ursula Command + "--debug", # Display log output; Do not attach console + "--dev", # Run in development mode (local ephemeral node) + "--dry-run", # Disable twisted reactor in subprocess + "--lonely", # Do not load seednodes + "--prometheus", # Specify collection of prometheus metrics + "--eth-provider", + TEST_ETH_PROVIDER_URI, + "--pre-payment-provider", + TEST_POLYGON_PROVIDER_URI, + ) - result = yield threads.deferToThread(click_runner.invoke, - nucypher_cli, args, - catch_exceptions=False) + result = yield threads.deferToThread( + click_runner.invoke, nucypher_cli, args, catch_exceptions=False + ) assert result.exit_code != 0 - expected_error = f"Error: --metrics-port is required when using --prometheus" + expected_error = "Error: --metrics-port is required when using --prometheus" assert expected_error in result.output @pt.inlineCallbacks -def test_run_lone_default_development_ursula(click_runner, test_registry_source_manager, testerchain, mock_funding_and_bonding): - +def test_run_lone_default_development_ursula( + click_runner, test_registry_source_manager, testerchain, mock_funding_and_bonding +): deploy_port = select_test_port() - args = ('ursula', 'run', # Stat Ursula Command - '--debug', # Display log output; Do not attach console - '--rest-port', deploy_port, # Network Port - '--dev', # Run in development mode (ephemeral node) - '--dry-run', # Disable twisted reactor in subprocess - '--lonely', # Do not load seednodes, - '--operator-address', testerchain.etherbase_account, - '--eth-provider', TEST_ETH_PROVIDER_URI, - '--payment-provider', TEST_ETH_PROVIDER_URI, - '--payment-network', TEMPORARY_DOMAIN, - ) + args = ( + "ursula", + "run", # Stat Ursula Command + "--debug", # Display log output; Do not attach console + "--rest-port", + deploy_port, # Network Port + "--dev", # Run in development mode (ephemeral node) + "--dry-run", # Disable twisted reactor in subprocess + "--lonely", # Do not load seednodes, + "--operator-address", + testerchain.etherbase_account, + "--eth-provider", + TEST_ETH_PROVIDER_URI, + "--pre-payment-provider", + TEST_ETH_PROVIDER_URI, + "--pre-payment-network", + TEMPORARY_DOMAIN, + ) - result = yield threads.deferToThread(click_runner.invoke, - nucypher_cli, args, - catch_exceptions=False, - input=INSECURE_DEVELOPMENT_PASSWORD + '\n') + result = yield threads.deferToThread( + click_runner.invoke, + nucypher_cli, + args, + catch_exceptions=False, + input=INSECURE_DEVELOPMENT_PASSWORD + "\n", + ) time.sleep(Learner._SHORT_LEARNING_DELAY) assert result.exit_code == 0, result.output @@ -102,23 +117,34 @@ def test_ursula_learns_via_cli( deploy_port = select_test_port() def run_ursula(): - i = start_pytest_ursula_services(ursula=teacher) - args = ('ursula', 'run', - '--debug', # Display log output; Do not attach console - '--rest-port', deploy_port, # Network Port - '--teacher', teacher_uri, - '--dev', # Run in development mode (ephemeral node) - '--dry-run', # Disable twisted reactor - '--operator-address', testerchain.etherbase_account, - '--eth-provider', TEST_ETH_PROVIDER_URI, - '--payment-provider', TEST_ETH_PROVIDER_URI, - '--payment-network', TEMPORARY_DOMAIN - ) + start_pytest_ursula_services(ursula=teacher) + args = ( + "ursula", + "run", + "--debug", # Display log output; Do not attach console + "--rest-port", + deploy_port, # Network Port + "--teacher", + teacher_uri, + "--dev", # Run in development mode (ephemeral node) + "--dry-run", # Disable twisted reactor + "--operator-address", + testerchain.etherbase_account, + "--eth-provider", + TEST_ETH_PROVIDER_URI, + "--pre-payment-provider", + TEST_ETH_PROVIDER_URI, + "--pre-payment-network", + TEMPORARY_DOMAIN, + ) - return threads.deferToThread(click_runner.invoke, - nucypher_cli, args, - catch_exceptions=False, - input=INSECURE_DEVELOPMENT_PASSWORD + '\n') + return threads.deferToThread( + click_runner.invoke, + nucypher_cli, + args, + catch_exceptions=False, + input=INSECURE_DEVELOPMENT_PASSWORD + "\n", + ) # Run the Callbacks d = run_ursula() @@ -142,25 +168,42 @@ def test_ursula_learns_via_cli( def test_persistent_node_storage_integration( click_runner, custom_filepath, testerchain, ursulas, agency_local_registry, mocker ): - - mocker.patch.object(ActiveRitualTracker, 'start') - alice, ursula, another_ursula, staking_provider, *all_yall = testerchain.unassigned_accounts + mocker.patch.object(ActiveRitualTracker, "start") + ( + alice, + ursula, + another_ursula, + staking_provider, + *all_yall, + ) = testerchain.unassigned_accounts filename = UrsulaConfiguration.generate_filename() another_ursula_configuration_file_location = custom_filepath / filename - init_args = ('ursula', 'init', - '--eth-provider', TEST_ETH_PROVIDER_URI, - '--payment-provider', TEST_POLYGON_PROVIDER_URI, - '--operator-address', another_ursula, - '--network', TEMPORARY_DOMAIN, - '--payment-network', TEMPORARY_DOMAIN, - '--rest-host', MOCK_IP_ADDRESS, - '--config-root', str(custom_filepath.absolute()), - '--registry-filepath', str(agency_local_registry.filepath.absolute()), - ) + init_args = ( + "ursula", + "init", + "--eth-provider", + TEST_ETH_PROVIDER_URI, + "--pre-payment-provider", + TEST_POLYGON_PROVIDER_URI, + "--operator-address", + another_ursula, + "--network", + TEMPORARY_DOMAIN, + "--pre-payment-network", + TEMPORARY_DOMAIN, + "--rest-host", + MOCK_IP_ADDRESS, + "--config-root", + str(custom_filepath.absolute()), + "--registry-filepath", + str(agency_local_registry.filepath.absolute()), + ) envvars = {NUCYPHER_ENVVAR_KEYSTORE_PASSWORD: INSECURE_DEVELOPMENT_PASSWORD} - result = click_runner.invoke(nucypher_cli, init_args, catch_exceptions=False, env=envvars) + result = click_runner.invoke( + nucypher_cli, init_args, catch_exceptions=False, env=envvars + ) assert result.exit_code == 0 teacher = ursulas[-1] diff --git a/tests/acceptance/conftest.py b/tests/acceptance/conftest.py index 5d2b4c55f..713564fc8 100644 --- a/tests/acceptance/conftest.py +++ b/tests/acceptance/conftest.py @@ -3,7 +3,7 @@ import random import pytest from web3 import Web3 -from nucypher.blockchain.eth.actors import Ritualist +from nucypher.blockchain.eth.actors import Operator from nucypher.blockchain.eth.agents import ( ContractAgency, CoordinatorAgent, @@ -480,5 +480,5 @@ def mock_condition_blockchains(session_mocker): @pytest.fixture(scope="module", autouse=True) def mock_multichain_configuration(module_mocker, testerchain): module_mocker.patch.object( - Ritualist, "_make_condition_provider", return_value=testerchain.provider + Operator, "_make_condition_provider", return_value=testerchain.provider ) diff --git a/tests/conftest.py b/tests/conftest.py index e6879311f..a15186636 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ from collections import defaultdict import pytest from eth_utils.crypto import keccak -from nucypher.blockchain.eth.actors import Ritualist +from nucypher.blockchain.eth.actors import Operator from nucypher.blockchain.eth.networks import NetworksInventory from nucypher.crypto.powers import TransactingPower from nucypher.network.nodes import Learner @@ -92,7 +92,6 @@ def check_character_state_after_test(request): from nucypher.network.nodes import Learner yield if Learner._DEBUG_MODE: - gmwe = global_mutable_where_everybody module_name = request.module.__name__ test_learners = global_mutable_where_everybody.get(module_name, []) @@ -159,5 +158,5 @@ def mock_condition_blockchains(session_mocker): @pytest.fixture(scope="module", autouse=True) def mock_multichain_configuration(module_mocker, testerchain): module_mocker.patch.object( - Ritualist, "_make_condition_provider", return_value=testerchain.provider + Operator, "_make_condition_provider", return_value=testerchain.provider ) diff --git a/tests/fixtures.py b/tests/fixtures.py index 4b191ce80..bcb788afa 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -133,7 +133,7 @@ def random_address(random_account): def ursula_test_config(test_registry, temp_dir_path, testerchain): config = make_ursula_test_configuration( eth_provider_uri=TEST_ETH_PROVIDER_URI, - payment_provider=TEST_ETH_PROVIDER_URI, + pre_payment_provider=TEST_ETH_PROVIDER_URI, test_registry=test_registry, rest_port=select_test_port(), operator_address=testerchain.ursulas_accounts.pop(), @@ -148,7 +148,7 @@ def ursula_test_config(test_registry, temp_dir_path, testerchain): def alice_test_config(ursulas, testerchain, test_registry): config = make_alice_test_configuration( eth_provider_uri=TEST_ETH_PROVIDER_URI, - payment_provider=TEST_ETH_PROVIDER_URI, + pre_payment_provider=TEST_ETH_PROVIDER_URI, known_nodes=ursulas, checksum_address=testerchain.alice_account, test_registry=test_registry, @@ -177,7 +177,7 @@ def idle_policy(testerchain, alice, bob, application_economics): random_label = generate_random_label() expiration = maya.now() + timedelta(days=1) threshold, shares = 3, 5 - price = alice.payment_method.quote( + price = alice.pre_payment_method.quote( expiration=expiration.epoch, shares=shares ).value # TODO: use default quote option policy = alice.create_policy( @@ -339,7 +339,7 @@ def light_ursula(temp_dir_path, test_registry_source_manager, random_account, mo mocker.patch.object( KeystoreSigner, "_KeystoreSigner__get_signer", return_value=random_account ) - payment_method = SubscriptionManagerPayment( + pre_payment_method = SubscriptionManagerPayment( eth_provider=MOCK_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN ) @@ -351,7 +351,7 @@ def light_ursula(temp_dir_path, test_registry_source_manager, random_account, mo rest_host=LOOPBACK_ADDRESS, rest_port=select_test_port(), domain=TEMPORARY_DOMAIN, - payment_method=payment_method, + pre_payment_method=pre_payment_method, checksum_address=random_account.address, operator_address=random_account.address, eth_provider_uri=MOCK_ETH_PROVIDER_URI, @@ -447,8 +447,15 @@ def fleet_of_highperf_mocked_ursulas( @pytest.fixture(scope="module") -def highperf_mocked_alice(fleet_of_highperf_mocked_ursulas, test_registry_source_manager, monkeymodule, testerchain): - monkeymodule.setattr(CharacterConfiguration, 'DEFAULT_PAYMENT_NETWORK', TEMPORARY_DOMAIN) +def highperf_mocked_alice( + fleet_of_highperf_mocked_ursulas, + test_registry_source_manager, + monkeymodule, + testerchain, +): + monkeymodule.setattr( + CharacterConfiguration, "DEFAULT_PRE_PAYMENT_NETWORK", TEMPORARY_DOMAIN + ) config = AliceConfiguration( dev_mode=True, @@ -522,7 +529,7 @@ def click_runner(): def nominal_configuration_fields(test_registry_source_manager): config = UrsulaConfiguration( dev_mode=True, - payment_network=TEMPORARY_DOMAIN, + pre_payment_network=TEMPORARY_DOMAIN, domain=TEMPORARY_DOMAIN, eth_provider_uri=TEST_ETH_PROVIDER_URI, ) diff --git a/tests/integration/blockchain/test_ritual_tracker.py b/tests/integration/blockchain/test_ritual_tracker.py index 66120bfbd..7a77ec3e7 100644 --- a/tests/integration/blockchain/test_ritual_tracker.py +++ b/tests/integration/blockchain/test_ritual_tracker.py @@ -5,7 +5,7 @@ from unittest.mock import Mock import maya import pytest -from nucypher.blockchain.eth.actors import Ritualist +from nucypher.blockchain.eth.actors import Operator from nucypher.blockchain.eth.agents import CoordinatorAgent from nucypher.blockchain.eth.trackers.dkg import ActiveRitualTracker @@ -17,7 +17,7 @@ class BlockInfo(NamedTuple): @pytest.fixture(scope="function") -def ritualist(ursulas, mock_coordinator_agent) -> Ritualist: +def ritualist(ursulas, mock_coordinator_agent) -> Operator: ursula = ursulas[0] mocked_agent = Mock(spec=CoordinatorAgent) mocked_agent.contract = mock_coordinator_agent.contract @@ -33,7 +33,7 @@ def ritualist(ursulas, mock_coordinator_agent) -> Ritualist: def test_first_scan_start_block_number_simple(ritualist): mocked_agent = ritualist.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ritualist) + active_ritual_tracker = ActiveRitualTracker(operator=ritualist) now = maya.now() # latest block is 0 - return it @@ -64,7 +64,7 @@ def test_first_scan_start_block_number_simple(ritualist): def test_first_scan_start_block_calc_is_perfect(ritualist): mocked_agent = ritualist.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ritualist) + active_ritual_tracker = ActiveRitualTracker(operator=ritualist) now = maya.now() # @@ -130,7 +130,7 @@ def test_first_scan_start_block_calc_is_perfect(ritualist): def test_first_scan_start_block_calc_is_not_perfect_go_back_more_blocks(ritualist): mocked_agent = ritualist.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ritualist) + active_ritual_tracker = ActiveRitualTracker(operator=ritualist) now = maya.now() # @@ -244,7 +244,7 @@ def test_first_scan_start_block_calc_is_not_perfect_go_back_more_blocks(ritualis def test_get_ritual_participant_info(ritualist, get_random_checksum_address): mocked_agent = ritualist.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ritualist) + active_ritual_tracker = ActiveRitualTracker(operator=ritualist) participants = [] # random participants @@ -255,17 +255,17 @@ def test_get_ritual_participant_info(ritualist, get_random_checksum_address): participants.append(participant) mocked_agent.get_participants.return_value = participants - # ritualist not in participants list + # operator not in participants list participant_info = active_ritual_tracker._get_ritual_participant_info(ritual_id=0) assert participant_info is None - # add ritualist to participants list + # add operator to participants list participant = CoordinatorAgent.Ritual.Participant( provider=ritualist.checksum_address ) participants.append(participant) - # ritualist in participants list + # operator in participants list participant_info = active_ritual_tracker._get_ritual_participant_info(ritual_id=0) assert participant_info assert participant_info.provider == ritualist.checksum_address @@ -275,7 +275,7 @@ def test_get_participation_state_values_from_contract( ritualist, get_random_checksum_address ): mocked_agent = ritualist.coordinator_agent - active_ritual_tracker = ActiveRitualTracker(ritualist=ritualist) + active_ritual_tracker = ActiveRitualTracker(operator=ritualist) participants = [] # random participants @@ -297,7 +297,7 @@ def test_get_participation_state_values_from_contract( assert not posted_transcript assert not posted_aggregate - # add ritualist to participants list + # add operator to participants list ritual_participant = CoordinatorAgent.Ritual.Participant( provider=ritualist.checksum_address ) diff --git a/tests/integration/cli/test_cli_config.py b/tests/integration/cli/test_cli_config.py index 3e670a869..528088f0a 100644 --- a/tests/integration/cli/test_cli_config.py +++ b/tests/integration/cli/test_cli_config.py @@ -44,7 +44,7 @@ def test_initialize_via_cli( TEMPORARY_DOMAIN, "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", TEST_ETH_PROVIDER_URI, "--config-root", str(custom_filepath.absolute()), @@ -77,8 +77,13 @@ def test_reconfigure_via_cli(click_runner, custom_filepath: Path, config_class, def fake_get_latest_registry(*args, **kwargs): return test_registry - monkeypatch.setattr(InMemoryContractRegistry, 'from_latest_publication', fake_get_latest_registry) - monkeypatch.setattr(CharacterConfiguration, 'DEFAULT_PAYMENT_NETWORK', TEMPORARY_DOMAIN) + + monkeypatch.setattr( + InMemoryContractRegistry, "from_latest_publication", fake_get_latest_registry + ) + monkeypatch.setattr( + CharacterConfiguration, "DEFAULT_PRE_PAYMENT_NETWORK", TEMPORARY_DOMAIN + ) custom_config_filepath = custom_filepath / config_class.generate_filename() diff --git a/tests/integration/cli/test_mixed_config.py b/tests/integration/cli/test_mixed_config.py index 1c3198bae..017ad74a5 100644 --- a/tests/integration/cli/test_mixed_config.py +++ b/tests/integration/cli/test_mixed_config.py @@ -66,13 +66,13 @@ def test_corrupted_configuration(click_runner, "init", "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", TEST_POLYGON_PROVIDER_URI, "--operator-address", another_ursula, "--network", TEMPORARY_DOMAIN, - "--payment-network", + "--pre-payment-network", TEMPORARY_DOMAIN, "--rest-host", MOCK_IP_ADDRESS, @@ -105,11 +105,11 @@ def test_corrupted_configuration(click_runner, "init", "--network", TEMPORARY_DOMAIN, - "--payment-network", + "--pre-payment-network", TEMPORARY_DOMAIN, "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", TEST_POLYGON_PROVIDER_URI, "--operator-address", another_ursula, diff --git a/tests/integration/cli/test_ursula_cli_ip_detection.py b/tests/integration/cli/test_ursula_cli_ip_detection.py index 6cd747391..5bffe0c16 100644 --- a/tests/integration/cli/test_ursula_cli_ip_detection.py +++ b/tests/integration/cli/test_ursula_cli_ip_detection.py @@ -35,7 +35,7 @@ def test_ursula_startup_ip_checkup(click_runner, mocker, test_registry_source_ma TEMPORARY_DOMAIN, "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", TEST_POLYGON_PROVIDER_URI, "--force", ) @@ -54,7 +54,7 @@ def test_ursula_startup_ip_checkup(click_runner, mocker, test_registry_source_ma "--force", "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", TEST_POLYGON_PROVIDER_URI, ) result = click_runner.invoke( @@ -72,7 +72,7 @@ def test_ursula_startup_ip_checkup(click_runner, mocker, test_registry_source_ma "--force", "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", TEST_POLYGON_PROVIDER_URI, ) result = click_runner.invoke( diff --git a/tests/integration/cli/test_ursula_config_cli.py b/tests/integration/cli/test_ursula_config_cli.py index 28623a9f8..326cb5f08 100644 --- a/tests/integration/cli/test_ursula_config_cli.py +++ b/tests/integration/cli/test_ursula_config_cli.py @@ -5,15 +5,13 @@ from unittest.mock import PropertyMock import pytest -import nucypher -from nucypher.blockchain.eth.actors import Ritualist from nucypher.blockchain.eth.trackers.dkg import ActiveRitualTracker from nucypher.cli.literature import ( COLLECT_NUCYPHER_PASSWORD, CONFIRM_IPV4_ADDRESS_QUESTION, REPEAT_FOR_CONFIRMATION, SELECT_OPERATOR_ACCOUNT, - SELECT_PAYMENT_NETWORK, + SELECT_PRE_PAYMENT_NETWORK, SUCCESSFUL_DESTRUCTION, ) from nucypher.cli.main import nucypher_cli @@ -33,7 +31,6 @@ from tests.constants import ( MOCK_ETH_PROVIDER_URI, MOCK_IP_ADDRESS, YES_ENTER, - TESTERCHAIN_CHAIN_ID, ) from tests.utils.ursula import select_test_port @@ -64,7 +61,7 @@ def test_interactive_initialize_ursula(click_runner, mocker, tmpdir, test_regist TEMPORARY_DOMAIN, "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", MOCK_ETH_PROVIDER_URI, ) @@ -73,7 +70,7 @@ def test_interactive_initialize_ursula(click_runner, mocker, tmpdir, test_regist assert result.exit_code == 0, result.output # Select network - assert SELECT_PAYMENT_NETWORK in result.output + assert SELECT_PRE_PAYMENT_NETWORK in result.output # Select account assert SELECT_OPERATOR_ACCOUNT in result.output @@ -103,9 +100,9 @@ def test_initialize_custom_configuration_root(click_runner, custom_filepath: Pat deploy_port, "--eth-provider", MOCK_ETH_PROVIDER_URI, - "--payment-provider", + "--pre-payment-provider", MOCK_ETH_PROVIDER_URI, - "--payment-network", + "--pre-payment-network", TEMPORARY_DOMAIN, "--operator-address", testerchain.ursulas_accounts[0], @@ -217,11 +214,19 @@ def test_ursula_destroy_configuration(custom_filepath, click_runner): assert custom_config_filepath.is_file(), 'Configuration file does not exist' # Run the destroy command - destruction_args = ('ursula', 'destroy', '--config-file', str(custom_config_filepath.absolute())) - result = click_runner.invoke(nucypher_cli, destruction_args, - input='Y\n'.format(INSECURE_DEVELOPMENT_PASSWORD), - catch_exceptions=False, - env={NUCYPHER_ENVVAR_KEYSTORE_PASSWORD: INSECURE_DEVELOPMENT_PASSWORD}) + destruction_args = ( + "ursula", + "destroy", + "--config-file", + str(custom_config_filepath.absolute()), + ) + result = click_runner.invoke( + nucypher_cli, + destruction_args, + input="Y\n".format(), + catch_exceptions=False, + env={NUCYPHER_ENVVAR_KEYSTORE_PASSWORD: INSECURE_DEVELOPMENT_PASSWORD}, + ) # CLI Output assert not custom_config_filepath.is_file(), 'Configuration file still exists' 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 230e9a52f..550dab206 100644 --- a/tests/integration/cli/test_ursula_local_keystore_cli_functionality.py +++ b/tests/integration/cli/test_ursula_local_keystore_cli_functionality.py @@ -53,9 +53,9 @@ def test_ursula_init_with_local_keystore_signer( "--eth-provider", testerchain.eth_provider_uri, # Layer 2 - "--payment-network", + "--pre-payment-network", TEMPORARY_DOMAIN, - "--payment-provider", + "--pre-payment-provider", testerchain.eth_provider_uri, "--rest-host", MOCK_IP_ADDRESS, diff --git a/tests/integration/config/test_character_configuration.py b/tests/integration/config/test_character_configuration.py index b6bd9c69d..8bfd3df16 100644 --- a/tests/integration/config/test_character_configuration.py +++ b/tests/integration/config/test_character_configuration.py @@ -43,7 +43,7 @@ def test_development_character_configurations( character, configuration, test_registry_source_manager, mocker, testerchain ): mocker.patch.object( - CharacterConfiguration, "DEFAULT_PAYMENT_NETWORK", TEMPORARY_DOMAIN + CharacterConfiguration, "DEFAULT_PRE_PAYMENT_NETWORK", TEMPORARY_DOMAIN ) params = dict( dev_mode=True, @@ -127,9 +127,9 @@ def test_default_character_configuration_preservation( eth_provider_uri=MOCK_ETH_PROVIDER_URI, domain=network, rest_host=MOCK_IP_ADDRESS, - payment_provider=MOCK_ETH_PROVIDER_URI, + pre_payment_provider=MOCK_ETH_PROVIDER_URI, policy_registry=test_registry, - payment_network=TEMPORARY_DOMAIN, + pre_payment_network=TEMPORARY_DOMAIN, keystore=keystore, ) @@ -138,7 +138,7 @@ def test_default_character_configuration_preservation( checksum_address=fake_address, eth_provider_uri=MOCK_ETH_PROVIDER_URI, domain=network, - payment_network=TEMPORARY_DOMAIN, + pre_payment_network=TEMPORARY_DOMAIN, policy_registry=test_registry, ) @@ -176,7 +176,7 @@ def test_ursula_development_configuration(test_registry_source_manager, testerch checksum_address=testerchain.unassigned_accounts[0], operator_address=testerchain.unassigned_accounts[1], domain=TEMPORARY_DOMAIN, - payment_network=TEMPORARY_DOMAIN, + pre_payment_network=TEMPORARY_DOMAIN, eth_provider_uri=MOCK_ETH_PROVIDER_URI, ) assert config.is_me is True diff --git a/tests/integration/config/test_configuration_persistence.py b/tests/integration/config/test_configuration_persistence.py index 662488422..0328e40d7 100644 --- a/tests/integration/config/test_configuration_persistence.py +++ b/tests/integration/config/test_configuration_persistence.py @@ -1,5 +1,3 @@ - - import datetime import maya @@ -22,7 +20,7 @@ def test_alices_powers_are_persistent( config_root=config_root, network_middleware=MockRestMiddleware(eth_provider_uri=MOCK_ETH_PROVIDER_URI), domain=TEMPORARY_DOMAIN, - payment_network=TEMPORARY_DOMAIN, + pre_payment_network=TEMPORARY_DOMAIN, checksum_address=testerchain.alice_account, start_learning_now=False, save_metadata=False, diff --git a/tests/integration/config/test_keystore_integration.py b/tests/integration/config/test_keystore_integration.py index 7c993466a..97a6bca7f 100644 --- a/tests/integration/config/test_keystore_integration.py +++ b/tests/integration/config/test_keystore_integration.py @@ -74,7 +74,7 @@ def test_characters_use_keystore( ) keystore.unlock(password=INSECURE_DEVELOPMENT_PASSWORD) - payment_method = SubscriptionManagerPayment( + pre_payment_method = SubscriptionManagerPayment( eth_provider=MOCK_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN ) @@ -84,7 +84,7 @@ def test_characters_use_keystore( domain=TEMPORARY_DOMAIN, eth_provider_uri=MOCK_ETH_PROVIDER_URI, checksum_address=testerchain.alice_account, - payment_method=payment_method, + pre_payment_method=pre_payment_method, ) Bob( eth_provider_uri=MOCK_ETH_PROVIDER_URI, @@ -99,7 +99,7 @@ def test_characters_use_keystore( rest_host=LOOPBACK_ADDRESS, rest_port=12345, domain=TEMPORARY_DOMAIN, - payment_method=payment_method, + pre_payment_method=pre_payment_method, operator_address=testerchain.ursulas_accounts[0], signer=Web3Signer(testerchain.client), ) @@ -158,7 +158,7 @@ def test_ritualist(temp_dir_path, testerchain, dkg_public_key): ) keystore.unlock(password=INSECURE_DEVELOPMENT_PASSWORD) - payment_method = SubscriptionManagerPayment( + pre_payment_method = SubscriptionManagerPayment( eth_provider=MOCK_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN ) @@ -168,7 +168,7 @@ def test_ritualist(temp_dir_path, testerchain, dkg_public_key): rest_host=LOOPBACK_ADDRESS, rest_port=12345, domain=TEMPORARY_DOMAIN, - payment_method=payment_method, + pre_payment_method=pre_payment_method, operator_address=testerchain.ursulas_accounts[0], signer=Web3Signer(testerchain.client), eth_provider_uri=MOCK_ETH_PROVIDER_URI, diff --git a/tests/integration/config/test_storages.py b/tests/integration/config/test_storages.py index f94849aed..11adc9653 100644 --- a/tests/integration/config/test_storages.py +++ b/tests/integration/config/test_storages.py @@ -6,7 +6,7 @@ from nucypher.config.constants import TEMPORARY_DOMAIN from nucypher.config.storages import ForgetfulNodeStorage, TemporaryFileBasedNodeStorage from nucypher.policy.payment import SubscriptionManagerPayment from nucypher.utilities.networking import LOOPBACK_ADDRESS -from tests.constants import MOCK_ETH_PROVIDER_URI, MOCK_IP_ADDRESS +from tests.constants import MOCK_ETH_PROVIDER_URI from tests.utils.ursula import select_test_port ADDITIONAL_NODES_TO_LEARN_ABOUT = 10 @@ -34,19 +34,23 @@ class BaseTestNodeStorageBackends: node_from_storage = node_storage.get(stamp=ursula.stamp) assert ursula == node_from_storage, "Node storage {} failed".format(node_storage) - payment_method = SubscriptionManagerPayment(eth_provider=MOCK_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN) + pre_payment_method = SubscriptionManagerPayment( + eth_provider=MOCK_ETH_PROVIDER_URI, network=TEMPORARY_DOMAIN + ) # Save more nodes all_known_nodes = set() for i in range(ADDITIONAL_NODES_TO_LEARN_ABOUT): - node = Ursula(rest_host=LOOPBACK_ADDRESS, - rest_port=select_test_port(), - domain=TEMPORARY_DOMAIN, - signer=signer, - eth_provider_uri=MOCK_ETH_PROVIDER_URI, - checksum_address=operator_addresses[i], - operator_address=operator_addresses[i], - payment_method=payment_method) + node = Ursula( + rest_host=LOOPBACK_ADDRESS, + rest_port=select_test_port(), + domain=TEMPORARY_DOMAIN, + signer=signer, + eth_provider_uri=MOCK_ETH_PROVIDER_URI, + checksum_address=operator_addresses[i], + operator_address=operator_addresses[i], + pre_payment_method=pre_payment_method, + ) node_storage.store_node_metadata(node=node) all_known_nodes.add(node) diff --git a/tests/metrics/grant_availability.py b/tests/metrics/grant_availability.py index d9e50d393..27bc32b65 100755 --- a/tests/metrics/grant_availability.py +++ b/tests/metrics/grant_availability.py @@ -72,7 +72,8 @@ SAMPLE_RATE: int = 15 # seconds GAS_STRATEGY: str = 'fast' MAX_GAS_PRICE: int = 200 # gwei LABEL_PREFIX = 'random-metrics-label-' -LABEL_SUFFIXER = lambda: os.urandom(16).hex() +def LABEL_SUFFIXER(): + return os.urandom(16).hex() HANDPICKED_URSULA_URIS: List[str] = [ # DEFAULT_SEEDNODE_URIS[0], # uncomment to use the seednode for granting ] @@ -151,8 +152,8 @@ def collect(alice: Alice, def make_alice(known_nodes: Optional[Set[Ursula]] = None): """Initializes a new 'persistent alice configuration' for grant metrics collection.""" - # This is Alice's payment method. - payment_method = SubscriptionManagerPayment( + # This is Alice's PRE payment method. + pre_payment_method = SubscriptionManagerPayment( network='polygon', eth_provider=POLYGON_PROVIDER_URI ) @@ -175,7 +176,7 @@ def make_alice(known_nodes: Optional[Set[Ursula]] = None): alice_config.initialize(password=INSECURE_PASSWORD) alice_config.keystore.unlock(password=INSECURE_PASSWORD) - alice = alice_config.produce(payment_method=payment_method, signer=wallet) + alice = alice_config.produce(pre_payment_method=pre_payment_method, signer=wallet) alice.start_learning_loop(now=True) return alice diff --git a/tests/unit/test_character_sign_and_verify.py b/tests/unit/test_character_sign_and_verify.py index 13f74e04e..ff5fb3c99 100644 --- a/tests/unit/test_character_sign_and_verify.py +++ b/tests/unit/test_character_sign_and_verify.py @@ -72,7 +72,7 @@ def test_anybody_can_verify(random_address): start_learning_now=False, domain=TEMPORARY_DOMAIN, checksum_address=random_address, - payment_method=FreeReencryptions(), + pre_payment_method=FreeReencryptions(), eth_provider_uri=MOCK_ETH_PROVIDER_URI, ) diff --git a/tests/utils/config.py b/tests/utils/config.py index 7800436e1..182bb1337 100644 --- a/tests/utils/config.py +++ b/tests/utils/config.py @@ -10,7 +10,6 @@ from nucypher.config.characters import ( UrsulaConfiguration, ) from nucypher.config.constants import TEMPORARY_DOMAIN -from tests.constants import MOCK_IP_ADDRESS from tests.utils.middleware import MockRestMiddleware from tests.utils.ursula import select_test_port @@ -47,28 +46,31 @@ def assemble(checksum_address: str = None, def make_ursula_test_configuration( operator_address: ChecksumAddress, rest_port: int = select_test_port(), - payment_provider: str = None, + pre_payment_provider: str = None, **assemble_kwargs ) -> UrsulaConfiguration: test_params = assemble(**assemble_kwargs) ursula_config = UrsulaConfiguration( **test_params, rest_port=rest_port, - payment_provider=payment_provider, - payment_network=TEMPORARY_DOMAIN, + pre_payment_provider=pre_payment_provider, + pre_payment_network=TEMPORARY_DOMAIN, operator_address=operator_address, policy_registry=test_params["registry"] ) return ursula_config -def make_alice_test_configuration(payment_provider: str = None, - **assemble_kwargs) -> AliceConfiguration: +def make_alice_test_configuration( + pre_payment_provider: str = None, **assemble_kwargs +) -> AliceConfiguration: test_params = assemble(**assemble_kwargs) - config = AliceConfiguration(**test_params, - payment_provider=payment_provider, - payment_network=TEMPORARY_DOMAIN, - policy_registry=test_params['registry']) + config = AliceConfiguration( + **test_params, + pre_payment_provider=pre_payment_provider, + pre_payment_network=TEMPORARY_DOMAIN, + policy_registry=test_params["registry"] + ) return config