Changeset View
Changeset View
Standalone View
Standalone View
src/test/fuzz/script.cpp
// Copyright (c) 2019 The Bitcoin Core developers | // Copyright (c) 2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <compressor.h> | #include <compressor.h> | ||||
#include <core_io.h> | #include <core_io.h> | ||||
#include <core_memusage.h> | #include <core_memusage.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <script/descriptor.h> | #include <script/descriptor.h> | ||||
#include <script/interpreter.h> | #include <script/interpreter.h> | ||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/script_error.h> | |||||
#include <script/sign.h> | #include <script/sign.h> | ||||
#include <script/signingprovider.h> | #include <script/signingprovider.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <test/fuzz/FuzzedDataProvider.h> | #include <test/fuzz/FuzzedDataProvider.h> | ||||
#include <test/fuzz/fuzz.h> | #include <test/fuzz/fuzz.h> | ||||
#include <test/fuzz/util.h> | #include <test/fuzz/util.h> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <algorithm> | |||||
#include <cassert> | |||||
#include <cstdint> | #include <cstdint> | ||||
#include <memory> | #include <memory> | ||||
#include <optional> | #include <optional> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
void initialize() { | void initialize() { | ||||
// Fuzzers using pubkey must hold an ECCVerifyHandle. | // Fuzzers using pubkey must hold an ECCVerifyHandle. | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | void test_one_input(const std::vector<uint8_t> &buffer) { | ||||
} | } | ||||
const std::optional<CScript> other_script = | const std::optional<CScript> other_script = | ||||
ConsumeDeserializable<CScript>(fuzzed_data_provider); | ConsumeDeserializable<CScript>(fuzzed_data_provider); | ||||
if (other_script) { | if (other_script) { | ||||
CScript script_mut{script}; | CScript script_mut{script}; | ||||
(void)FindAndDelete(script_mut, *other_script); | (void)FindAndDelete(script_mut, *other_script); | ||||
} | } | ||||
(void)GetOpName(ConsumeOpcodeType(fuzzed_data_provider)); | |||||
(void)ScriptErrorString(static_cast<ScriptError>( | |||||
fuzzed_data_provider.ConsumeIntegralInRange<int>( | |||||
0, static_cast<int>(ScriptError::ERROR_COUNT)))); | |||||
{ | |||||
const std::vector<uint8_t> bytes = | |||||
ConsumeRandomLengthByteVector(fuzzed_data_provider); | |||||
CScript append_script{bytes.begin(), bytes.end()}; | |||||
append_script << fuzzed_data_provider.ConsumeIntegral<int64_t>(); | |||||
append_script << ConsumeOpcodeType(fuzzed_data_provider); | |||||
append_script << CScriptNum{ | |||||
fuzzed_data_provider.ConsumeIntegral<int64_t>()}; | |||||
append_script << ConsumeRandomLengthByteVector(fuzzed_data_provider); | |||||
} | |||||
{ | |||||
const CTxDestination tx_destination_1 = | |||||
ConsumeTxDestination(fuzzed_data_provider); | |||||
const CTxDestination tx_destination_2 = | |||||
ConsumeTxDestination(fuzzed_data_provider); | |||||
(void)(tx_destination_1 == tx_destination_2); | |||||
(void)(tx_destination_1 < tx_destination_2); | |||||
} | |||||
} | } |