blob: 249f5a3cda165a65559d96cd2d3f4eeb34fc6d38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// 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 <core_io.h>
#include <primitives/transaction.h>
#include <test/fuzz/fuzz.h>
#include <util/strencodings.h>
#include <cassert>
#include <cstdint>
#include <string>
#include <vector>
FUZZ_TARGET(decode_tx)
{
const std::string tx_hex = HexStr(buffer);
CMutableTransaction mtx;
const bool result_none = DecodeHexTx(mtx, tx_hex, false, false);
const bool result_try_witness = DecodeHexTx(mtx, tx_hex, false, true);
const bool result_try_witness_and_maybe_no_witness = DecodeHexTx(mtx, tx_hex, true, true);
CMutableTransaction no_witness_mtx;
const bool result_try_no_witness = DecodeHexTx(no_witness_mtx, tx_hex, true, false);
assert(!result_none);
if (result_try_witness_and_maybe_no_witness) {
assert(result_try_no_witness || result_try_witness);
}
if (result_try_no_witness) {
assert(!no_witness_mtx.HasWitness());
assert(result_try_witness_and_maybe_no_witness);
}
}
|