Skip to content

Commit b3026b1

Browse files
committed
fuzz: add HasPrivKey miniscript helper
1 parent 9c7e477 commit b3026b1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/test/fuzz/miniscript.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ struct TestData {
106106
return &it->second;
107107
}
108108
}
109+
110+
//! Whether signing material is available for this pubkey in this script context.
111+
bool HasPrivKey(const MsCtx script_ctx, const Key& key) const {
112+
const auto sig_ptr = GetSig(script_ctx, key);
113+
return sig_ptr && sig_ptr->second;
114+
}
109115
} TEST_DATA;
110116

111117
/**
@@ -1162,8 +1168,7 @@ void TestNode(const MsCtx script_ctx, const NodeRef& node, FuzzedDataProvider& p
11621168
// are identical, this implies that for such nodes, the non-malleable
11631169
// satisfaction will also match the expected policy.
11641170
const auto is_key_satisfiable = [script_ctx](const CPubKey& pubkey) -> bool {
1165-
auto sig_ptr{TEST_DATA.GetSig(script_ctx, pubkey)};
1166-
return sig_ptr != nullptr && sig_ptr->second;
1171+
return TEST_DATA.HasPrivKey(script_ctx, pubkey);
11671172
};
11681173
bool satisfiable = node->IsSatisfiable([&](const Node& node) -> bool {
11691174
switch (node.fragment) {

0 commit comments

Comments
 (0)