Convert blockchain_constants's consensus_mode param into a fixture and use it to skip some simulation related tests in HARD_FORK_2_0 mode (#15384)
* Convert blockchain_constants's consensus_mode param into a fixture and use it to run daemon_simulation one at a time. * Simulation test seems to support only one running at a time too.
This commit is contained in:
parent
6effab5dd2
commit
fbe7daa32e
|
@ -28,6 +28,7 @@ from chia.server.start_service import Service
|
|||
from chia.simulator.full_node_simulator import FullNodeSimulator
|
||||
from chia.simulator.setup_nodes import (
|
||||
SimulatorsAndWallets,
|
||||
setup_full_system,
|
||||
setup_full_system_connect_to_deamon,
|
||||
setup_n_nodes,
|
||||
setup_simulators_and_wallets,
|
||||
|
@ -92,8 +93,13 @@ class Mode(Enum):
|
|||
|
||||
|
||||
@pytest.fixture(scope="session", params=[Mode.PLAIN])
|
||||
def blockchain_constants(request: SubRequest) -> ConsensusConstants:
|
||||
if request.param == Mode.PLAIN:
|
||||
def consensus_mode(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def blockchain_constants(consensus_mode) -> ConsensusConstants:
|
||||
if consensus_mode == Mode.PLAIN:
|
||||
return test_constants
|
||||
raise AssertionError("Invalid Blockchain mode in simulation")
|
||||
|
||||
|
@ -609,7 +615,9 @@ async def farmer_three_harvester_not_started(
|
|||
# because of a hack in shutting down the full node, which means you cannot run
|
||||
# more than one simulations per process.
|
||||
@pytest_asyncio.fixture(scope="function")
|
||||
async def daemon_simulation(bt, get_b_tools, get_b_tools_1):
|
||||
async def daemon_simulation(consensus_mode, bt, get_b_tools, get_b_tools_1):
|
||||
if consensus_mode != Mode.PLAIN:
|
||||
pytest.skip("Skipping this run. This test only supports one running at a time.")
|
||||
async for _ in setup_full_system_connect_to_deamon(
|
||||
test_constants_modified,
|
||||
bt,
|
||||
|
@ -838,3 +846,11 @@ def cost_logger_fixture() -> Iterator[CostLogger]:
|
|||
print()
|
||||
print()
|
||||
print(cost_logger.log_cost_statistics())
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="function")
|
||||
async def simulation(consensus_mode, bt):
|
||||
if consensus_mode != Mode.PLAIN:
|
||||
pytest.skip("Skipping this run. This test only supports one running at a time.")
|
||||
async for _ in setup_full_system(test_constants_modified, bt, db_version=1):
|
||||
yield _
|
||||
|
|
|
@ -15,7 +15,7 @@ from chia.server.start_service import Service
|
|||
from chia.simulator.block_tools import BlockTools, create_block_tools_async, test_constants
|
||||
from chia.simulator.full_node_simulator import FullNodeSimulator
|
||||
from chia.simulator.keyring import TempKeyring
|
||||
from chia.simulator.setup_nodes import SimulatorsAndWallets, setup_full_system
|
||||
from chia.simulator.setup_nodes import SimulatorsAndWallets
|
||||
from chia.simulator.setup_services import setup_full_node
|
||||
from chia.simulator.simulator_protocol import FarmNewBlockProtocol, GetAllCoinsProtocol, ReorgProtocol
|
||||
from chia.simulator.time_out_assert import time_out_assert
|
||||
|
@ -58,12 +58,6 @@ async def extra_node(self_hostname):
|
|||
yield service._api
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="function")
|
||||
async def simulation(bt):
|
||||
async for _ in setup_full_system(test_constants_modified, bt, db_version=1):
|
||||
yield _
|
||||
|
||||
|
||||
class TestSimulation:
|
||||
@pytest.mark.asyncio
|
||||
async def test_simulation_1(self, simulation, extra_node, self_hostname):
|
||||
|
|
Loading…
Reference in New Issue