aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2019-10-09 13:14:52 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2019-12-06 09:10:44 +0000
commite75ecb91c730115290e1201371492c2cd334e9b4 (patch)
treeb4ff0f82e847e8c9bc14fd60d4c0c9529b7e7735 /src/test
parentce935292c041162e160d95fc6afeda3dceded2cf (diff)
downloadbitcoin-e75ecb91c730115290e1201371492c2cd334e9b4.tar.xz
tests: Add fuzzing harness for various CTxOut related functions
Diffstat (limited to 'src/test')
-rw-r--r--src/test/fuzz/tx_out.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/fuzz/tx_out.cpp b/src/test/fuzz/tx_out.cpp
new file mode 100644
index 0000000000..aa1338d5ba
--- /dev/null
+++ b/src/test/fuzz/tx_out.cpp
@@ -0,0 +1,35 @@
+// Copyright (c) 2019 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 <consensus/validation.h>
+#include <core_memusage.h>
+#include <policy/policy.h>
+#include <primitives/transaction.h>
+#include <streams.h>
+#include <test/fuzz/fuzz.h>
+#include <version.h>
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
+ CTxOut tx_out;
+ try {
+ int version;
+ ds >> version;
+ ds.SetVersion(version);
+ ds >> tx_out;
+ } catch (const std::ios_base::failure&) {
+ return;
+ }
+
+ const CFeeRate dust_relay_fee{DUST_RELAY_TX_FEE};
+ (void)GetDustThreshold(tx_out, dust_relay_fee);
+ (void)IsDust(tx_out, dust_relay_fee);
+ (void)RecursiveDynamicUsage(tx_out);
+
+ (void)tx_out.ToString();
+ (void)tx_out.IsNull();
+ tx_out.SetNull();
+ assert(tx_out.IsNull());
+}