Skip to content

Commit 6b8d56c

Browse files
knstfanquake
andcommitted
Merge bitcoin#30761: test: Avoid intermittent timeout in p2p_headers_sync_with_minchainwork.py
fa247e6 test: Avoid intermittent timeout in p2p_headers_sync_with_minchainwork.py (MarcoFalke) Pull request description: Similar to bitcoin#30705: The goal of this test case is to check that the sync works at all, not to check any timeout. On extremely slow hardware (for example qemu virtual hardware), downloading the 4110 BLOCKS_TO_MINE may take longer than the block download timeout. Fix it by pinning the time using mocktime temporarily, and advance it immediately after the sync. ACKs for top commit: stratospher: ACK fa247e6. Checked the timeout downloading block logs before/after using `setmocktime`. tdb3: ACK fa247e6 Tree-SHA512: f61632a8d9e484f1b888aafbf87f7adf71b8692387bd77f603cdbc0de49f30d42e654741d46ae1ff8b9706a5559ee0faabdb192ed0db7449010b68bfcdbaa42d Co-authored-by: merge-script <fanquake@gmail.com>
1 parent c3860df commit 6b8d56c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

test/functional/p2p_headers_sync_with_minchainwork.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2019-2021 The Bitcoin Core developers
2+
# Copyright (c) 2019-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test that we reject low difficulty headers to prevent our block tree from filling up with useless bloat"""
@@ -23,6 +23,8 @@
2323

2424
from test_framework.util import assert_equal
2525

26+
import time
27+
2628
NODE1_BLOCKS_REQUIRED = 15
2729
NODE2_BLOCKS_REQUIRED = 2047
2830

@@ -50,6 +52,10 @@ def reconnect_all(self):
5052
self.connect_nodes(0, 2)
5153
self.connect_nodes(0, 3)
5254

55+
def mocktime_all(self, time):
56+
for n in self.nodes:
57+
n.setmocktime(time)
58+
5359
def test_chains_sync_when_long_enough(self):
5460
# The Dash test framework pins mocktime to TIME_GENESIS_BLOCK when
5561
# setup_clean_chain is set, which makes the genesis tip look "recent"
@@ -173,7 +179,9 @@ def test_large_reorgs_can_succeed(self):
173179

174180
self.reconnect_all()
175181

182+
self.mocktime_all(int(time.time())) # Temporarily hold time to avoid internal timeouts
176183
self.sync_blocks(timeout=300) # Ensure tips eventually agree
184+
self.mocktime_all(0)
177185

178186

179187
def run_test(self):

0 commit comments

Comments
 (0)