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