MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ListCoinsTestingSetup

Class ListCoinsTestingSetup

src/wallet/test/wallet_tests.cpp:382–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382class ListCoinsTestingSetup : public TestChain100Setup
383{
384public:
385 ListCoinsTestingSetup()
386 {
387 CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
388 wallet = CreateSyncedWallet(*m_node.chain, WITH_LOCK(Assert(m_node.chainman)->GetMutex(), return m_node.chainman->ActiveChain()), coinbaseKey);
389 }
390
391 ~ListCoinsTestingSetup()
392 {
393 wallet.reset();
394 }
395
396 CWalletTx& AddTx(CRecipient recipient)
397 {
398 CTransactionRef tx;
399 CCoinControl dummy;
400 {
401 auto res = CreateTransaction(*wallet, {recipient}, /*change_pos=*/std::nullopt, dummy);
402 BOOST_CHECK(res);
403 tx = res->tx;
404 }
405 wallet->CommitTransaction(tx, {}, {});
406 CMutableTransaction blocktx;
407 {
408 LOCK(wallet->cs_wallet);
409 blocktx = CMutableTransaction(*wallet->mapWallet.at(tx->GetHash()).tx);
410 }
411 CreateAndProcessBlock({CMutableTransaction(blocktx)}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
412
413 LOCK(wallet->cs_wallet);
414 LOCK(Assert(m_node.chainman)->GetMutex());
415 wallet->SetLastBlockProcessed(wallet->GetLastBlockHeight() + 1, m_node.chainman->ActiveChain().Tip()->GetBlockHash());
416 auto it = wallet->mapWallet.find(tx->GetHash());
417 BOOST_CHECK(it != wallet->mapWallet.end());
418 it->second.m_state = TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), /*index=*/1};
419 return it->second;
420 }
421
422 std::unique_ptr<CWallet> wallet;
423};
424
425BOOST_FIXTURE_TEST_CASE(ListCoinsTest, ListCoinsTestingSetup)
426{

Callers

nothing calls this directly

Calls 13

CreateTransactionFunction · 0.85
GetScriptForRawPubKeyFunction · 0.85
CommitTransactionMethod · 0.80
SetLastBlockProcessedMethod · 0.80
findMethod · 0.80
HeightMethod · 0.80
CMutableTransactionClass · 0.50
atMethod · 0.45
GetHashMethod · 0.45
GetPubKeyMethod · 0.45
GetBlockHashMethod · 0.45
TipMethod · 0.45

Tested by

no test coverage detected