aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/tx_in.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2019-10-09 13:07:31 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2019-12-06 09:10:31 +0000
commitce935292c041162e160d95fc6afeda3dceded2cf (patch)
treee880e8d2f3eae3d74dde6b151f72440dd5b80b8e /src/test/fuzz/tx_in.cpp
parentcb11324a63ef10475bfc4d8e45148d5ae6f3e71e (diff)
tests: Add fuzzing harness for various CTxIn related functions
Diffstat (limited to 'src/test/fuzz/tx_in.cpp')
-rw-r--r--src/test/fuzz/tx_in.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/fuzz/tx_in.cpp b/src/test/fuzz/tx_in.cpp
new file mode 100644
index 0000000000..8e116537d1
--- /dev/null
+++ b/src/test/fuzz/tx_in.cpp
@@ -0,0 +1,33 @@
+// 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>
+
+#include <cassert>
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
+ CTxIn tx_in;
+ try {
+ int version;
+ ds >> version;
+ ds.SetVersion(version);
+ ds >> tx_in;
+ } catch (const std::ios_base::failure&) {
+ return;
+ }
+
+ (void)GetTransactionInputWeight(tx_in);
+ (void)GetVirtualTransactionInputSize(tx_in);
+ (void)RecursiveDynamicUsage(tx_in);
+
+ (void)tx_in.ToString();
+}