aboutsummaryrefslogtreecommitdiff
path: root/src/test/util
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-03-30 09:32:35 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-03-30 10:42:45 +0200
commitfa4926cca68db2433e579d9b4a642248a9314673 (patch)
tree882ddae72fde111eb8c5785c872c46f6cba0f496 /src/test/util
parenteeee8f5be1d4ccfb7e237248be5c6bef45b0fbb8 (diff)
fuzz: [refactor] Use IsValidFlagCombination in signature_checker fuzz target
Can be reviewed with --color-moved=dimmed-zebra
Diffstat (limited to 'src/test/util')
-rw-r--r--src/test/util/script.cpp13
-rw-r--r--src/test/util/script.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/src/test/util/script.cpp b/src/test/util/script.cpp
new file mode 100644
index 0000000000..a5852daa60
--- /dev/null
+++ b/src/test/util/script.cpp
@@ -0,0 +1,13 @@
+// Copyright (c) 2021 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <script/interpreter.h>
+#include <test/util/script.h>
+
+bool IsValidFlagCombination(unsigned flags)
+{
+ if (flags & SCRIPT_VERIFY_CLEANSTACK && ~flags & (SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS)) return false;
+ if (flags & SCRIPT_VERIFY_WITNESS && ~flags & SCRIPT_VERIFY_P2SH) return false;
+ return true;
+}
diff --git a/src/test/util/script.h b/src/test/util/script.h
index abd14c2067..428b3e10b3 100644
--- a/src/test/util/script.h
+++ b/src/test/util/script.h
@@ -18,4 +18,7 @@ static const CScript P2WSH_OP_TRUE{
return hash;
}())};
+/** Flags that are not forbidden by an assert in script validation */
+bool IsValidFlagCombination(unsigned flags);
+
#endif // BITCOIN_TEST_UTIL_SCRIPT_H