aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2023-02-24 16:47:51 -0500
committerPieter Wuille <pieter@wuille.net>2023-02-28 09:22:42 -0500
commite1f30414c6b9434048e089ccc3ec4f475f980c60 (patch)
treee77fe4e4b8bece3c011b6eab9c428a29fb28add2 /src/test
parent5abb0f5ac37e8a17072d5989a025227035fdc7e6 (diff)
downloadbitcoin-e1f30414c6b9434048e089ccc3ec4f475f980c60.tar.xz
Simplify miniscript fuzzer NodeInfo struct
Since we now keep track of all expected child node types (even if rudimentary) in both miniscript_stable and miniscript_smart fuzzers, there is no need anymore for the former shortcut NodeInfo constructors without sub types.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/fuzz/miniscript.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/test/fuzz/miniscript.cpp b/src/test/fuzz/miniscript.cpp
index 3d210aa7a6..1e11c3323c 100644
--- a/src/test/fuzz/miniscript.cpp
+++ b/src/test/fuzz/miniscript.cpp
@@ -261,8 +261,6 @@ template<typename... Args> NodeRef MakeNodeRef(Args&&... args) {
struct NodeInfo {
//! The type of this node
Fragment fragment;
- //! Number of subs of this node
- uint8_t n_subs;
//! The timelock value for older() and after(), the threshold value for multi() and thresh()
uint32_t k;
//! Keys for this node, if it has some
@@ -272,15 +270,13 @@ struct NodeInfo {
//! The type requirements for the children of this node.
std::vector<Type> subtypes;
- NodeInfo(Fragment frag): fragment(frag), n_subs(0), k(0) {}
- NodeInfo(Fragment frag, CPubKey key): fragment(frag), n_subs(0), k(0), keys({key}) {}
- NodeInfo(Fragment frag, uint32_t _k): fragment(frag), n_subs(0), k(_k) {}
- NodeInfo(Fragment frag, std::vector<unsigned char> h): fragment(frag), n_subs(0), k(0), hash(std::move(h)) {}
- NodeInfo(uint8_t subs, Fragment frag): fragment(frag), n_subs(subs), k(0), subtypes(subs, ""_mst) {}
- NodeInfo(uint8_t subs, Fragment frag, uint32_t _k): fragment(frag), n_subs(subs), k(_k), subtypes(subs, ""_mst) {}
- NodeInfo(std::vector<Type> subt, Fragment frag): fragment(frag), n_subs(subt.size()), k(0), subtypes(std::move(subt)) {}
- NodeInfo(std::vector<Type> subt, Fragment frag, uint32_t _k): fragment(frag), n_subs(subt.size()), k(_k), subtypes(std::move(subt)) {}
- NodeInfo(Fragment frag, uint32_t _k, std::vector<CPubKey> _keys): fragment(frag), n_subs(0), k(_k), keys(std::move(_keys)) {}
+ NodeInfo(Fragment frag): fragment(frag), k(0) {}
+ NodeInfo(Fragment frag, CPubKey key): fragment(frag), k(0), keys({key}) {}
+ NodeInfo(Fragment frag, uint32_t _k): fragment(frag), k(_k) {}
+ NodeInfo(Fragment frag, std::vector<unsigned char> h): fragment(frag), k(0), hash(std::move(h)) {}
+ NodeInfo(std::vector<Type> subt, Fragment frag): fragment(frag), k(0), subtypes(std::move(subt)) {}
+ NodeInfo(std::vector<Type> subt, Fragment frag, uint32_t _k): fragment(frag), k(_k), subtypes(std::move(subt)) {}
+ NodeInfo(Fragment frag, uint32_t _k, std::vector<CPubKey> _keys): fragment(frag), k(_k), keys(std::move(_keys)) {}
};
/** Pick an index in a collection from a single byte in the fuzzer's output. */
@@ -795,11 +791,11 @@ NodeRef GenNode(F ConsumeNode, Type root_type, bool strict_valid = false) {
NodeInfo& info = *todo.back().second;
// Gather children from the back of stack.
std::vector<NodeRef> sub;
- sub.reserve(info.n_subs);
- for (size_t i = 0; i < info.n_subs; ++i) {
- sub.push_back(std::move(*(stack.end() - info.n_subs + i)));
+ sub.reserve(info.subtypes.size());
+ for (size_t i = 0; i < info.subtypes.size(); ++i) {
+ sub.push_back(std::move(*(stack.end() - info.subtypes.size() + i)));
}
- stack.erase(stack.end() - info.n_subs, stack.end());
+ stack.erase(stack.end() - info.subtypes.size(), stack.end());
// Construct new NodeRef.
NodeRef node;
if (info.keys.empty()) {