In commit “test: Group values and states in tests into CoinEntry wrappers” (553db5dec1334ed5e8e07e34306f16de9afc22bb)
Review note: It’s not really easy to verify by looking at code that new and old test cases are equivalent, but an approach that worked for me was to add extra prints showing the test cases, and then diff the output from test_bitcoin -t coins_tests
before and after this commit, and confirm there are were no changes. My change used to test this was:
0--- a/src/test/coins_tests.cpp
1+++ b/src/test/coins_tests.cpp
2@@ -286,6 +286,7 @@ void SimulationTest(CCoinsView* base, bool fake_best_block)
3 // Run the above simulation for multiple base types.
4 BOOST_FIXTURE_TEST_CASE(coins_cache_simulation_test, CacheTest)
5 {
6+ if ((1)) return;
7 CCoinsViewTest base{m_rng};
8 SimulationTest(&base, false);
9
10@@ -318,6 +319,7 @@ UtxoData::iterator FindRandomFrom(const std::set<COutPoint> &utxoSet) {
11 // has the expected effect (the other duplicate is overwritten at all cache levels)
12 BOOST_FIXTURE_TEST_CASE(updatecoins_simulation_test, UpdateTest)
13 {
14+ if ((1)) return;
15 SeedRandomForTest(SeedRand::ZEROS);
16
17 bool spent_a_duplicate_coinbase = false;
18@@ -572,7 +574,7 @@ struct CoinEntry {
19 CoinEntry(CAmount v, char s) : value(v), flags(s) {}
20
21 bool operator==(const CoinEntry& o) const = default;
22- friend std::ostream& operator<<(std::ostream& os, const CoinEntry& e) { return os << e.value << e.flags; }
23+ friend std::ostream& operator<<(std::ostream& os, const CoinEntry& e) { return os << e.value << " " << int{e.flags}; }
24
25 constexpr bool IsDirty() const { return flags & DIRTY; }
26 constexpr bool IsFresh() const { return flags & FRESH; }
27@@ -671,6 +673,7 @@ public:
28
29 static void CheckAccessCoin(CAmount base_value, const CoinEntry& cache_coin, const CoinEntry& expected)
30 {
31+ tfm::format(std::cout, "CheckAccessCoin(%s, %s, %s)\n", base_value, cache_coin, expected);
32 SingleEntryCacheTest test(base_value, cache_coin);
33 test.cache.AccessCoin(OUTPOINT);
34 test.cache.SelfTest(/*sanity_check=*/false);
35@@ -717,6 +720,7 @@ BOOST_AUTO_TEST_CASE(ccoins_access)
36
37 static void CheckSpendCoins(CAmount base_value, const CoinEntry& cache_coin, const CoinEntry& expected)
38 {
39+ tfm::format(std::cout, "CheckSpendCoins(%s, %s, %s)\n", base_value, cache_coin, expected);
40 SingleEntryCacheTest test(base_value, cache_coin);
41 test.cache.SpendCoin(OUTPOINT);
42 test.cache.SelfTest();
43@@ -763,6 +767,7 @@ BOOST_AUTO_TEST_CASE(ccoins_spend)
44
45 static void CheckAddCoin(CAmount base_value, CAmount modify_value, const CoinEntry& cache_coin, const CoinEntry& expected, bool coinbase)
46 {
47+ tfm::format(std::cout, "CheckAddCoin(%s, %s, %s, %s, %s)\n", base_value, modify_value, cache_coin, expected, coinbase);
48 try {
49 SingleEntryCacheTest test(base_value, cache_coin);
50 CTxOut output;
51@@ -809,6 +814,7 @@ BOOST_AUTO_TEST_CASE(ccoins_add)
52
53 void CheckWriteCoins(const CoinEntry& parent, const CoinEntry& child, const CoinEntry& expected)
54 {
55+ tfm::format(std::cout, "CheckWriteCoins(%s, %s, %s)\n", parent, child, expected);
56 try {
57 SingleEntryCacheTest test(ABSENT, parent);
58 WriteCoinsViewEntry(test.cache, child);