| 380 | } |
| 381 | |
| 382 | class ListCoinsTestingSetup : public TestChain100Setup |
| 383 | { |
| 384 | public: |
| 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 | |
| 425 | BOOST_FIXTURE_TEST_CASE(ListCoinsTest, ListCoinsTestingSetup) |
| 426 | { |
nothing calls this directly
no test coverage detected