Skip to content

Commit 9289755

Browse files
committed
fix and rename fixture
1 parent 36f7c64 commit 9289755

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

chia/_tests/conftest.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
from chia.simulator.wallet_tools import WalletTool
7373
from chia.solver.solver_service import SolverService
7474
from chia.timelord.timelord_service import TimelordService
75-
from chia.types.peer_info import PeerInfo
75+
from chia.types.peer_info import PeerInfo, UnresolvedPeerInfo
7676
from chia.util.config import create_default_chia_config, lock_and_load_config
7777
from chia.util.db_wrapper import generate_in_memory_db_uri
7878
from chia.util.keychain import Keychain
@@ -92,7 +92,7 @@
9292
from chia_rs.sized_ints import uint128
9393

9494
from chia._tests.environments.wallet import WalletEnvironment, WalletState, WalletTestFramework
95-
from chia._tests.util.setup_nodes import setup_farmer_multi_harvester
95+
from chia._tests.util.setup_nodes import setup_farmer_solver_multi_harvester
9696
from chia.full_node.full_node_rpc_client import FullNodeRpcClient
9797
from chia.simulator.block_tools import BlockTools, create_block_tools_async, test_constants
9898
from chia.simulator.keyring import TempKeyring
@@ -866,7 +866,7 @@ async def farmer_one_harvester_simulator_wallet(
866866
]
867867
]:
868868
async with setup_simulators_and_wallets_service(1, 1, blockchain_constants) as (nodes, wallets, bt):
869-
async with setup_farmer_multi_harvester(bt, 1, tmp_path, bt.constants, start_services=True) as (
869+
async with setup_farmer_solver_multi_harvester(bt, 1, tmp_path, bt.constants, start_services=True) as (
870870
harvester_services,
871871
farmer_service,
872872
_,
@@ -879,7 +879,9 @@ async def farmer_one_harvester_simulator_wallet(
879879

880880
@pytest.fixture(scope="function")
881881
async def farmer_one_harvester(tmp_path: Path, get_b_tools: BlockTools) -> AsyncIterator[FarmerOneHarvester]:
882-
async with setup_farmer_multi_harvester(get_b_tools, 1, tmp_path, get_b_tools.constants, start_services=True) as _:
882+
async with setup_farmer_solver_multi_harvester(
883+
get_b_tools, 1, tmp_path, get_b_tools.constants, start_services=True
884+
) as _:
883885
yield _
884886

885887

@@ -890,36 +892,41 @@ async def farmer_one_harvester(tmp_path: Path, get_b_tools: BlockTools) -> Async
890892
async def farmer_one_harvester_solver(
891893
tmp_path: Path, get_b_tools: BlockTools
892894
) -> AsyncIterator[FarmerOneHarvesterSolver]:
893-
async with setup_farmer_multi_harvester(get_b_tools, 1, tmp_path, get_b_tools.constants, start_services=True) as (
894-
harvester_services,
895-
farmer_service,
896-
bt,
897-
):
898-
async with setup_solver(tmp_path / "solver", bt, bt.constants) as solver_service:
895+
async with setup_solver(tmp_path / "solver", get_b_tools, get_b_tools.constants) as solver_service:
896+
solver_peer = UnresolvedPeerInfo("127.0.0.1", solver_service._server.get_port())
897+
async with setup_farmer_solver_multi_harvester(
898+
get_b_tools, 1, tmp_path, get_b_tools.constants, start_services=True, solver_peer=solver_peer
899+
) as (harvester_services, farmer_service, bt):
899900
yield harvester_services, farmer_service, solver_service, bt
900901

901902

902903
@pytest.fixture(scope="function")
903904
async def farmer_one_harvester_not_started(
904905
tmp_path: Path, get_b_tools: BlockTools
905906
) -> AsyncIterator[tuple[list[HarvesterService], FarmerService, BlockTools]]:
906-
async with setup_farmer_multi_harvester(get_b_tools, 1, tmp_path, get_b_tools.constants, start_services=False) as _:
907+
async with setup_farmer_solver_multi_harvester(
908+
get_b_tools, 1, tmp_path, get_b_tools.constants, start_services=False
909+
) as _:
907910
yield _
908911

909912

910913
@pytest.fixture(scope="function")
911914
async def farmer_two_harvester_not_started(
912915
tmp_path: Path, get_b_tools: BlockTools
913916
) -> AsyncIterator[tuple[list[HarvesterService], FarmerService, BlockTools]]:
914-
async with setup_farmer_multi_harvester(get_b_tools, 2, tmp_path, get_b_tools.constants, start_services=False) as _:
917+
async with setup_farmer_solver_multi_harvester(
918+
get_b_tools, 2, tmp_path, get_b_tools.constants, start_services=False
919+
) as _:
915920
yield _
916921

917922

918923
@pytest.fixture(scope="function")
919924
async def farmer_three_harvester_not_started(
920925
tmp_path: Path, get_b_tools: BlockTools
921926
) -> AsyncIterator[tuple[list[HarvesterService], FarmerService, BlockTools]]:
922-
async with setup_farmer_multi_harvester(get_b_tools, 3, tmp_path, get_b_tools.constants, start_services=False) as _:
927+
async with setup_farmer_solver_multi_harvester(
928+
get_b_tools, 3, tmp_path, get_b_tools.constants, start_services=False
929+
) as _:
923930
yield _
924931

925932

@@ -1302,7 +1309,7 @@ async def farmer_harvester_2_simulators_zero_bits_plot_filter(
13021309
]
13031310

13041311
[harvester_service], farmer_service, _ = await async_exit_stack.enter_async_context(
1305-
setup_farmer_multi_harvester(bt, 1, tmp_path, bt.constants, start_services=True)
1312+
setup_farmer_solver_multi_harvester(bt, 1, tmp_path, bt.constants, start_services=True)
13061313
)
13071314

13081315
yield farmer_service, harvester_service, simulators[0], simulators[1], bt

chia/_tests/farmer_harvester/test_filter_prefix_bits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from chia._tests.conftest import ConsensusMode
1313
from chia._tests.core.test_farmer_harvester_rpc import wait_for_plot_sync
14-
from chia._tests.util.setup_nodes import setup_farmer_multi_harvester
14+
from chia._tests.util.setup_nodes import setup_farmer_solver_multi_harvester
1515
from chia._tests.util.time_out_assert import time_out_assert
1616
from chia.farmer.farmer_api import FarmerAPI
1717
from chia.farmer.farmer_rpc_client import FarmerRpcClient
@@ -60,7 +60,7 @@ async def have_connections() -> bool:
6060
)
6161
new_config = local_b_tools._config
6262
local_b_tools.change_config(new_config)
63-
async with setup_farmer_multi_harvester(
63+
async with setup_farmer_solver_multi_harvester(
6464
local_b_tools, 1, tmp_path, local_b_tools.constants, start_services=True
6565
) as (harvesters, farmer_service, _):
6666
harvester_service = harvesters[0]

chia/_tests/util/setup_nodes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,14 @@ async def setup_simulators_and_wallets_inner(
303303

304304

305305
@asynccontextmanager
306-
async def setup_farmer_multi_harvester(
306+
async def setup_farmer_solver_multi_harvester(
307307
block_tools: BlockTools,
308308
harvester_count: int,
309309
temp_dir: Path,
310310
consensus_constants: ConsensusConstants,
311311
*,
312312
start_services: bool,
313+
solver_peer: Optional[UnresolvedPeerInfo] = None,
313314
) -> AsyncIterator[tuple[list[HarvesterService], FarmerService, BlockTools]]:
314315
async with AsyncExitStack() as async_exit_stack:
315316
farmer_service = await async_exit_stack.enter_async_context(
@@ -320,6 +321,7 @@ async def setup_farmer_multi_harvester(
320321
consensus_constants,
321322
port=uint16(0),
322323
start_service=start_services,
324+
solver_peer=solver_peer,
323325
)
324326
)
325327
if start_services:

chia/simulator/setup_services.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ async def setup_farmer(
359359
full_node_port: Optional[uint16] = None,
360360
start_service: bool = True,
361361
port: uint16 = uint16(0),
362+
solver_peer: Optional[UnresolvedPeerInfo] = None,
362363
) -> AsyncGenerator[FarmerService, None]:
363364
with create_lock_and_load_config(b_tools.root_path / "config" / "ssl" / "ca", root_path) as root_config:
364365
root_config["logging"]["log_stdout"] = True
@@ -386,6 +387,16 @@ async def setup_farmer(
386387
service_config.pop("full_node_peer", None)
387388
service_config.pop("full_node_peers", None)
388389

390+
if solver_peer:
391+
service_config["solver_peers"] = [
392+
{
393+
"host": solver_peer.host,
394+
"port": solver_peer.port,
395+
},
396+
]
397+
else:
398+
service_config.pop("solver_peers", None)
399+
389400
service = create_farmer_service(
390401
root_path,
391402
root_config,

0 commit comments

Comments
 (0)