mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#21634: Skip SQLite fsyncs while testing
This commit is contained in:
parent
6900545ca8
commit
9795605d3b
@ -66,7 +66,8 @@ void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
|
|||||||
"-dblogsize=<n>",
|
"-dblogsize=<n>",
|
||||||
"-flushwallet",
|
"-flushwallet",
|
||||||
"-privdb",
|
"-privdb",
|
||||||
"-walletrejectlongchains"
|
"-walletrejectlongchains",
|
||||||
|
"-unsafesqlitesync"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +106,12 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
|
|||||||
argsman.AddHiddenArgs({"-dblogsize", "-flushwallet", "-privdb"});
|
argsman.AddHiddenArgs({"-dblogsize", "-flushwallet", "-privdb"});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_SQLITE
|
||||||
|
argsman.AddArg("-unsafesqlitesync", "Set SQLite synchronous=OFF to disable waiting for the database to sync to disk. This is unsafe and can cause data loss and corruption. This option is only used by tests to improve their performance (default: false)", ArgsManager::ALLOW_BOOL | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
|
||||||
|
#else
|
||||||
|
argsman.AddHiddenArgs({"-unsafesqlitesync"});
|
||||||
|
#endif
|
||||||
|
|
||||||
argsman.AddArg("-walletrejectlongchains", strprintf("Wallet will not create transactions that violate mempool chain limits (default: %u)", DEFAULT_WALLET_REJECT_LONG_CHAINS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
|
argsman.AddArg("-walletrejectlongchains", strprintf("Wallet will not create transactions that violate mempool chain limits (default: %u)", DEFAULT_WALLET_REJECT_LONG_CHAINS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
|
||||||
|
|
||||||
argsman.AddHiddenArgs({"-zapwallettxes"});
|
argsman.AddHiddenArgs({"-zapwallettxes"});
|
||||||
|
@ -239,6 +239,15 @@ void SQLiteDatabase::Open()
|
|||||||
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to enable fullfsync: %s\n", sqlite3_errstr(ret)));
|
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to enable fullfsync: %s\n", sqlite3_errstr(ret)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gArgs.GetBoolArg("-unsafesqlitesync", false)) {
|
||||||
|
// Use normal synchronous mode for the journal
|
||||||
|
LogPrintf("WARNING SQLite is configured to not wait for data to be flushed to disk. Data loss and corruption may occur.\n");
|
||||||
|
ret = sqlite3_exec(m_db, "PRAGMA synchronous = OFF", nullptr, nullptr, nullptr);
|
||||||
|
if (ret != SQLITE_OK) {
|
||||||
|
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to set synchronous mode to OFF: %s\n", sqlite3_errstr(ret)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Make the table for our key-value pairs
|
// Make the table for our key-value pairs
|
||||||
// First check that the main table exists
|
// First check that the main table exists
|
||||||
sqlite3_stmt* check_main_stmt{nullptr};
|
sqlite3_stmt* check_main_stmt{nullptr};
|
||||||
|
@ -1062,6 +1062,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain100Setup)
|
|||||||
//! matter. The test could be extended to cover other scenarios in the future.
|
//! matter. The test could be extended to cover other scenarios in the future.
|
||||||
BOOST_FIXTURE_TEST_CASE(CreateWalletFromFile, TestChain100Setup)
|
BOOST_FIXTURE_TEST_CASE(CreateWalletFromFile, TestChain100Setup)
|
||||||
{
|
{
|
||||||
|
gArgs.ForceSetArg("-unsafesqlitesync", "1");
|
||||||
// Create new wallet with known key and unload it.
|
// Create new wallet with known key and unload it.
|
||||||
auto chain = interfaces::MakeChain(m_node);
|
auto chain = interfaces::MakeChain(m_node);
|
||||||
auto wallet = TestLoadWallet(*chain);
|
auto wallet = TestLoadWallet(*chain);
|
||||||
|
@ -355,6 +355,8 @@ def initialize_datadir(dirname, n, chain):
|
|||||||
f.write("upnp=0\n")
|
f.write("upnp=0\n")
|
||||||
f.write("natpmp=0\n")
|
f.write("natpmp=0\n")
|
||||||
f.write("shrinkdebugfile=0\n")
|
f.write("shrinkdebugfile=0\n")
|
||||||
|
# To improve SQLite wallet performance so that the tests don't timeout, use -unsafesqlitesync
|
||||||
|
f.write("unsafesqlitesync=1\n")
|
||||||
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
|
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
|
||||||
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
|
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
|
||||||
return datadir
|
return datadir
|
||||||
|
Loading…
Reference in New Issue
Block a user