def test_load(tmp_path): private_key_path = tmp_path / 'private' public_key_path = tmp_path / 'public' key1 = KeyComponent.load_or_create(private_key_path, public_key_path) key2 = KeyComponent.load_or_create(private_key_path, public_key_path) assert key1.key_to_bin() == key2.key_to_bin()
def upgrade_state_dir(root_state_dir: Path, update_status_callback=None, interrupt_upgrade_event=None): # Before any upgrade, prepare a separate state directory for the update version so it does not # affect the older version state directory. This allows for safe rollback. version_history = VersionHistory(root_state_dir) version_history.fork_state_directory_if_necessary() version_history.save_if_necessary() state_dir = version_history.code_version.directory if not state_dir.exists(): return config = TriblerConfig.load(file=state_dir / CONFIG_FILE_NAME, state_dir=state_dir, reset_config_on_error=True) channels_dir = config.chant.get_path_as_absolute('channels_dir', config.state_dir) primary_private_key_path = config.state_dir / KeyComponent.get_private_key_filename( config) primary_public_key_path = config.state_dir / config.trustchain.ec_keypair_pubfilename primary_key = KeyComponent.load_or_create(primary_private_key_path, primary_public_key_path) upgrader = TriblerUpgrader(state_dir, channels_dir, primary_key, update_status_callback=update_status_callback, interrupt_upgrade_event=interrupt_upgrade_event) upgrader.run()
def test_create_no_public_key(tmp_path): private_key_path = tmp_path / 'private' assert not private_key_path.exists() key = KeyComponent.load_or_create(private_key_path) assert key assert private_key_path.exists()