2019-12-19 16:26:42 -03:00
|
|
|
// 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>
|
|
|
|
|
|
|
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
|
|
|
{
|
2020-06-24 09:48:26 -04:00
|
|
|
const std::string tx_hex = HexStr(buffer);
|
2019-12-19 16:26:42 -03:00
|
|
|
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);
|
2020-11-04 20:06:25 -03:00
|
|
|
CMutableTransaction no_witness_mtx;
|
|
|
|
const bool result_try_no_witness = DecodeHexTx(no_witness_mtx, tx_hex, true, false);
|
2019-12-19 16:26:42 -03:00
|
|
|
assert(!result_none);
|
|
|
|
if (result_try_witness_and_maybe_no_witness) {
|
|
|
|
assert(result_try_no_witness || result_try_witness);
|
|
|
|
}
|
2020-11-02 19:21:03 -03:00
|
|
|
if (result_try_no_witness) {
|
2020-11-04 20:06:25 -03:00
|
|
|
assert(!no_witness_mtx.HasWitness());
|
2019-12-19 16:26:42 -03:00
|
|
|
assert(result_try_witness_and_maybe_no_witness);
|
|
|
|
}
|
|
|
|
}
|