aboutsummaryrefslogtreecommitdiff
path: root/src/test/base58_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/base58_tests.cpp')
-rw-r--r--src/test/base58_tests.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp
index 2741672a88..af65416485 100644
--- a/src/test/base58_tests.cpp
+++ b/src/test/base58_tests.cpp
@@ -108,8 +108,6 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
std::vector<unsigned char> result;
CBitcoinSecret secret;
CBitcoinAddress addr;
- // Save global state
- bool fTestNet_stored = fTestNet;
BOOST_FOREACH(Value& tv, tests)
{
@@ -125,7 +123,10 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
const Object &metadata = test[2].get_obj();
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
bool isTestnet = find_value(metadata, "isTestnet").get_bool();
- fTestNet = isTestnet; // Override testnet flag
+ if (isTestnet)
+ SelectParams(CChainParams::TESTNET);
+ else
+ SelectParams(CChainParams::MAIN);
if(isPrivkey)
{
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
@@ -156,8 +157,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid pubkey as privkey:" + strTest);
}
}
- // Restore global state
- fTestNet = fTestNet_stored;
+ SelectParams(CChainParams::MAIN);
}
// Goal: check that generated keys match test vectors
@@ -165,9 +165,6 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
{
Array tests = read_json("base58_keys_valid.json");
std::vector<unsigned char> result;
- // Save global state
- bool fTestNet_stored = fTestNet;
-
BOOST_FOREACH(Value& tv, tests)
{
Array test = tv.get_array();
@@ -182,7 +179,10 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
const Object &metadata = test[2].get_obj();
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
bool isTestnet = find_value(metadata, "isTestnet").get_bool();
- fTestNet = isTestnet; // Override testnet flag
+ if (isTestnet)
+ SelectParams(CChainParams::TESTNET);
+ else
+ SelectParams(CChainParams::MAIN);
if(isPrivkey)
{
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
@@ -225,8 +225,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
CTxDestination nodest = CNoDestination();
BOOST_CHECK(!boost::apply_visitor(CBitcoinAddressVisitor(&dummyAddr), nodest));
- // Restore global state
- fTestNet = fTestNet_stored;
+ SelectParams(CChainParams::MAIN);
}
// Goal: check that base58 parsing code is robust against a variety of corrupted data