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) 2012-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 <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>12#include <boost/test/unit_test.hpp>14namespace wallet {15BOOST_FIXTURE_TEST_SUITE(walletdb_tests, BasicTestingSetup)17BOOST_AUTO_TEST_CASE(walletdb_readkeyvalue)18{19/**20* When ReadKeyValue() reads from either a "key" or "wkey" it first reads the DataStream into a21* CPrivKey or CWalletKey respectively and then reads a hash of the pubkey and privkey into a uint256.22* Wallets from 0.8 or before do not store the pubkey/privkey hash, trying to read the hash from old23* wallets throws an exception, for backwards compatibility this read is wrapped in a try block to24* silently fail. The test here makes sure the type of exception thrown from DataStream::read()25* matches the type we expect, otherwise we need to update the "key"/"wkey" exception type caught.26*/27DataStream ssValue{};28uint256 dummy;29BOOST_CHECK_THROW(ssValue >> dummy, std::ios_base::failure);30}32BOOST_AUTO_TEST_SUITE_END()33} // 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.