mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#16277: suppress output in test_bitcoin for expected errors
This commit is contained in:
parent
ff22aa299a
commit
07632958cb
44
src/noui.cpp
44
src/noui.cpp
@ -14,6 +14,12 @@
|
||||
#include <string>
|
||||
|
||||
#include <boost/signals2/connection.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
/** Store connections so we can disconnect them when suppressing output */
|
||||
boost::signals2::connection noui_ThreadSafeMessageBoxConn;
|
||||
boost::signals2::connection noui_ThreadSafeQuestionConn;
|
||||
boost::signals2::connection noui_InitMessageConn;
|
||||
|
||||
bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
|
||||
{
|
||||
@ -54,7 +60,39 @@ void noui_InitMessage(const std::string& message)
|
||||
|
||||
void noui_connect()
|
||||
{
|
||||
uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
|
||||
uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
|
||||
uiInterface.InitMessage_connect(noui_InitMessage);
|
||||
noui_ThreadSafeMessageBoxConn = uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
|
||||
noui_ThreadSafeQuestionConn = uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
|
||||
noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessage);
|
||||
}
|
||||
|
||||
bool noui_ThreadSafeMessageBoxSuppressed(const std::string& message, const std::string& caption, unsigned int style)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool noui_ThreadSafeQuestionSuppressed(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void noui_InitMessageSuppressed(const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void noui_suppress()
|
||||
{
|
||||
noui_ThreadSafeMessageBoxConn.disconnect();
|
||||
noui_ThreadSafeQuestionConn.disconnect();
|
||||
noui_InitMessageConn.disconnect();
|
||||
noui_ThreadSafeMessageBoxConn = uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBoxSuppressed);
|
||||
noui_ThreadSafeQuestionConn = uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestionSuppressed);
|
||||
noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessageSuppressed);
|
||||
}
|
||||
|
||||
void noui_reconnect()
|
||||
{
|
||||
noui_ThreadSafeMessageBoxConn.disconnect();
|
||||
noui_ThreadSafeQuestionConn.disconnect();
|
||||
noui_InitMessageConn.disconnect();
|
||||
noui_connect();
|
||||
}
|
@ -17,4 +17,10 @@ void noui_InitMessage(const std::string& message);
|
||||
/** Connect all bitcoind signal handlers */
|
||||
void noui_connect();
|
||||
|
||||
/** Suppress all bitcoind signal handlers. Used to suppress output during test runs that produce expected errors */
|
||||
void noui_suppress();
|
||||
|
||||
/** Reconnects the regular Non-GUI handlers after having used noui_suppress */
|
||||
void noui_reconnect();
|
||||
|
||||
#endif // BITCOIN_NOUI_H
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <noui.h>
|
||||
#include <test/test_dash.h>
|
||||
#include <wallet/test/init_test_fixture.h>
|
||||
|
||||
@ -17,7 +18,9 @@ BOOST_FIXTURE_TEST_SUITE(init_tests, InitWalletDirTestingSetup)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["default"]);
|
||||
noui_suppress();
|
||||
bool result = m_chain_client->verify();
|
||||
noui_reconnect();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
|
||||
@ -27,7 +30,9 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["custom"]);
|
||||
noui_suppress();
|
||||
bool result = m_chain_client->verify();
|
||||
noui_reconnect();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["custom"]);
|
||||
@ -37,28 +42,36 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["nonexistent"]);
|
||||
noui_suppress();
|
||||
bool result = m_chain_client->verify();
|
||||
noui_reconnect();
|
||||
BOOST_CHECK(result == false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["file"]);
|
||||
noui_suppress();
|
||||
bool result = m_chain_client->verify();
|
||||
noui_reconnect();
|
||||
BOOST_CHECK(result == false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["relative"]);
|
||||
noui_suppress();
|
||||
bool result = m_chain_client->verify();
|
||||
noui_reconnect();
|
||||
BOOST_CHECK(result == false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["trailing"]);
|
||||
noui_suppress();
|
||||
bool result = m_chain_client->verify();
|
||||
noui_reconnect();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
|
||||
@ -68,7 +81,9 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["trailing2"]);
|
||||
noui_suppress();
|
||||
bool result = m_chain_client->verify();
|
||||
noui_reconnect();
|
||||
BOOST_CHECK(result == true);
|
||||
fs::path walletdir = gArgs.GetArg("-walletdir", "");
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
|
||||
|
Loading…
Reference in New Issue
Block a user