Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
wallet
test
wallet_rpc_tests.cpp
Go to the documentation of this file.
1
// Copyright (c) 2025-present 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 <
rpc/request.h
>
6
#include <
test/util/setup_common.h
>
7
#include <
univalue.h
>
8
#include <
wallet/rpc/util.h
>
9
10
#include <boost/test/unit_test.hpp>
11
12
#include <optional>
13
#include <string>
14
15
namespace
wallet
{
16
static
std::string
TestWalletName
(
const
std::string& endpoint, std::optional<std::string> parameter = std::nullopt)
17
{
18
JSONRPCRequest
req;
19
req.
URI
= endpoint;
20
return
EnsureUniqueWalletName
(req, parameter);
21
}
22
23
BOOST_FIXTURE_TEST_SUITE
(wallet_rpc_tests,
BasicTestingSetup
)
24
25
BOOST_AUTO_TEST_CASE
(ensure_unique_wallet_name)
26
{
27
// EnsureUniqueWalletName should only return if exactly one unique wallet name is provided
28
BOOST_CHECK_EQUAL
(
TestWalletName
(
"/wallet/foo"
),
"foo"
);
29
BOOST_CHECK_EQUAL
(
TestWalletName
(
"/wallet/foo"
,
"foo"
),
"foo"
);
30
BOOST_CHECK_EQUAL
(
TestWalletName
(
"/"
,
"foo"
),
"foo"
);
31
BOOST_CHECK_EQUAL
(
TestWalletName
(
"/bar"
,
"foo"
),
"foo"
);
32
33
BOOST_CHECK_THROW
(
TestWalletName
(
"/"
),
UniValue
);
34
BOOST_CHECK_THROW
(
TestWalletName
(
"/foo"
),
UniValue
);
35
BOOST_CHECK_THROW
(
TestWalletName
(
"/wallet/foo"
,
"bar"
),
UniValue
);
36
BOOST_CHECK_THROW
(
TestWalletName
(
"/wallet/foo"
,
"foobar"
),
UniValue
);
37
BOOST_CHECK_THROW
(
TestWalletName
(
"/wallet/foobar"
,
"foo"
),
UniValue
);
38
}
39
40
BOOST_AUTO_TEST_SUITE_END
()
41
}
// namespace wallet
JSONRPCRequest
Definition
request.h:53
JSONRPCRequest::URI
std::string URI
Definition
request.h:59
UniValue
Definition
univalue.h:22
BOOST_FIXTURE_TEST_SUITE
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
wallet
Definition
wallet_balance.cpp:26
wallet::TestWalletName
static std::string TestWalletName(const std::string &endpoint, std::optional< std::string > parameter=std::nullopt)
Definition
wallet_rpc_tests.cpp:16
wallet::EnsureUniqueWalletName
std::string EnsureUniqueWalletName(const JSONRPCRequest &request, std::optional< std::string_view > wallet_name)
Ensures that a wallet name is specified across the endpoint and wallet_name.
Definition
util.cpp:33
wallet::BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(bnb_test)
Definition
coinselection_tests.cpp:123
BOOST_CHECK_THROW
#define BOOST_CHECK_THROW(stmt, excMatch)
Definition
object.cpp:18
BOOST_CHECK_EQUAL
#define BOOST_CHECK_EQUAL(v1, v2)
Definition
object.cpp:17
request.h
setup_common.h
BasicTestingSetup
Basic testing setup.
Definition
setup_common.h:64
univalue.h
util.h
Generated on
for Bitcoin Core by
1.17.0