mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-11 01:28:17 +03:00
tidy from review recommendations
This commit is contained in:
parent
d60f6f2fdc
commit
951d01975f
@ -24,14 +24,10 @@ log = logging.getLogger(__name__)
|
||||
def service_kwargs_for_data_layer(
|
||||
root_path: pathlib.Path,
|
||||
config: Dict[str, Any],
|
||||
port: Optional[int] = None,
|
||||
rpc_port: Optional[int] = None,
|
||||
wallet_rpc_port: Optional[int] = None,
|
||||
) -> Dict[str, Any]:
|
||||
dl_config = config["data_layer"]
|
||||
self_hostname = config["self_hostname"]
|
||||
if wallet_rpc_port is None:
|
||||
wallet_rpc_port = dl_config["wallet_peer"]["port"]
|
||||
wallet_rpc_port = dl_config["wallet_peer"]["port"]
|
||||
wallet_rpc_init = WalletRpcClient.create(self_hostname, uint16(wallet_rpc_port), root_path, config)
|
||||
data_layer = DataLayer(root_path=root_path, wallet_rpc_init=wallet_rpc_init)
|
||||
api = DataLayerAPI(data_layer)
|
||||
@ -48,13 +44,11 @@ def service_kwargs_for_data_layer(
|
||||
network_id=network_id,
|
||||
)
|
||||
|
||||
if port is None:
|
||||
port = dl_config.get("port")
|
||||
port = dl_config.get("port")
|
||||
if port is not None:
|
||||
kwargs.update(advertised_port=dl_config["port"], server_listen_ports=[dl_config["port"]])
|
||||
|
||||
if rpc_port is None:
|
||||
rpc_port = dl_config.get("rpc_port")
|
||||
rpc_port = dl_config.get("rpc_port")
|
||||
if rpc_port is not None:
|
||||
kwargs["rpc_info"] = (DataLayerRpcApi, dl_config["rpc_port"])
|
||||
|
||||
|
@ -29,15 +29,12 @@ pytestmark = pytest.mark.data_layer
|
||||
nodes = Tuple[WalletNode, FullNodeSimulator]
|
||||
|
||||
|
||||
async def init_data_layer(root_path: Path, wallet_rpc_port: int) -> AsyncIterator[DataLayer]:
|
||||
async def init_data_layer(wallet_rpc_port: int) -> AsyncIterator[DataLayer]:
|
||||
config = bt.config
|
||||
kwargs = service_kwargs_for_data_layer(
|
||||
root_path=root_path,
|
||||
config=config,
|
||||
port=find_available_listen_port("data_layer"),
|
||||
rpc_port=find_available_listen_port("data_layer_rpc"),
|
||||
wallet_rpc_port=wallet_rpc_port,
|
||||
)
|
||||
config["data_layer"]["wallet_peer"]["port"] = wallet_rpc_port
|
||||
config["data_layer"]["port"] = find_available_listen_port("data_layer")
|
||||
config["data_layer"]["rpc_port"] = find_available_listen_port("data_layer_rpc")
|
||||
kwargs = service_kwargs_for_data_layer(root_path=bt.root_path, config=config)
|
||||
kwargs.update(parse_cli_args=False)
|
||||
service = Service(**kwargs)
|
||||
await service.start()
|
||||
@ -91,7 +88,7 @@ async def test_create_insert_get(one_wallet_node_and_rpc: nodes) -> None:
|
||||
)
|
||||
await time_out_assert(15, wallet_node.wallet_state_manager.main_wallet.get_confirmed_balance, funds)
|
||||
wallet_rpc_api = WalletRpcApi(wallet_node)
|
||||
async for data_layer in init_data_layer(root_path, wallet_rpc_port=wallet_node.server._port):
|
||||
async for data_layer in init_data_layer(wallet_rpc_port=wallet_node.server._port):
|
||||
data_rpc_api = DataLayerRpcApi(data_layer)
|
||||
key = b"a"
|
||||
value = b"\x00\x01"
|
||||
@ -147,7 +144,7 @@ async def test_create_double_insert(one_wallet_node_and_rpc: nodes) -> None:
|
||||
)
|
||||
await time_out_assert(15, wallet_node.wallet_state_manager.main_wallet.get_confirmed_balance, funds)
|
||||
wallet_rpc_api = WalletRpcApi(wallet_node)
|
||||
async for data_layer in init_data_layer(root_path, wallet_rpc_port=wallet_node.server._port):
|
||||
async for data_layer in init_data_layer(wallet_rpc_port=wallet_node.server._port):
|
||||
data_rpc_api = DataLayerRpcApi(data_layer)
|
||||
res = await data_rpc_api.create_data_store({})
|
||||
assert res is not None
|
||||
@ -210,7 +207,7 @@ async def test_keys_values_ancestors(one_wallet_node_and_rpc: nodes) -> None:
|
||||
await time_out_assert(15, wallet_node.wallet_state_manager.main_wallet.get_confirmed_balance, funds)
|
||||
wallet_rpc_api = WalletRpcApi(wallet_node)
|
||||
# TODO: with this being a pseudo context manager'ish thing it doesn't actually handle shutdown
|
||||
async for data_layer in init_data_layer(root_path, wallet_rpc_port=wallet_node.server._port):
|
||||
async for data_layer in init_data_layer(wallet_rpc_port=wallet_node.server._port):
|
||||
data_rpc_api = DataLayerRpcApi(data_layer)
|
||||
res = await data_rpc_api.create_data_store({})
|
||||
assert res is not None
|
||||
@ -294,7 +291,7 @@ async def test_get_roots(one_wallet_node_and_rpc: nodes) -> None:
|
||||
)
|
||||
await time_out_assert(15, wallet_node.wallet_state_manager.main_wallet.get_confirmed_balance, funds)
|
||||
wallet_rpc_api = WalletRpcApi(wallet_node)
|
||||
async for data_layer in init_data_layer(root_path, wallet_rpc_port=wallet_node.server._port):
|
||||
async for data_layer in init_data_layer(wallet_rpc_port=wallet_node.server._port):
|
||||
data_rpc_api = DataLayerRpcApi(data_layer)
|
||||
res = await data_rpc_api.create_data_store({})
|
||||
assert res is not None
|
||||
@ -369,7 +366,7 @@ async def test_get_root_history(one_wallet_node_and_rpc: nodes) -> None:
|
||||
)
|
||||
await time_out_assert(15, wallet_node.wallet_state_manager.main_wallet.get_confirmed_balance, funds)
|
||||
wallet_rpc_api = WalletRpcApi(wallet_node)
|
||||
async for data_layer in init_data_layer(root_path, wallet_rpc_port=wallet_node.server._port):
|
||||
async for data_layer in init_data_layer(wallet_rpc_port=wallet_node.server._port):
|
||||
data_rpc_api = DataLayerRpcApi(data_layer)
|
||||
res = await data_rpc_api.create_data_store({})
|
||||
assert res is not None
|
||||
@ -447,7 +444,7 @@ async def test_get_kv_diff(one_wallet_node_and_rpc: nodes) -> None:
|
||||
)
|
||||
await time_out_assert(15, wallet_node.wallet_state_manager.main_wallet.get_confirmed_balance, funds)
|
||||
wallet_rpc_api = WalletRpcApi(wallet_node)
|
||||
async for data_layer in init_data_layer(root_path, wallet_rpc_port=wallet_node.server._port):
|
||||
async for data_layer in init_data_layer(wallet_rpc_port=wallet_node.server._port):
|
||||
data_rpc_api = DataLayerRpcApi(data_layer)
|
||||
res = await data_rpc_api.create_data_store({})
|
||||
assert res is not None
|
||||
@ -538,7 +535,7 @@ async def test_batch_update_matches_single_operations(one_wallet_node_and_rpc: n
|
||||
)
|
||||
await time_out_assert(15, wallet_node.wallet_state_manager.main_wallet.get_confirmed_balance, funds)
|
||||
wallet_rpc_api = WalletRpcApi(wallet_node)
|
||||
async for data_layer in init_data_layer(root_path, wallet_rpc_port=wallet_node.server._port):
|
||||
async for data_layer in init_data_layer(wallet_rpc_port=wallet_node.server._port):
|
||||
data_rpc_api = DataLayerRpcApi(data_layer)
|
||||
res = await data_rpc_api.create_data_store({})
|
||||
assert res is not None
|
||||
|
Loading…
Reference in New Issue
Block a user