diff options
author | Jon Atack <jon@atack.com> | 2023-02-01 08:53:21 -0800 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2023-02-09 15:03:36 -0800 |
commit | 4275195606e6f42466d9a8ef766b3035833df4d5 (patch) | |
tree | 939b48de981fa3ab3d8a871e4cab2712503e647b /src/test/util/coins.cpp | |
parent | 9d92c3d7f42c18939a9a6aa1ee185f1c958360a0 (diff) |
De-duplicate add_coin methods to a test util helper
Diffstat (limited to 'src/test/util/coins.cpp')
-rw-r--r-- | src/test/util/coins.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/util/coins.cpp b/src/test/util/coins.cpp new file mode 100644 index 0000000000..9b6c5535c5 --- /dev/null +++ b/src/test/util/coins.cpp @@ -0,0 +1,27 @@ +// Copyright (c) 2023 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 <test/util/coins.h> + +#include <coins.h> +#include <primitives/transaction.h> +#include <script/script.h> +#include <test/util/random.h> +#include <uint256.h> + +#include <stdint.h> +#include <utility> + +COutPoint AddTestCoin(CCoinsViewCache& coins_view) +{ + Coin new_coin; + const uint256 txid{InsecureRand256()}; + COutPoint outpoint{txid, /*nIn=*/0}; + new_coin.nHeight = 1; + new_coin.out.nValue = InsecureRandMoneyAmount(); + new_coin.out.scriptPubKey.assign(uint32_t{56}, 1); + coins_view.AddCoin(outpoint, std::move(new_coin), /*possible_overwrite=*/false); + + return outpoint; +}; |