Bitcoin Core
28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
wallet
test
walletdb_tests.cpp
Go to the documentation of this file.
1
// Copyright (c) 2012-2021 The Bitcoin Core developers
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 <
test/util/setup_common.h
>
6
#include <
clientversion.h
>
7
#include <
streams.h
>
8
#include <
uint256.h
>
9
#include <
wallet/test/util.h
>
10
#include <
wallet/wallet.h
>
11
12
#include <boost/test/unit_test.hpp>
13
14
namespace
wallet
{
15
BOOST_FIXTURE_TEST_SUITE(walletdb_tests,
BasicTestingSetup
)
16
17
BOOST_AUTO_TEST_CASE
(walletdb_readkeyvalue)
18
{
27
DataStream
ssValue{};
28
uint256
dummy;
29
BOOST_CHECK_THROW
(ssValue >> dummy, std::ios_base::failure);
30
}
31
32
BOOST_AUTO_TEST_CASE
(walletdb_read_write_deadlock)
33
{
34
// Exercises a db read write operation that shouldn't deadlock.
35
for
(
const
DatabaseFormat
& db_format :
DATABASE_FORMATS
) {
36
// Context setup
37
DatabaseOptions
options;
38
options.
require_format
= db_format;
39
DatabaseStatus
status;
40
bilingual_str
error_string;
41
std::unique_ptr<WalletDatabase> db =
MakeDatabase
(m_path_root /
strprintf
(
"wallet_%d_.dat"
, db_format).c_str(), options, status, error_string);
42
BOOST_CHECK_EQUAL
(status,
DatabaseStatus::SUCCESS
);
43
44
std::shared_ptr<CWallet>
wallet
(
new
CWallet
(
m_node
.
chain
.get(),
""
, std::move(db)));
45
wallet
->m_keypool_size = 4;
46
47
// Create legacy spkm
48
LOCK
(
wallet
->cs_wallet);
49
auto
legacy_spkm =
wallet
->GetOrCreateLegacyScriptPubKeyMan();
50
BOOST_CHECK
(legacy_spkm->SetupGeneration(
true
));
51
wallet
->Flush();
52
53
// Now delete all records, which performs a read write operation.
54
BOOST_CHECK
(
wallet
->GetLegacyScriptPubKeyMan()->DeleteRecords());
55
}
56
}
57
58
BOOST_AUTO_TEST_SUITE_END
()
59
}
// namespace wallet
m_node
node::NodeContext m_node
Definition
bitcoin-gui.cpp:37
DataStream
Double ended buffer combining vector and stream-like interfaces.
Definition
streams.h:147
uint256
256-bit opaque blob.
Definition
uint256.h:178
wallet::CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition
wallet.h:300
clientversion.h
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
wallet
Definition
wallet_balance.cpp:18
wallet::MakeDatabase
std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
Definition
walletdb.cpp:1360
wallet::DatabaseFormat
DatabaseFormat
Definition
db.h:183
wallet::DATABASE_FORMATS
static const DatabaseFormat DATABASE_FORMATS[]
Definition
util.h:28
wallet::BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(bnb_search_test)
Definition
coinselector_tests.cpp:191
wallet::DatabaseStatus
DatabaseStatus
Definition
db.h:204
wallet::DatabaseStatus::SUCCESS
@ SUCCESS
BOOST_CHECK_THROW
#define BOOST_CHECK_THROW(stmt, excMatch)
Definition
object.cpp:19
BOOST_CHECK_EQUAL
#define BOOST_CHECK_EQUAL(v1, v2)
Definition
object.cpp:18
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition
object.cpp:17
setup_common.h
streams.h
BasicTestingSetup
Basic testing setup.
Definition
setup_common.h:64
bilingual_str
Bilingual messages:
Definition
translation.h:18
node::NodeContext::chain
std::unique_ptr< interfaces::Chain > chain
Definition
context.h:73
wallet::DatabaseOptions
Definition
db.h:190
wallet::DatabaseOptions::require_format
std::optional< DatabaseFormat > require_format
Definition
db.h:193
LOCK
#define LOCK(cs)
Definition
sync.h:257
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition
tinyformat.h:1161
uint256.h
util.h
wallet.h
Generated on Thu Oct 3 2024 09:20:15 for Bitcoin Core by
1.12.0