Skip to content

Commit 5fc10f3

Browse files
tests: Fuzz additional functions in the transaction fuzzing harness
1 parent 1d324ce commit 5fc10f3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/fuzz/transaction.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#include <chainparams.h>
56
#include <coins.h>
67
#include <consensus/tx_check.h>
78
#include <consensus/tx_verify.h>
@@ -13,12 +14,18 @@
1314
#include <primitives/transaction.h>
1415
#include <streams.h>
1516
#include <test/fuzz/fuzz.h>
17+
#include <univalue.h>
1618
#include <util/rbf.h>
1719
#include <validation.h>
1820
#include <version.h>
1921

2022
#include <cassert>
2123

24+
void initialize()
25+
{
26+
SelectParams(CBaseChainParams::REGTEST);
27+
}
28+
2229
void test_one_input(const std::vector<uint8_t>& buffer)
2330
{
2431
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
@@ -85,4 +92,21 @@ void test_one_input(const std::vector<uint8_t>& buffer)
8592
(void)IsStandardTx(tx, reason);
8693
(void)RecursiveDynamicUsage(tx);
8794
(void)SignalsOptInRBF(tx);
95+
96+
CCoinsView coins_view;
97+
const CCoinsViewCache coins_view_cache(&coins_view);
98+
(void)AreInputsStandard(tx, coins_view_cache);
99+
(void)IsWitnessStandard(tx, coins_view_cache);
100+
101+
UniValue u(UniValue::VOBJ);
102+
// ValueFromAmount(i) not defined when i == std::numeric_limits<int64_t>::min()
103+
bool skip_tx_to_univ = false;
104+
for (const CTxOut& txout : tx.vout) {
105+
if (txout.nValue == std::numeric_limits<int64_t>::min()) {
106+
skip_tx_to_univ = true;
107+
}
108+
}
109+
if (!skip_tx_to_univ) {
110+
TxToUniv(tx, /* hashBlock */ {}, u);
111+
}
88112
}

0 commit comments

Comments
 (0)