MCPcopy Create free account
hub / github.com/ElementsProject/elements / ListCoinsTestingSetup

Class ListCoinsTestingSetup

src/wallet/test/wallet_tests.cpp:511–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511class ListCoinsTestingSetup : public TestChain100Setup
512{
513public:
514 ListCoinsTestingSetup()
515 {
516 CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
517 wallet = CreateSyncedWallet(*m_node.chain, m_node.chainman->ActiveChain(), m_args, coinbaseKey);
518 }
519
520 ~ListCoinsTestingSetup()
521 {
522 wallet.reset();
523 }
524
525 CWalletTx& AddTx(CRecipient recipient)
526 {
527 CTransactionRef tx;
528 CAmount fee;
529 int changePos = -1;
530 bilingual_str error;
531 CCoinControl dummy;
532 FeeCalculation fee_calc_out;
533 {
534 BOOST_CHECK(CreateTransaction(*wallet, {recipient}, tx, fee, changePos, error, dummy, fee_calc_out));
535 }
536 wallet->CommitTransaction(tx, {}, {});
537 CMutableTransaction blocktx;
538 {
539 LOCK(wallet->cs_wallet);
540 blocktx = CMutableTransaction(*wallet->mapWallet.at(tx->GetHash()).tx);
541 }
542 CreateAndProcessBlock({CMutableTransaction(blocktx)}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
543
544 LOCK(wallet->cs_wallet);
545 wallet->SetLastBlockProcessed(wallet->GetLastBlockHeight() + 1, m_node.chainman->ActiveChain().Tip()->GetBlockHash());
546 auto it = wallet->mapWallet.find(tx->GetHash());
547 BOOST_CHECK(it != wallet->mapWallet.end());
548 it->second.m_state = TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), /*position_in_block=*/1};
549 return it->second;
550 }
551
552 std::unique_ptr<CWallet> wallet;
553};
554
555BOOST_FIXTURE_TEST_CASE(ListCoinsTest, ListCoinsTestingSetup)
556{

Callers

nothing calls this directly

Calls 10

GetScriptForRawPubKeyFunction · 0.85
CommitTransactionMethod · 0.80
findMethod · 0.80
HeightMethod · 0.80
CMutableTransactionClass · 0.50
GetHashMethod · 0.45
GetPubKeyMethod · 0.45
GetBlockHashMethod · 0.45
TipMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected