Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
coincontrol.cpp
Go to the documentation of this file.
1// Copyright (c) 2022-present 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
6#include <test/fuzz/fuzz.h>
7#include <test/fuzz/util.h>
10#include <wallet/test/util.h>
11
12namespace wallet {
13namespace {
14
16
18{
19 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
20 g_setup = testing_setup.get();
21}
22
24{
25 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
26 const auto& node = g_setup->m_node;
27 ArgsManager& args = *node.args;
28
29 // for GetBoolArg to return true sometimes
30 args.ForceSetArg("-avoidpartialspends", fuzzed_data_provider.ConsumeBool()?"1":"0");
31
32 CCoinControl coin_control;
34
36 {
39 [&] {
41 if (!optional_out_point) {
42 return;
43 }
45 },
46 [&] {
47 (void)coin_control.HasSelected();
48 },
49 [&] {
50 (void)coin_control.IsSelected(out_point);
51 },
52 [&] {
53 (void)coin_control.IsExternalSelected(out_point);
54 },
55 [&] {
56 (void)coin_control.GetExternalOutput(out_point);
57 },
58 [&] {
60 },
61 [&] {
63 (void)coin_control.Select(out_point).SetTxOut(tx_out);
64 },
65 [&] {
66 (void)coin_control.UnSelect(out_point);
67 },
68 [&] {
69 (void)coin_control.UnSelectAll();
70 },
71 [&] {
72 (void)coin_control.ListSelected();
73 },
74 [&] {
76 (void)coin_control.SetInputWeight(out_point, weight);
77 },
78 [&] {
79 (void)coin_control.GetInputWeight(out_point);
80 });
81 }
82}
83} // namespace
84} // namespace wallet
ArgsManager & args
Definition bitcoind.cpp:277
const TestingSetup * g_setup
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition args.cpp:571
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition transaction.h:29
An output of a transaction.
#define FUZZ_TARGET(...)
Definition fuzz.h:35
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Definition fuzz.h:22
node::NodeContext m_node
Testing setup that configures a complete environment.
CScript ConsumeScript(FuzzedDataProvider &fuzzed_data_provider, const bool maybe_p2wsh) noexcept
Definition util.cpp:98
CAmount ConsumeMoney(FuzzedDataProvider &fuzzed_data_provider, const std::optional< CAmount > &max) noexcept
Definition util.cpp:29
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
Definition util.h:35
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:73
FuzzedDataProvider & fuzzed_data_provider
Definition fees.cpp:38