diff options
Diffstat (limited to 'src/wallet/test')
-rw-r--r-- | src/wallet/test/db_tests.cpp | 4 | ||||
-rw-r--r-- | src/wallet/test/fuzz/coinselection.cpp | 2 | ||||
-rw-r--r-- | src/wallet/test/fuzz/scriptpubkeyman.cpp | 5 | ||||
-rw-r--r-- | src/wallet/test/fuzz/wallet_bdb_parser.cpp | 17 | ||||
-rw-r--r-- | src/wallet/test/ismine_tests.cpp | 4 | ||||
-rw-r--r-- | src/wallet/test/util.h | 2 | ||||
-rw-r--r-- | src/wallet/test/wallet_tests.cpp | 15 |
7 files changed, 29 insertions, 20 deletions
diff --git a/src/wallet/test/db_tests.cpp b/src/wallet/test/db_tests.cpp index 2fac356263..ea32199497 100644 --- a/src/wallet/test/db_tests.cpp +++ b/src/wallet/test/db_tests.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <config/bitcoin-config.h> // IWYU pragma: keep +#include <bitcoin-build-config.h> // IWYU pragma: keep #include <boost/test/unit_test.hpp> @@ -28,7 +28,7 @@ inline std::ostream& operator<<(std::ostream& os, const std::pair<const Serializ { Span key{kv.first}, value{kv.second}; os << "(\"" << std::string_view{reinterpret_cast<const char*>(key.data()), key.size()} << "\", \"" - << std::string_view{reinterpret_cast<const char*>(key.data()), key.size()} << "\")"; + << std::string_view{reinterpret_cast<const char*>(value.data()), value.size()} << "\")"; return os; } diff --git a/src/wallet/test/fuzz/coinselection.cpp b/src/wallet/test/fuzz/coinselection.cpp index 209c87fd42..31fa00c0a2 100644 --- a/src/wallet/test/fuzz/coinselection.cpp +++ b/src/wallet/test/fuzz/coinselection.cpp @@ -252,7 +252,7 @@ FUZZ_TARGET(coinselection) GroupCoins(fuzzed_data_provider, utxo_pool, coin_params, /*positive_only=*/false, group_all); for (const OutputGroup& group : group_all) { - const CoinEligibilityFilter filter(fuzzed_data_provider.ConsumeIntegral<int>(), fuzzed_data_provider.ConsumeIntegral<int>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()); + const CoinEligibilityFilter filter{fuzzed_data_provider.ConsumeIntegral<int>(), fuzzed_data_provider.ConsumeIntegral<int>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()}; (void)group.EligibleForSpending(filter); } diff --git a/src/wallet/test/fuzz/scriptpubkeyman.cpp b/src/wallet/test/fuzz/scriptpubkeyman.cpp index 88f8c151e7..091d42f6cf 100644 --- a/src/wallet/test/fuzz/scriptpubkeyman.cpp +++ b/src/wallet/test/fuzz/scriptpubkeyman.cpp @@ -186,7 +186,10 @@ FUZZ_TARGET(scriptpubkeyman, .init = initialize_spkm) auto psbt{*opt_psbt}; const PrecomputedTransactionData txdata{PrecomputePSBTData(psbt)}; const int sighash_type{fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 150)}; - (void)spk_manager->FillPSBT(psbt, txdata, sighash_type, fuzzed_data_provider.ConsumeBool(), fuzzed_data_provider.ConsumeBool(), nullptr, fuzzed_data_provider.ConsumeBool()); + auto sign = fuzzed_data_provider.ConsumeBool(); + auto bip32derivs = fuzzed_data_provider.ConsumeBool(); + auto finalize = fuzzed_data_provider.ConsumeBool(); + (void)spk_manager->FillPSBT(psbt, txdata, sighash_type, sign, bip32derivs, nullptr, finalize); } ); } diff --git a/src/wallet/test/fuzz/wallet_bdb_parser.cpp b/src/wallet/test/fuzz/wallet_bdb_parser.cpp index 6fbd695fc5..6482b65d06 100644 --- a/src/wallet/test/fuzz/wallet_bdb_parser.cpp +++ b/src/wallet/test/fuzz/wallet_bdb_parser.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <config/bitcoin-config.h> // IWYU pragma: keep +#include <bitcoin-build-config.h> // IWYU pragma: keep #include <test/fuzz/FuzzedDataProvider.h> #include <test/fuzz/fuzz.h> #include <test/fuzz/util.h> @@ -18,6 +18,13 @@ #include <fstream> #include <iostream> +// There is an inconsistency in BDB on Windows. +// See: https://github.com/bitcoin/bitcoin/pull/26606#issuecomment-2322763212 +#undef USE_BDB_NON_MSVC +#if defined(USE_BDB) && !defined(_MSC_VER) +#define USE_BDB_NON_MSVC +#endif + using wallet::DatabaseOptions; using wallet::DatabaseStatus; @@ -50,7 +57,7 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser) } g_setup->m_args.ForceSetArg("-dumpfile", fs::PathToString(bdb_ro_dumpfile)); -#ifdef USE_BDB +#ifdef USE_BDB_NON_MSVC bool bdb_ro_err = false; bool bdb_ro_strict_err = false; #endif @@ -58,7 +65,7 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser) if (db) { assert(DumpWallet(g_setup->m_args, *db, error)); } else { -#ifdef USE_BDB +#ifdef USE_BDB_NON_MSVC bdb_ro_err = true; #endif if (error.original.starts_with("AutoFile::ignore: end of file") || @@ -90,7 +97,7 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser) error.original == "Subdatabase has an unexpected name" || error.original == "Unsupported BDB data file version number" || error.original == "BDB builtin encryption is not supported") { -#ifdef USE_BDB +#ifdef USE_BDB_NON_MSVC bdb_ro_strict_err = true; #endif } else { @@ -98,7 +105,7 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser) } } -#ifdef USE_BDB +#ifdef USE_BDB_NON_MSVC // Try opening with BDB fs::path bdb_dumpfile{g_setup->m_args.GetDataDirNet() / "fuzzed_dumpfile_bdb.dump"}; if (fs::exists(bdb_dumpfile)) { // Writing into an existing dump file will throw an exception diff --git a/src/wallet/test/ismine_tests.cpp b/src/wallet/test/ismine_tests.cpp index 8deab74fac..f6688ed30a 100644 --- a/src/wallet/test/ismine_tests.cpp +++ b/src/wallet/test/ismine_tests.cpp @@ -684,7 +684,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard) BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0])); scriptPubKey.clear(); - scriptPubKey << OP_0 << "aabb"_hex_v_u8; + scriptPubKey << OP_0 << "aabb"_hex; result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey); BOOST_CHECK_EQUAL(result, ISMINE_NO); @@ -699,7 +699,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard) BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0])); scriptPubKey.clear(); - scriptPubKey << OP_16 << "aabb"_hex_v_u8; + scriptPubKey << OP_16 << "aabb"_hex; result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey); BOOST_CHECK_EQUAL(result, ISMINE_NO); diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h index fc7674e961..ba12f5f6bf 100644 --- a/src/wallet/test/util.h +++ b/src/wallet/test/util.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_WALLET_TEST_UTIL_H #define BITCOIN_WALLET_TEST_UTIL_H -#include <config/bitcoin-config.h> // IWYU pragma: keep +#include <bitcoin-build-config.h> // IWYU pragma: keep #include <addresstype.h> #include <wallet/db.h> diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 5a520cbfe9..b5de4b4b3d 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -334,12 +334,11 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) // concurrently, ensuring no race conditions occur during either process. BOOST_FIXTURE_TEST_CASE(write_wallet_settings_concurrently, TestingSetup) { - WalletContext context; - context.chain = m_node.chain.get(); + auto chain = m_node.chain.get(); const auto NUM_WALLETS{5}; // Since we're counting the number of wallets, ensure we start without any. - BOOST_REQUIRE(context.chain->getRwSetting("wallet").isNull()); + BOOST_REQUIRE(chain->getRwSetting("wallet").isNull()); const auto& check_concurrent_wallet = [&](const auto& settings_function, int num_expected_wallets) { std::vector<std::thread> threads; @@ -347,19 +346,19 @@ BOOST_FIXTURE_TEST_CASE(write_wallet_settings_concurrently, TestingSetup) for (auto i{0}; i < NUM_WALLETS; ++i) threads.emplace_back(settings_function, i); for (auto& t : threads) t.join(); - auto wallets = context.chain->getRwSetting("wallet"); + auto wallets = chain->getRwSetting("wallet"); BOOST_CHECK_EQUAL(wallets.getValues().size(), num_expected_wallets); }; // Add NUM_WALLETS wallets concurrently, ensure we end up with NUM_WALLETS stored. - check_concurrent_wallet([&context](int i) { - Assert(AddWalletSetting(*context.chain, strprintf("wallet_%d", i))); + check_concurrent_wallet([&chain](int i) { + Assert(AddWalletSetting(*chain, strprintf("wallet_%d", i))); }, /*num_expected_wallets=*/NUM_WALLETS); // Remove NUM_WALLETS wallets concurrently, ensure we end up with 0 wallets. - check_concurrent_wallet([&context](int i) { - Assert(RemoveWalletSetting(*context.chain, strprintf("wallet_%d", i))); + check_concurrent_wallet([&chain](int i) { + Assert(RemoveWalletSetting(*chain, strprintf("wallet_%d", i))); }, /*num_expected_wallets=*/0); } |