From 5577d5a3c0904a4805e7b768cb60144daa2a0854 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sun, 25 Aug 2024 20:57:22 +0200 Subject: test: fix `TestShell` initialization (late follow-up for #30463) Github-Pull: #30714 Rebased-From: bd7ce05f9d9d21903163a2bd9dd2df3ed3990c3e --- test/functional/test_framework/test_shell.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/functional/test_framework/test_shell.py b/test/functional/test_framework/test_shell.py index 09ccec28a1..e232430507 100644 --- a/test/functional/test_framework/test_shell.py +++ b/test/functional/test_framework/test_shell.py @@ -2,9 +2,11 @@ # Copyright (c) 2019-2022 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +import pathlib from test_framework.test_framework import BitcoinTestFramework + class TestShell: """Wrapper Class for BitcoinTestFramework. @@ -67,7 +69,13 @@ class TestShell: # This implementation enforces singleton pattern, and will return the # previously initialized instance if available if not TestShell.instance: - TestShell.instance = TestShell.__TestShell() + # BitcoinTestFramework instances are supposed to be constructed with the path + # of the calling test in order to find shared data like configuration and the + # cache. Since TestShell is meant for interactive use, there is no concrete + # test; passing a dummy name is fine though, as only the containing directory + # is relevant for successful initialization. + tests_directory = pathlib.Path(__file__).resolve().parent.parent + TestShell.instance = TestShell.__TestShell(tests_directory / "testshell_dummy.py") TestShell.instance.running = False return TestShell.instance -- cgit v1.2.3 From 342baabaffc385dc44a44f6d8cf32728a25a0356 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 30 Aug 2024 12:05:13 +0200 Subject: test: Avoid intermittent timeout in p2p_headers_sync_with_minchainwork.py Github-Pull: #30761 Rebased-From: fa247e6e8c7fddf9e3461c3e2e6f5fade0fe64cf --- test/functional/p2p_headers_sync_with_minchainwork.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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): -- cgit v1.2.3 From 199bb09d88e28d951c5068eb65643390dbedd066 Mon Sep 17 00:00:00 2001 From: Jadi Date: Mon, 2 Sep 2024 16:18:33 +0330 Subject: test: fixing failing system_tests/run_command under some Locales the run_command test under system_tests fails if the locale is anything other than English ones because results such as "No such file or directory" will be different under Non-English locales. On the old version, a `ls nonexistingfile` was used to generate the error output which is not ideal. In the current version we are using a Python one-liner to generate a non 0 zero return value and "err" on stderr and check the expected value against this. fixes #30608 Github-Pull: #30788 Rebased-From: ae48a22a3df086fb59843b7b814619ed5df7557b --- src/test/system_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index baa759e42c..07d15f5552 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -54,8 +54,8 @@ BOOST_AUTO_TEST_CASE(run_command) } { // Return non-zero exit code, with error message for stderr - const std::string command{"ls nosuchfile"}; - const std::string expected{"No such file or directory"}; + const std::string command{"python3 -c 'import sys; print(\"err\", file=sys.stderr); sys.exit(2)'"}; + const std::string expected{"err"}; BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) { const std::string what(e.what()); BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned", command)) != std::string::npos); -- cgit v1.2.3 From b2a137929a20baed161988e24de592b1f59c0096 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 28 Aug 2024 17:35:29 +0100 Subject: depends: build libevent with -D_GNU_SOURCE Currently, builds of libevent in depends, using CMake, fail on some systems, like Alpine, with the following: ```bash /bitcoin/depends/work/build/aarch64-unknown-linux-musl/libevent/2.1.12-stable-1516ed47ea8/evmap.c: In function 'evmap_signal_add_': /bitcoin/depends/work/build/aarch64-unknown-linux-musl/libevent/2.1.12-stable-1516ed47ea8/evmap.c:456:31: error: 'NSIG' undeclared (first use in this function) 456 | if (sig < 0 || sig >= NSIG) ``` From what I can tell the `_GNU_SOURCE` "detection" in libevents CMake build system, never? really worked, and it's not clear what a nice fix is. For now, always use `_GNU_SOURCE` when building libevent in depends. Github-Pull: #30743 Rebased-From: 556775408797d8e27154c3edaf139820b0979cce --- depends/packages/libevent.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/depends/packages/libevent.mk b/depends/packages/libevent.mk index 24e940eaa0..4c05e8a0a7 100644 --- a/depends/packages/libevent.mk +++ b/depends/packages/libevent.mk @@ -14,6 +14,7 @@ define $(package)_set_vars $(package)_config_opts=-DEVENT__DISABLE_BENCHMARK=ON -DEVENT__DISABLE_OPENSSL=ON $(package)_config_opts+=-DEVENT__DISABLE_SAMPLES=ON -DEVENT__DISABLE_REGRESS=ON $(package)_config_opts+=-DEVENT__DISABLE_TESTS=ON -DEVENT__LIBRARY_TYPE=STATIC + $(package)_cppflags += -D_GNU_SOURCE $(package)_cppflags_mingw32=-D_WIN32_WINNT=0x0601 ifeq ($(NO_HARDEN),) -- cgit v1.2.3