aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-08-30 12:05:13 +0200
committerfanquake <fanquake@gmail.com>2024-09-03 10:01:56 +0100
commit342baabaffc385dc44a44f6d8cf32728a25a0356 (patch)
tree47b1a704ab2e2657a1ceb91e0f1410e4e60de467
parent5577d5a3c0904a4805e7b768cb60144daa2a0854 (diff)
test: Avoid intermittent timeout in p2p_headers_sync_with_minchainwork.py
Github-Pull: #30761 Rebased-From: fa247e6e8c7fddf9e3461c3e2e6f5fade0fe64cf
-rwxr-xr-xtest/functional/p2p_headers_sync_with_minchainwork.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/functional/p2p_headers_sync_with_minchainwork.py b/test/functional/p2p_headers_sync_with_minchainwork.py
index 9055232cf3..6e7b4b399e 100755
--- a/test/functional/p2p_headers_sync_with_minchainwork.py
+++ b/test/functional/p2p_headers_sync_with_minchainwork.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# Copyright (c) 2019-2022 The Bitcoin Core developers
+# Copyright (c) 2019-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test that we reject low difficulty headers to prevent our block tree from filling up with useless bloat"""
@@ -21,6 +21,8 @@ from test_framework.blocktools import (
from test_framework.util import assert_equal
+import time
+
NODE1_BLOCKS_REQUIRED = 15
NODE2_BLOCKS_REQUIRED = 2047
@@ -48,6 +50,10 @@ class RejectLowDifficultyHeadersTest(BitcoinTestFramework):
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
+ def mocktime_all(self, time):
+ for n in self.nodes:
+ n.setmocktime(time)
+
def test_chains_sync_when_long_enough(self):
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")
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 @@ class RejectLowDifficultyHeadersTest(BitcoinTestFramework):
self.reconnect_all()
+ self.mocktime_all(int(time.time())) # Temporarily hold time to avoid internal timeouts
self.sync_blocks(timeout=300) # Ensure tips eventually agree
+ self.mocktime_all(0)
def run_test(self):