Allow other Characters to be --lonely.

pull/2140/head
jMyles 2020-06-22 21:19:20 -07:00
parent a9c1763e1b
commit b491a613a1
6 changed files with 13 additions and 7 deletions

View File

@ -52,7 +52,7 @@ from nucypher.cli.options import (
option_provider_uri,
option_registry_filepath,
option_signer_uri,
option_teacher_uri
option_teacher_uri, option_lonely
)
from nucypher.cli.painting.help import paint_new_installation_help
from nucypher.cli.processes import get_geth_provider_process
@ -89,7 +89,8 @@ class AliceConfigOptions:
registry_filepath: str,
middleware: RestMiddleware,
gas_strategy: str,
signer_uri: str
signer_uri: str,
lonely: bool,
):
if federated_only and geth:
@ -115,6 +116,7 @@ class AliceConfigOptions:
self.discovery_port = discovery_port
self.registry_filepath = registry_filepath
self.middleware = middleware
self.lonely = lonely
def create_config(self, emitter, config_file):
@ -172,6 +174,7 @@ group_config_options = group_options(
pay_with=option_pay_with,
registry_filepath=option_registry_filepath,
middleware=option_middleware,
lonely=option_lonely,
)
@ -286,7 +289,8 @@ class AliceCharacterOptions:
min_stake=self.min_stake,
client_password=client_password,
load_preferred_teachers=load_seednodes,
start_learning_now=load_seednodes)
start_learning_now=load_seednodes,
lonely=self.config_options.lonely)
return ALICE
except NucypherKeyring.AuthenticationFailed as e:

View File

@ -294,7 +294,6 @@ class UrsulaCharacterOptions:
group_character_options = group_options(
UrsulaCharacterOptions,
config_options=group_config_options,
lonely=click.option('--lonely', help="Do not connect to seednodes", is_flag=True),
teacher_uri=option_teacher_uri,
min_stake=option_min_stake
)

View File

@ -46,6 +46,7 @@ option_force = click.option('--force', help="Don't ask for confirmation", is_fla
option_geth = click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True)
option_hw_wallet = click.option('--hw-wallet/--no-hw-wallet')
option_light = click.option('--light', help="Indicate that node is light", is_flag=True, default=None)
option_lonely = click.option('--lonely', help="Do not connect to seednodes", is_flag=True)
option_m = click.option('--m', help="M-Threshold KFrags", type=click.INT)
option_min_stake = click.option('--min-stake', help="The minimum stake the teacher must have to be a teacher", type=click.INT, default=0)
option_n = click.option('--n', help="N-Total KFrags", type=click.INT)

View File

@ -227,7 +227,8 @@ class Learner:
self._seed_nodes = seed_nodes or []
self.unresponsive_seed_nodes = set()
if self.start_learning_now:
if self.start_learning_now and not self.lonely:
self.load_seednodes()
self.start_learning_loop(now=self.learn_on_same_thread)
@property

View File

@ -73,7 +73,7 @@ def test_alice_control_starts_with_mocked_keyring(click_runner, mocker, monkeypa
mocker.patch.object(AliceConfiguration, "attach_keyring", return_value=None)
good_enough_config = AliceConfiguration(dev_mode=True, federated_only=True, keyring=MockKeyring)
mocker.patch.object(AliceConfiguration, "from_configuration_file", return_value=good_enough_config)
init_args = ('alice', 'run', '-x', '--network', TEMPORARY_DOMAIN)
init_args = ('alice', 'run', '-x', '--lonely', '--network', TEMPORARY_DOMAIN)
result = click_runner.invoke(nucypher_cli, init_args, input=FAKE_PASSWORD_CONFIRMED)
assert result.exit_code == 0, result.exception
@ -110,7 +110,7 @@ def test_initialize_alice_with_custom_configuration_root(custom_filepath, click_
def test_alice_control_starts_with_preexisting_configuration(click_runner, custom_filepath):
custom_config_filepath = os.path.join(custom_filepath, AliceConfiguration.generate_filename())
run_args = ('alice', 'run', '--dry-run', '--config-file', custom_config_filepath)
run_args = ('alice', 'run', '--dry-run', '--lonely', '--config-file', custom_config_filepath)
result = click_runner.invoke(nucypher_cli, run_args, input=FAKE_PASSWORD_CONFIRMED)
assert result.exit_code == 0

View File

@ -139,6 +139,7 @@ def test_run_federated_ursula_from_config_file(custom_filepath, click_runner):
run_args = ('ursula', 'run',
'--dry-run',
'--interactive',
'--lonely',
'--config-file', custom_config_filepath)
result = click_runner.invoke(nucypher_cli, run_args,