Branch data Line data Source code
1 : : // Copyright (c) 2023-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 : :
5 : : #ifndef BITCOIN_TEST_UTIL_COINS_H
6 : : #define BITCOIN_TEST_UTIL_COINS_H
7 : :
8 : : #include <coins.h>
9 : : #include <crypto/hex_base.h>
10 : : #include <primitives/transaction.h>
11 : : #include <tinyformat.h>
12 : :
13 : : #include <ostream>
14 : :
15 : : class CCoinsViewCache;
16 : : class FastRandomContext;
17 : :
18 : : /**
19 : : * Create a Coin with DynamicMemoryUsage of 80 bytes and add it to the given view.
20 : : * @param[in,out] coins_view The coins view cache to add the new coin to.
21 : : * @returns the COutPoint of the created coin.
22 : : */
23 : : COutPoint AddTestCoin(FastRandomContext& rng, CCoinsViewCache& coins_view);
24 : :
25 : : //! Strict equality, including fields of spent coins
26 : 1070718 : inline bool operator==(const Coin& a, const Coin& b)
27 : : {
28 [ + - + - : 1070718 : return a.fCoinBase == b.fCoinBase && a.nHeight == b.nHeight && a.out == b.out;
- + ]
29 : : }
30 : :
31 : : //! Printed when a coin comparison fails
32 : 0 : inline std::ostream& operator<<(std::ostream& os, const Coin& coin)
33 : : {
34 : 0 : return os << strprintf("Coin(spent=%d, coinbase=%d, height=%d, value=%d, scriptPubKey=%s)",
35 [ # # # # ]: 0 : coin.IsSpent(), coin.fCoinBase, coin.nHeight, coin.out.nValue, HexStr(coin.out.scriptPubKey));
36 : : }
37 : :
38 : : #endif // BITCOIN_TEST_UTIL_COINS_H
|