From 0b8fe88f5c063c1d8d056f3511f54c2a7cf8f505 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 27 Jul 2025 05:09:27 +0000 Subject: [PATCH 1/2] chore: resolve logical conflict between dash#6691 and dash#6775 dash#6775 updates UniValue, which changed the syntax for fetching integers, which created a divergence of expected behavior from dash#6691 --- src/test/llmq_commitment_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/llmq_commitment_tests.cpp b/src/test/llmq_commitment_tests.cpp index cfc193f42725..00423685851b 100644 --- a/src/test/llmq_commitment_tests.cpp +++ b/src/test/llmq_commitment_tests.cpp @@ -142,8 +142,8 @@ BOOST_AUTO_TEST_CASE(commitment_json_test) BOOST_CHECK(json.exists("signersCount")); BOOST_CHECK(json.exists("validMembersCount")); - BOOST_CHECK_EQUAL(json["signersCount"].get_int(), commitment.CountSigners()); - BOOST_CHECK_EQUAL(json["validMembersCount"].get_int(), commitment.CountValidMembers()); + BOOST_CHECK_EQUAL(json["signersCount"].getInt(), commitment.CountSigners()); + BOOST_CHECK_EQUAL(json["validMembersCount"].getInt(), commitment.CountValidMembers()); } BOOST_AUTO_TEST_CASE(commitment_bitvector_json_test) From 1eedea0a2c337268d78cd727c4032c81902feba3 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 7 Jul 2023 10:57:22 +0100 Subject: [PATCH 2/2] Merge bitcoin/bitcoin#28015: fuzz: Generate rpc fuzz targets individually fa1e27fe8ec42764d0250c82a83d774c15798c4a fuzz: Generate rpc fuzz targets individually (MarcoFalke) Pull request description: The `rpc` fuzz target was added more than two years ago in e45863166f5e44cc2c380f4667812fcd3cddc73b. However, the bug https://github.com/bitcoin/bitcoin/issues/27913 was only found recently. Thus, it is pretty clear that fuzz engines can't deal with a search space that is too broad and can be extended in too many directions. Fix that by limiting the search space to each RPC method name and then iterate over all names, instead of letting the fuzz engine do the iteration. With this, the bug can be found in seconds, as opposed to years of CPU time (or never). ACKs for top commit: brunoerg: ACK fa1e27fe8ec42764d0250c82a83d774c15798c4a dergoegge: ACK fa1e27fe8ec42764d0250c82a83d774c15798c4a Tree-SHA512: 45ccba842367650d010320603153276b1b303deda9ba8c6bb31a4d2473b00aa5bca866db95f541485d65efd8276e2575026968c037872ef344fa33cf45bcdcd7 --- test/fuzz/test_runner.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/test/fuzz/test_runner.py b/test/fuzz/test_runner.py index 7888830028ad..9697e0e098fd 100755 --- a/test/fuzz/test_runner.py +++ b/test/fuzz/test_runner.py @@ -193,22 +193,40 @@ def generate_corpus(*, fuzz_pool, src_dir, build_dir, corpus_dir, targets): {corpus_dir}. """ logging.info("Generating corpus to {}".format(corpus_dir)) - - def job(command, t): - logging.debug("Running '{}'\n".format(" ".join(command))) + rpc_target = "rpc" + has_rpc = rpc_target in targets + if has_rpc: + targets.remove(rpc_target) + targets = [(t, {}) for t in targets] + if has_rpc: + lines = subprocess.run( + ["git", "grep", "--function-context", "RPC_COMMANDS_SAFE_FOR_FUZZING{", os.path.join(src_dir, "src", "test", "fuzz", "rpc.cpp")], + check=True, + stdout=subprocess.PIPE, + text=True, + ).stdout.splitlines() + lines = [l.split("\"", 1)[1].split("\"")[0] for l in lines if l.startswith("src/test/fuzz/rpc.cpp- \"")] + targets += [(rpc_target, {"LIMIT_TO_RPC_COMMAND": r}) for r in lines] + + def job(command, t, t_env): + logging.debug(f"Running '{command}'") logging.debug("Command '{}' output:\n'{}'\n".format( - ' '.join(command), + command, subprocess.run( command, - env=get_fuzz_env(target=t, source_dir=src_dir), + env={ + **t_env, + **get_fuzz_env(target=t, source_dir=src_dir), + }, check=True, stderr=subprocess.PIPE, universal_newlines=True, - ).stderr)) + ).stderr, + )) futures = [] - for target in targets: - target_corpus_dir = os.path.join(corpus_dir, target) + for target, t_env in targets: + target_corpus_dir = corpus_dir / target os.makedirs(target_corpus_dir, exist_ok=True) use_value_profile = int(random.random() < .3) command = [ @@ -219,7 +237,7 @@ def job(command, t): f"-use_value_profile={use_value_profile}", target_corpus_dir, ] - futures.append(fuzz_pool.submit(job, command, target)) + futures.append(fuzz_pool.submit(job, command, target, t_env)) for future in as_completed(futures): future.result()