diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-01-15 21:53:25 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-03-07 14:35:49 +0000 |
commit | 5fc10f3cb5991684f10c589fa5ccf2d694ffa32a (patch) | |
tree | 58d6343a35bee31fb8eaf1e1bbaefd1fcd9f6d83 /src/test/fuzz | |
parent | 1d324ce92229f3557f6bb38a63873dea1677240e (diff) | |
download | bitcoin-5fc10f3cb5991684f10c589fa5ccf2d694ffa32a.tar.xz |
tests: Fuzz additional functions in the transaction fuzzing harness
Diffstat (limited to 'src/test/fuzz')
-rw-r--r-- | src/test/fuzz/transaction.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/fuzz/transaction.cpp b/src/test/fuzz/transaction.cpp index fefafda36b..1ec69cc23d 100644 --- a/src/test/fuzz/transaction.cpp +++ b/src/test/fuzz/transaction.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <chainparams.h> #include <coins.h> #include <consensus/tx_check.h> #include <consensus/tx_verify.h> @@ -13,12 +14,18 @@ #include <primitives/transaction.h> #include <streams.h> #include <test/fuzz/fuzz.h> +#include <univalue.h> #include <util/rbf.h> #include <validation.h> #include <version.h> #include <cassert> +void initialize() +{ + SelectParams(CBaseChainParams::REGTEST); +} + void test_one_input(const std::vector<uint8_t>& buffer) { CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION); @@ -85,4 +92,21 @@ void test_one_input(const std::vector<uint8_t>& buffer) (void)IsStandardTx(tx, reason); (void)RecursiveDynamicUsage(tx); (void)SignalsOptInRBF(tx); + + CCoinsView coins_view; + const CCoinsViewCache coins_view_cache(&coins_view); + (void)AreInputsStandard(tx, coins_view_cache); + (void)IsWitnessStandard(tx, coins_view_cache); + + UniValue u(UniValue::VOBJ); + // ValueFromAmount(i) not defined when i == std::numeric_limits<int64_t>::min() + bool skip_tx_to_univ = false; + for (const CTxOut& txout : tx.vout) { + if (txout.nValue == std::numeric_limits<int64_t>::min()) { + skip_tx_to_univ = true; + } + } + if (!skip_tx_to_univ) { + TxToUniv(tx, /* hashBlock */ {}, u); + } } |