def test_trinity_config_computed_properties(xdg_trinity_root): data_dir = get_local_data_dir('muffin', xdg_trinity_root) trinity_config = TrinityConfig(network_id=1, data_dir=data_dir) assert trinity_config.network_id == 1 assert trinity_config.data_dir == data_dir assert trinity_config.nodekey_path == get_nodekey_path(data_dir)
async def test_trinity_sync_from_trinity(unused_tcp_port_factory, prepopulated_datadir): port1 = unused_tcp_port_factory() listen_ip = '0.0.0.0' nodekey = load_nodekey(get_nodekey_path(prepopulated_datadir / 'mainnet')) serving_enode = f'enode://{remove_0x_prefix(nodekey.public_key.to_hex())}@{listen_ip}:{port1}' command1 = amend_command_for_unused_port( ('trinity', '--trinity-root-dir', str(prepopulated_datadir), '--disable-discovery'), port1) async with AsyncProcessRunner.run(command1, timeout_sec=120) as runner1: assert await contains_all(runner1.stderr, {serving_enode}) port2 = unused_tcp_port_factory() command2 = amend_command_for_unused_port( ('trinity', '--disable-discovery', '--preferred-node', serving_enode), port2) async with AsyncProcessRunner.run(command2, timeout_sec=120) as runner2: assert await contains_all(runner2.stderr, { "Adding ETHPeer", "Imported 192 headers", "Caught up to skeleton peer", }) # A weak assertion to try and ensure our nodes are actually talking to each other. assert await contains_all(runner1.stderr, { "Adding ETHPeer", })
def test_trinity_config_computed_properties_custom_xdg(tmpdir, xdg_trinity_root): alt_xdg_root = tmpdir.mkdir('trinity-custom') assert not is_under_path(alt_xdg_root, xdg_trinity_root) data_dir = get_data_dir_for_network_id(1, alt_xdg_root) trinity_config = TrinityConfig(trinity_root_dir=alt_xdg_root, network_id=1) assert trinity_config.network_id == 1 assert trinity_config.data_dir == data_dir assert trinity_config.nodekey_path == get_nodekey_path(data_dir)
def nodekey_path(self) -> Path: """ Path where the nodekey is stored """ if self._nodekey_path is None: if self._nodekey is not None: return None else: return get_nodekey_path(self.data_dir) else: return self._nodekey_path
def test_trinity_config_app_identifier(xdg_trinity_root, app_identifier, expected_suffix): data_dir = get_local_data_dir('muffin', xdg_trinity_root) trinity_config = TrinityConfig(network_id=1, data_dir=data_dir, app_identifier=app_identifier) assert trinity_config.network_id == 1 assert trinity_config.data_dir == data_dir assert trinity_config.logfile_path == data_dir / (LOG_DIR + expected_suffix) / LOG_FILE assert trinity_config.jsonrpc_ipc_path == data_dir / (IPC_DIR + expected_suffix) / JSONRPC_SOCKET_FILENAME # noqa: E501 assert trinity_config.database_ipc_path == data_dir / (IPC_DIR + expected_suffix) / DATABASE_SOCKET_FILENAME # noqa: E501 assert trinity_config.pid_dir == data_dir / (PID_DIR + expected_suffix) assert trinity_config.nodekey_path == get_nodekey_path(data_dir)