Skip to content

Commit fa46088

Browse files
committed
Merge bitcoin#30762: [28.x] rc backports
b2a1379 depends: build libevent with -D_GNU_SOURCE (fanquake) 199bb09 test: fixing failing system_tests/run_command under some Locales (Jadi) 342baab test: Avoid intermittent timeout in p2p_headers_sync_with_minchainwork.py (MarcoFalke) 5577d5a test: fix `TestShell` initialization (late follow-up for bitcoin#30463) (Sebastian Falbesoner) Pull request description: Backports: * bitcoin#30714 * bitcoin#30743 * bitcoin#30761 * bitcoin#30788 ACKs for top commit: willcl-ark: ACK b2a1379 achow101: ACK b2a1379 stickies-v: ACK b2a1379 Tree-SHA512: bf08ac0c613395def974a1b287345d4a64edc066c14f8c9f0184478b0e33e48333760eeb6e96b6b5fbafbb21b40d01875e3f526213a2734e226b2e111d71f3a3
2 parents 88f0419 + b2a1379 commit fa46088

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

depends/packages/libevent.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ define $(package)_set_vars
1414
$(package)_config_opts=-DEVENT__DISABLE_BENCHMARK=ON -DEVENT__DISABLE_OPENSSL=ON
1515
$(package)_config_opts+=-DEVENT__DISABLE_SAMPLES=ON -DEVENT__DISABLE_REGRESS=ON
1616
$(package)_config_opts+=-DEVENT__DISABLE_TESTS=ON -DEVENT__LIBRARY_TYPE=STATIC
17+
$(package)_cppflags += -D_GNU_SOURCE
1718
$(package)_cppflags_mingw32=-D_WIN32_WINNT=0x0601
1819

1920
ifeq ($(NO_HARDEN),)

src/test/system_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ BOOST_AUTO_TEST_CASE(run_command)
5454
}
5555
{
5656
// Return non-zero exit code, with error message for stderr
57-
const std::string command{"ls nosuchfile"};
58-
const std::string expected{"No such file or directory"};
57+
const std::string command{"python3 -c 'import sys; print(\"err\", file=sys.stderr); sys.exit(2)'"};
58+
const std::string expected{"err"};
5959
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
6060
const std::string what(e.what());
6161
BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned", command)) != std::string::npos);

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-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):

test/functional/test_framework/test_shell.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
# Copyright (c) 2019-2022 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.
5+
import pathlib
56

67
from test_framework.test_framework import BitcoinTestFramework
78

9+
810
class TestShell:
911
"""Wrapper Class for BitcoinTestFramework.
1012
@@ -67,7 +69,13 @@ def __new__(cls):
6769
# This implementation enforces singleton pattern, and will return the
6870
# previously initialized instance if available
6971
if not TestShell.instance:
70-
TestShell.instance = TestShell.__TestShell()
72+
# BitcoinTestFramework instances are supposed to be constructed with the path
73+
# of the calling test in order to find shared data like configuration and the
74+
# cache. Since TestShell is meant for interactive use, there is no concrete
75+
# test; passing a dummy name is fine though, as only the containing directory
76+
# is relevant for successful initialization.
77+
tests_directory = pathlib.Path(__file__).resolve().parent.parent
78+
TestShell.instance = TestShell.__TestShell(tests_directory / "testshell_dummy.py")
7179
TestShell.instance.running = False
7280
return TestShell.instance
7381

0 commit comments

Comments
 (0)