Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 6: [PATCH 06/17] feat(wallet): preserve Roots signing and spend controls on v31

src/wallet/test/wallet_tests.cpp

Before: src/wallet/test/wallet_tests.cpp · After: src/wallet/test/wallet_tests.cpp

File metadata
index b592c27badf4e0648481d5fde8f7adcc7bf67464..73e371b17072d5c17932925816f81f5c42e51fe0 100644

Download original patch · Release notes

Diff rows 1–50 of 50. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/wallet/test/wallet_tests.cpp CHANGED
@@ -2,6 +2,7 @@
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 <wallet/wallet.h>
6
 
7
  #include <cstdint>
@@ -449,6 +450,43 @@ BOOST_FIXTURE_TEST_CASE(ListCoinsTest, ListCoinsTestingSetup)
449
  BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U);
450
  }
451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  void TestCoinsResult(ListCoinsTest& context, OutputType out_type, CAmount amount,
453
  std::map<OutputType, size_t>& expected_coins_sizes)
454
  {
 
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 <interfaces/wallet.h>
6
  #include <wallet/wallet.h>
7
 
8
  #include <cstdint>
 
450
  BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U);
451
  }
452
 
453
+ BOOST_FIXTURE_TEST_CASE(coin_control_interface_facts, TestChain100Setup)
454
+ {
455
+ CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
456
+ auto wallet{std::shared_ptr<CWallet>{CreateSyncedWallet(*m_node.chain, WITH_LOCK(Assert(m_node.chainman)->GetMutex(), return m_node.chainman->ActiveChain()), coinbaseKey).release()}};
457
+ const CFeeRate feerate{1000};
458
+ const auto available_coins{WITH_LOCK(wallet->cs_wallet, return AvailableCoins(*wallet, /*coin_control=*/nullptr, feerate).All())};
459
+ BOOST_REQUIRE(!available_coins.empty());
460
+ const COutput coin{available_coins.front()};
461
+
462
+ WITH_LOCK(wallet->cs_wallet, wallet->LockCoin(coin.outpoint, /*persist=*/false));
463
+ WalletContext context;
464
+ context.chain = m_node.chain.get();
465
+ auto wallet_interface{interfaces::MakeWallet(context, wallet)};
466
+
467
+ const auto without_feerate{wallet_interface->getCoins({coin.outpoint})};
468
+ BOOST_REQUIRE_EQUAL(without_feerate.size(), 1U);
469
+ BOOST_CHECK(!without_feerate.front().effective_value);
470
+
471
+ const auto coins{wallet_interface->getCoins({coin.outpoint}, feerate)};
472
+ BOOST_REQUIRE_EQUAL(coins.size(), 1U);
473
+ const auto& info{coins.front()};
474
+ BOOST_CHECK(info.outpoint == coin.outpoint);
475
+ BOOST_CHECK_EQUAL(info.txout.nValue, coin.txout.nValue);
476
+ BOOST_CHECK_EQUAL(info.time, coin.time);
477
+ BOOST_CHECK_EQUAL(info.depth_in_main_chain, coin.depth);
478
+ BOOST_CHECK_EQUAL(info.input_bytes, coin.input_bytes);
479
+ BOOST_REQUIRE(info.effective_value);
480
+ BOOST_CHECK_EQUAL(*info.effective_value, coin.GetEffectiveValue());
481
+ BOOST_CHECK_EQUAL(info.ancestor_bump_fees, coin.ancestor_bump_fees);
482
+ BOOST_CHECK_EQUAL(info.is_spendable, WITH_LOCK(wallet->cs_wallet, return wallet->IsMine(coin.txout)));
483
+ BOOST_CHECK_EQUAL(info.is_solvable, coin.solvable);
484
+ BOOST_CHECK_EQUAL(info.is_safe, coin.safe);
485
+ BOOST_CHECK(info.is_locked);
486
+ BOOST_CHECK(!info.is_reused);
487
+ BOOST_CHECK(!info.is_spent);
488
+ }
489
+
490
  void TestCoinsResult(ListCoinsTest& context, OutputType out_type, CAmount amount,
491
  std::map<OutputType, size_t>& expected_coins_sizes)
492
  {