Line data Source code
1 : // Copyright (c) 2019-2022 The Bitcoin Core developers 2 : // Distributed under the MIT software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #include <chainparams.h> 6 : #include <consensus/consensus.h> 7 : #include <core_io.h> 8 : #include <policy/policy.h> 9 : #include <script/script.h> 10 : #include <test/fuzz/FuzzedDataProvider.h> 11 : #include <test/fuzz/fuzz.h> 12 : #include <test/fuzz/util.h> 13 : #include <univalue.h> 14 : #include <util/chaintype.h> 15 : 16 0 : void initialize_script_format() 17 : { 18 0 : SelectParams(ChainType::REGTEST); 19 0 : } 20 : 21 4 : FUZZ_TARGET(script_format, .init = initialize_script_format) 22 : { 23 0 : FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); 24 0 : const CScript script{ConsumeScript(fuzzed_data_provider)}; 25 0 : if (script.size() > MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR) { 26 0 : return; 27 : } 28 : 29 0 : (void)FormatScript(script); 30 0 : (void)ScriptToAsmStr(script, /*fAttemptSighashDecode=*/fuzzed_data_provider.ConsumeBool()); 31 : 32 0 : UniValue o1(UniValue::VOBJ); 33 0 : ScriptToUniv(script, /*out=*/o1, /*include_hex=*/fuzzed_data_provider.ConsumeBool(), /*include_address=*/fuzzed_data_provider.ConsumeBool()); 34 0 : }