Bitcoin Core  0.20.99
P2P Digital Currency
Classes | Functions
wallet_tests.cpp File Reference
#include <wallet/wallet.h>
#include <future>
#include <memory>
#include <stdint.h>
#include <vector>
#include <interfaces/chain.h>
#include <node/context.h>
#include <policy/policy.h>
#include <rpc/server.h>
#include <test/util/logging.h>
#include <test/util/setup_common.h>
#include <util/ref.h>
#include <util/translation.h>
#include <validation.h>
#include <wallet/coincontrol.h>
#include <wallet/test/wallet_test_fixture.h>
#include <boost/test/unit_test.hpp>
#include <univalue.h>
Include dependency graph for wallet_tests.cpp:

Go to the source code of this file.

Classes

class  ListCoinsTestingSetup
 

Functions

RPCHelpMan importmulti ()
 
RPCHelpMan dumpwallet ()
 
RPCHelpMan importwallet ()
 
static std::shared_ptr< CWalletTestLoadWallet (interfaces::Chain &chain)
 
static void TestUnloadWallet (std::shared_ptr< CWallet > &&wallet)
 
static CMutableTransaction TestSimpleSpend (const CTransaction &from, uint32_t index, const CKey &key, const CScript &pubkey)
 
static void AddKey (CWallet &wallet, const CKey &key)
 
 BOOST_FIXTURE_TEST_CASE (scan_for_wallet_transactions, TestChain100Setup)
 
 BOOST_FIXTURE_TEST_CASE (importmulti_rescan, TestChain100Setup)
 
 BOOST_FIXTURE_TEST_CASE (importwallet_rescan, TestChain100Setup)
 
 BOOST_FIXTURE_TEST_CASE (coin_mark_dirty_immature_credit, TestChain100Setup)
 
static int64_t AddTx (ChainstateManager &chainman, CWallet &wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime)
 
 BOOST_AUTO_TEST_CASE (ComputeTimeSmart)
 
 BOOST_AUTO_TEST_CASE (LoadReceiveRequests)
 
static void TestWatchOnlyPubKey (LegacyScriptPubKeyMan *spk_man, const CPubKey &add_pubkey)
 
static void PollutePubKey (CPubKey &pubkey)
 
 BOOST_AUTO_TEST_CASE (WatchOnlyPubKeys)
 
 BOOST_FIXTURE_TEST_CASE (ListCoins, ListCoinsTestingSetup)
 
 BOOST_FIXTURE_TEST_CASE (wallet_disableprivkeys, TestChain100Setup)
 
static size_t CalculateNestedKeyhashInputSize (bool use_max_sig)
 
 BOOST_FIXTURE_TEST_CASE (dummy_input_size_test, TestChain100Setup)
 
bool malformed_descriptor (std::ios_base::failure e)
 
 BOOST_FIXTURE_TEST_CASE (wallet_descriptor_test, BasicTestingSetup)
 
 BOOST_FIXTURE_TEST_CASE (CreateWalletFromFile, TestChain100Setup)
 Test CreateWalletFromFile function and its behavior handling potential race conditions if it's called the same time an incoming transaction shows up in the mempool or a new block. More...
 
 BOOST_FIXTURE_TEST_CASE (ZapSelectTx, TestChain100Setup)
 

Function Documentation

◆ AddKey()

static void AddKey ( CWallet wallet,
const CKey key 
)
static

Definition at line 71 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddTx()

static int64_t AddTx ( ChainstateManager chainman,
CWallet wallet,
uint32_t  lockTime,
int64_t  mockTime,
int64_t  blockTime 
)
static

Definition at line 344 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( ComputeTimeSmart  )

Definition at line 372 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( LoadReceiveRequests  )

Definition at line 398 of file wallet_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( WatchOnlyPubKeys  )

Definition at line 459 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [1/10]

BOOST_FIXTURE_TEST_CASE ( scan_for_wallet_transactions  ,
TestChain100Setup   
)

Definition at line 78 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [2/10]

BOOST_FIXTURE_TEST_CASE ( importmulti_rescan  ,
TestChain100Setup   
)

Definition at line 178 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [3/10]

BOOST_FIXTURE_TEST_CASE ( importwallet_rescan  ,
TestChain100Setup   
)

Definition at line 243 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [4/10]

BOOST_FIXTURE_TEST_CASE ( coin_mark_dirty_immature_credit  ,
TestChain100Setup   
)

Definition at line 318 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [5/10]

BOOST_FIXTURE_TEST_CASE ( ListCoins  ,
ListCoinsTestingSetup   
)

Definition at line 551 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [6/10]

BOOST_FIXTURE_TEST_CASE ( wallet_disableprivkeys  ,
TestChain100Setup   
)

Definition at line 612 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [7/10]

BOOST_FIXTURE_TEST_CASE ( dummy_input_size_test  ,
TestChain100Setup   
)

Definition at line 663 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [8/10]

BOOST_FIXTURE_TEST_CASE ( wallet_descriptor_test  ,
BasicTestingSetup   
)

Definition at line 675 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [9/10]

BOOST_FIXTURE_TEST_CASE ( CreateWalletFromFile  ,
TestChain100Setup   
)

Test CreateWalletFromFile function and its behavior handling potential race conditions if it's called the same time an incoming transaction shows up in the mempool or a new block.

It isn't possible to verify there aren't race condition in every case, so this test just checks two specific cases and ensures that timing of notifications in these cases doesn't prevent the wallet from detecting transactions.

In the first case, block and mempool transactions are created before the wallet is loaded, but notifications about these transactions are delayed until after it is loaded. The notifications are superfluous in this case, so the test verifies the transactions are detected before they arrive.

In the second case, block and mempool transactions are created after the wallet rescan and notifications are immediately synced, to verify the wallet must already have a handler in place for them, and there's no gap after rescanning where new transactions in new blocks could be lost.

Definition at line 708 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ BOOST_FIXTURE_TEST_CASE() [10/10]

BOOST_FIXTURE_TEST_CASE ( ZapSelectTx  ,
TestChain100Setup   
)

Definition at line 802 of file wallet_tests.cpp.

Here is the call graph for this function:

◆ CalculateNestedKeyhashInputSize()

static size_t CalculateNestedKeyhashInputSize ( bool  use_max_sig)
static

Definition at line 628 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dumpwallet()

RPCHelpMan dumpwallet ( )

Definition at line 715 of file rpcdump.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ importmulti()

RPCHelpMan importmulti ( )

Definition at line 1260 of file rpcdump.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ importwallet()

RPCHelpMan importwallet ( )

Definition at line 510 of file rpcdump.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ malformed_descriptor()

bool malformed_descriptor ( std::ios_base::failure  e)

Definition at line 669 of file wallet_tests.cpp.

Here is the caller graph for this function:

◆ PollutePubKey()

static void PollutePubKey ( CPubKey pubkey)
static

Definition at line 449 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestLoadWallet()

static std::shared_ptr<CWallet> TestLoadWallet ( interfaces::Chain chain)
static

Definition at line 38 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSimpleSpend()

static CMutableTransaction TestSimpleSpend ( const CTransaction from,
uint32_t  index,
const CKey key,
const CScript pubkey 
)
static

Definition at line 57 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestUnloadWallet()

static void TestUnloadWallet ( std::shared_ptr< CWallet > &&  wallet)
static

Definition at line 50 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestWatchOnlyPubKey()

static void TestWatchOnlyPubKey ( LegacyScriptPubKeyMan spk_man,
const CPubKey add_pubkey 
)
static

Definition at line 417 of file wallet_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: