1 // Copyright (c) 2020 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 <rpc/util.h>
6 #include <test/fuzz/FuzzedDataProvider.h>
7 #include <test/fuzz/fuzz.h>
8 #include <test/fuzz/util.h>
9 #include <util/error.h>
10 #include <util/translation.h>
11 
12 #include <cstdint>
13 #include <vector>
14 
15 // The fuzzing kitchen sink: Fuzzing harness for functions that need to be
16 // fuzzed but a.) don't belong in any existing fuzzing harness file, and
17 // b.) are not important enough to warrant their own fuzzing harness file.
test_one_input(const std::vector<uint8_t> & buffer)18 void test_one_input(const std::vector<uint8_t>& buffer)
19 {
20     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
21 
22     const TransactionError transaction_error = fuzzed_data_provider.PickValueInArray<TransactionError>({TransactionError::OK, TransactionError::MISSING_INPUTS, TransactionError::ALREADY_IN_CHAIN, TransactionError::P2P_DISABLED, TransactionError::MEMPOOL_REJECTED, TransactionError::MEMPOOL_ERROR, TransactionError::INVALID_PSBT, TransactionError::PSBT_MISMATCH, TransactionError::SIGHASH_MISMATCH, TransactionError::MAX_FEE_EXCEEDED});
23     (void)JSONRPCTransactionError(transaction_error);
24     (void)RPCErrorFromTransactionError(transaction_error);
25     (void)TransactionErrorString(transaction_error);
26 }
27