diff --git a/nucypher/blockchain/eth/providers.py b/nucypher/blockchain/eth/providers.py
index 67ddaae07..5611dea3e 100644
--- a/nucypher/blockchain/eth/providers.py
+++ b/nucypher/blockchain/eth/providers.py
@@ -24,6 +24,7 @@ from web3.exceptions import InfuraKeyNotFound
from web3.providers.eth_tester.main import EthereumTesterProvider
from nucypher.blockchain.eth.clients import NuCypherGethDevProcess
+from nucypher.exceptions import DevelopmentInstallationRequired
class ProviderError(Exception):
@@ -90,10 +91,10 @@ def _get_auto_provider(provider_uri):
def _get_pyevm_test_backend() -> PyEVMBackend:
try:
+ # TODO: Consider packaged support of --dev mode with testerchain
from tests.constants import PYEVM_GAS_LIMIT, NUMBER_OF_ETH_TEST_ACCOUNTS
except ImportError:
- raise ImportError("Nucypher is not installed in development mode. "
- "Please checkout the code locally and reinstall to use the test client.")
+ raise DevelopmentInstallationRequired(importable_name='tests.constants')
# Initialize
genesis_params = PyEVMBackend._generate_genesis_params(overrides={'gas_limit': PYEVM_GAS_LIMIT})
diff --git a/nucypher/characters/control/controllers.py b/nucypher/characters/control/controllers.py
index 36ae1ea7b..6400b9ff2 100644
--- a/nucypher/characters/control/controllers.py
+++ b/nucypher/characters/control/controllers.py
@@ -14,6 +14,7 @@ from nucypher.characters.control.interfaces import CharacterPublicInterface
from nucypher.characters.control.specifications.exceptions import SpecificationError
from nucypher.cli.processes import JSONRPCLineReceiver
from nucypher.config.constants import MAX_UPLOAD_CONTENT_LENGTH
+from nucypher.exceptions import DevelopmentInstallationRequired
class CharacterControllerBase(ABC):
@@ -139,8 +140,8 @@ class JSONRPCController(CharacterControlServer):
try:
from tests.utils.controllers import JSONRPCTestClient
except ImportError:
- raise ImportError("Nucypher is not installed in development mode, "
- "Please checkout the code locally and reinstall to use the test client.")
+ raise DevelopmentInstallationRequired(importable_name='tests.utils.controllers.JSONRPCTestClient')
+
test_client = JSONRPCTestClient(rpc_controller=self)
return test_client
diff --git a/nucypher/characters/unlawful.py b/nucypher/characters/unlawful.py
index 76a7854f7..6bcb9fc5a 100644
--- a/nucypher/characters/unlawful.py
+++ b/nucypher/characters/unlawful.py
@@ -16,6 +16,8 @@ along with nucypher. If not, see .
"""
+from nucypher.exceptions import DevelopmentInstallationRequired
+
from copy import copy
from eth_tester.exceptions import ValidationError
@@ -31,7 +33,6 @@ class Vladimir(Ursula):
"""
from tests.utils.middleware import EvilMiddleWare
- network_middleware = EvilMiddleWare()
fraud_address = '0xbad022A87Df21E4c787C7B1effD5077014b8CC45'
fraud_key = 'a75d701cc4199f7646909d15f22e2e0ef6094b3e2aa47a188f35f47e8932a7b9'
db_filepath = ':memory:'
@@ -47,6 +48,13 @@ class Vladimir(Ursula):
TODO: This is probably a more instructive method if it takes a bytes representation instead of the entire Ursula.
"""
+ try:
+ from tests.utils.middleware import EvilMiddleWare
+ except ImportError:
+ raise DevelopmentInstallationRequired(importable_name='tests.utils.middleware.EvilMiddleWare')
+ else:
+ cls.network_middleware = EvilMiddleWare()
+
crypto_power = CryptoPower(power_ups=target_ursula._default_crypto_powerups)
if claim_signing_key:
@@ -55,6 +63,7 @@ class Vladimir(Ursula):
if attach_transacting_key:
cls.attach_transacting_key(blockchain=target_ursula.blockchain)
+
vladimir = cls(is_me=True,
crypto_power=crypto_power,
db_filepath=cls.db_filepath,
diff --git a/nucypher/cli/options.py b/nucypher/cli/options.py
index fe2f910d9..1cb5dd81b 100644
--- a/nucypher/cli/options.py
+++ b/nucypher/cli/options.py
@@ -20,6 +20,7 @@ from collections import namedtuple
import click
import functools
import os
+from twisted.python.log import Logger
from nucypher.blockchain.eth.constants import NUCYPHER_CONTRACT_NAMES
from nucypher.cli.types import (
@@ -30,6 +31,7 @@ from nucypher.cli.types import (
)
# Alphabetical
+
option_checksum_address = click.option('--checksum-address', help="Run with a specified account", type=EIP55_CHECKSUM_ADDRESS)
option_config_file = click.option('--config-file', help="Path to configuration file", type=EXISTING_READABLE_FILE)
option_config_root = click.option('--config-root', help="Custom configuration directory", type=click.Path())
@@ -182,22 +184,18 @@ def wrap_option(handler, **options):
return _decorator
-def process_middleware(mock_networking):
+def process_middleware(mock_networking) -> tuple:
+ """Must not raise"""
try:
- import tests
- except ImportError:
- # TODO: IDK what to say here...needs further discussion around deprecation in lieu of mocks.
- tests_available = False
- else:
- tests_available = True
-
- if mock_networking and tests_available:
from tests.utils.middleware import MockRestMiddleware
+ except ImportError:
+ logger = Logger("CLI-Middleware-Optional-Handler")
+ logger.info('--mock-networking flag is unavailable without dev install.')
+ if mock_networking:
middleware = MockRestMiddleware()
else:
from nucypher.network.middleware import RestMiddleware
middleware = RestMiddleware()
-
return 'middleware', middleware
diff --git a/scripts/local_fleet/run_single_ursula.py b/scripts/local_fleet/run_single_ursula.py
index f8430c59f..42ef6a03b 100644
--- a/scripts/local_fleet/run_single_ursula.py
+++ b/scripts/local_fleet/run_single_ursula.py
@@ -25,7 +25,12 @@ along with nucypher. If not, see .
from click.testing import CliRunner
from nucypher.cli.main import nucypher_cli
-from tests.utils.constants import select_test_port
+from nucypher.exceptions import DevelopmentInstallationRequired
+
+try:
+ from tests.utils.networking import select_test_port
+except ImportError:
+ raise DevelopmentInstallationRequired(importable_name='tests.utils.ursula.select_test_port')
click_runner = CliRunner()