Skip to content

Commit fa247e6

Browse files
author
MarcoFalke
committed
test: Avoid intermittent timeout in p2p_headers_sync_with_minchainwork.py
1 parent ffdc3d6 commit fa247e6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/functional/p2p_headers_sync_with_minchainwork.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2019-2022 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"""
@@ -21,6 +21,8 @@
2121

2222
from test_framework.util import assert_equal
2323

24+
import time
25+
2426
NODE1_BLOCKS_REQUIRED = 15
2527
NODE2_BLOCKS_REQUIRED = 2047
2628

@@ -48,6 +50,10 @@ def reconnect_all(self):
4850
self.connect_nodes(0, 2)
4951
self.connect_nodes(0, 3)
5052

53+
def mocktime_all(self, time):
54+
for n in self.nodes:
55+
n.setmocktime(time)
56+
5157
def test_chains_sync_when_long_enough(self):
5258
self.log.info("Generate blocks on the node with no required chainwork, and verify nodes 1 and 2 have no new headers in their headers tree")
5359
with self.nodes[1].assert_debug_log(expected_msgs=["[net] Ignoring low-work chain (height=14)"]), self.nodes[2].assert_debug_log(expected_msgs=["[net] Ignoring low-work chain (height=14)"]), self.nodes[3].assert_debug_log(expected_msgs=["Synchronizing blockheaders, height: 14"]):
@@ -149,7 +155,9 @@ def test_large_reorgs_can_succeed(self):
149155

150156
self.reconnect_all()
151157

158+
self.mocktime_all(int(time.time())) # Temporarily hold time to avoid internal timeouts
152159
self.sync_blocks(timeout=300) # Ensure tips eventually agree
160+
self.mocktime_all(0)
153161

154162

155163
def run_test(self):

0 commit comments

Comments
 (0)