Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/llmq_commitment_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(), commitment.CountSigners());
BOOST_CHECK_EQUAL(json["validMembersCount"].getInt<int>(), commitment.CountValidMembers());
}

BOOST_AUTO_TEST_CASE(commitment_bitvector_json_test)
Expand Down
36 changes: 27 additions & 9 deletions test/fuzz/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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()
Expand Down