Skip to content

Commit

Permalink
make sure we set max_sync_wait to 0 in all tests (#16771)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn authored Nov 6, 2023
1 parent 95ed41d commit 9622331
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,10 +913,11 @@ async def _sync(self) -> None:
self.log.debug("long sync started")
try:
self.log.info("Starting to perform sync.")
self.log.info("Waiting to receive peaks from peers.")

# Wait until we have 3 peaks or up to a max of 30 seconds
max_iterations = int(self.config.get("max_sync_wait", 30)) * 10

self.log.info(f"Waiting to receive peaks from peers. (timeout: {max_iterations/10}s)")
peaks = []
for i in range(max_iterations):
peaks = [peak.header_hash for peak in self.sync_store.get_peak_of_each_peer().values()]
Expand Down
27 changes: 20 additions & 7 deletions chia/simulator/setup_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ async def setup_two_nodes(
Setup and teardown of two full nodes, with blockchains and separate DBs.
"""

config_overrides = {"full_node.max_sync_wait": 0}
with TempKeyring(populate=True) as keychain1, TempKeyring(populate=True) as keychain2:
bt1 = await create_block_tools_async(constants=consensus_constants, keychain=keychain1)
bt1 = await create_block_tools_async(
constants=consensus_constants, keychain=keychain1, config_overrides=config_overrides
)
async with setup_full_node(
consensus_constants,
"blockchain_test.db",
Expand All @@ -91,7 +94,9 @@ async def setup_two_nodes(
consensus_constants,
"blockchain_test_2.db",
self_hostname,
await create_block_tools_async(constants=consensus_constants, keychain=keychain2),
await create_block_tools_async(
constants=consensus_constants, keychain=keychain2, config_overrides=config_overrides
),
simulator=False,
db_version=db_version,
) as service2:
Expand All @@ -108,6 +113,7 @@ async def setup_n_nodes(
"""
Setup and teardown of n full nodes, with blockchains and separate DBs.
"""
config_overrides = {"full_node.max_sync_wait": 0}
with ExitStack() as stack:
keychains = [stack.enter_context(TempKeyring(populate=True)) for _ in range(n)]
async with AsyncExitStack() as async_exit_stack:
Expand All @@ -117,7 +123,9 @@ async def setup_n_nodes(
consensus_constants,
f"blockchain_test_{i}.db",
self_hostname,
await create_block_tools_async(constants=consensus_constants, keychain=keychain),
await create_block_tools_async(
constants=consensus_constants, keychain=keychain, config_overrides=config_overrides
),
simulator=False,
db_version=db_version,
)
Expand Down Expand Up @@ -145,8 +153,6 @@ async def setup_simulators_and_wallets(
with TempKeyring(populate=True) as keychain1, TempKeyring(populate=True) as keychain2:
if config_overrides is None:
config_overrides = {}
if "full_node.max_sync_wait" not in config_overrides:
config_overrides["full_node.max_sync_wait"] = 1
async with setup_simulators_and_wallets_inner(
db_version,
consensus_constants,
Expand Down Expand Up @@ -223,6 +229,8 @@ async def setup_simulators_and_wallets_inner(
) -> AsyncIterator[
Tuple[List[BlockTools], List[Service[FullNode, FullNodeSimulator]], List[Service[WalletNode, WalletNodeAPI]]]
]:
if config_overrides is not None and "full_node.max_sync_wait" not in config_overrides:
config_overrides["full_node.max_sync_wait"] = 0
async with AsyncExitStack() as async_exit_stack:
bt_tools: List[BlockTools] = [
await create_block_tools_async(consensus_constants, keychain=keychain1, config_overrides=config_overrides)
Expand Down Expand Up @@ -337,10 +345,15 @@ async def setup_full_system_inner(
keychain2: Keychain,
shared_b_tools: BlockTools,
) -> AsyncIterator[FullSystem]:
config_overrides = {"full_node.max_sync_wait": 0}
if b_tools is None:
b_tools = await create_block_tools_async(constants=consensus_constants, keychain=keychain1)
b_tools = await create_block_tools_async(
constants=consensus_constants, keychain=keychain1, config_overrides=config_overrides
)
if b_tools_1 is None:
b_tools_1 = await create_block_tools_async(constants=consensus_constants, keychain=keychain2)
b_tools_1 = await create_block_tools_async(
constants=consensus_constants, keychain=keychain2, config_overrides=config_overrides
)

self_hostname = shared_b_tools.config["self_hostname"]

Expand Down

0 comments on commit 9622331

Please sign in to comment.