aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-12-24 11:28:44 -0500
committerMatt Corallo <git@bluematt.me>2016-12-27 13:52:07 +0100
commitc2f61bebb190258753714b29ab2041e80651cec9 (patch)
tree5242c7209483c676c4549c61556fd5f86202bd2c /src/test
parent4e048142a5e45d622355dad92ade192ad4769ca3 (diff)
Add a ForceSetArg method for testing
Diffstat (limited to 'src/test')
-rw-r--r--src/test/DoS_tests.cpp6
-rw-r--r--src/test/test_bitcoin.cpp4
2 files changed, 4 insertions, 6 deletions
diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp
index dafb096e80..d90dcaeb02 100644
--- a/src/test/DoS_tests.cpp
+++ b/src/test/DoS_tests.cpp
@@ -12,6 +12,7 @@
#include "script/sign.h"
#include "serialize.h"
#include "util.h"
+#include "validation.h"
#include "test/test_bitcoin.h"
@@ -32,7 +33,6 @@ struct COrphanTx {
int64_t nTimeExpire;
};
extern std::map<uint256, COrphanTx> mapOrphanTransactions;
-extern std::map<std::string, std::string> mapArgs;
CService ip(uint32_t i)
{
@@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
BOOST_AUTO_TEST_CASE(DoS_banscore)
{
connman->ClearBanned();
- mapArgs["-banscore"] = "111"; // because 11 is my favorite number
+ ForceSetArg("-banscore", "111"); // because 11 is my favorite number
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 3, 1, "", true);
dummyNode1.SetSendVersion(PROTOCOL_VERSION);
@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
Misbehaving(dummyNode1.GetId(), 1);
SendMessages(&dummyNode1, *connman);
BOOST_CHECK(connman->IsBanned(addr1));
- mapArgs.erase("-banscore");
+ ForceSetArg("-banscore", std::to_string(DEFAULT_BANSCORE_THRESHOLD));
}
BOOST_AUTO_TEST_CASE(DoS_bantime)
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
index b62b317105..5c4ef5eb8c 100644
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -33,8 +33,6 @@
std::unique_ptr<CConnman> g_connman;
FastRandomContext insecure_rand_ctx(true);
-extern std::map<std::string, std::string> mapArgs;
-
extern bool fPrintToConsole;
extern void noui_connect();
@@ -66,7 +64,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
ClearDatadirCache();
pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
boost::filesystem::create_directories(pathTemp);
- mapArgs["-datadir"] = pathTemp.string();
+ ForceSetArg("-datadir", pathTemp.string());
mempool.setSanityCheck(1.0);
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);