Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2025-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <rpc/request.h>6#include <test/util/setup_common.h>7#include <univalue.h>8#include <wallet/rpc/util.h>10#include <boost/test/unit_test.hpp>12#include <optional>13#include <string>15namespace wallet {16static std::string TestWalletName(const std::string& endpoint, std::optional<std::string> parameter = std::nullopt)17{18JSONRPCRequest req;19req.URI = endpoint;20return EnsureUniqueWalletName(req, parameter);21}23BOOST_FIXTURE_TEST_SUITE(wallet_rpc_tests, BasicTestingSetup)25BOOST_AUTO_TEST_CASE(ensure_unique_wallet_name)26{27// EnsureUniqueWalletName should only return if exactly one unique wallet name is provided28BOOST_CHECK_EQUAL(TestWalletName("/wallet/foo"), "foo");29BOOST_CHECK_EQUAL(TestWalletName("/wallet/foo", "foo"), "foo");30BOOST_CHECK_EQUAL(TestWalletName("/", "foo"), "foo");31BOOST_CHECK_EQUAL(TestWalletName("/bar", "foo"), "foo");33BOOST_CHECK_THROW(TestWalletName("/"), UniValue);34BOOST_CHECK_THROW(TestWalletName("/foo"), UniValue);35BOOST_CHECK_THROW(TestWalletName("/wallet/foo", "bar"), UniValue);36BOOST_CHECK_THROW(TestWalletName("/wallet/foo", "foobar"), UniValue);37BOOST_CHECK_THROW(TestWalletName("/wallet/foobar", "foo"), UniValue);38}40BOOST_AUTO_TEST_SUITE_END()41} // namespace wallet
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.