aboutsummaryrefslogtreecommitdiff
path: root/src/test/base58_tests.cpp
diff options
context:
space:
mode:
authorMike Hearn <hearn@google.com>2013-05-07 15:16:25 +0200
committerMike Hearn <hearn@google.com>2013-06-19 16:28:52 +0200
commit0e4b31755534fac4ea6c20a60f719e3694252220 (patch)
tree80f576f67c855485e5d82007b98a45536bbf2f9a /src/test/base58_tests.cpp
parent70e7fba06da36218688a4cae4a5d12332c714247 (diff)
downloadbitcoin-0e4b31755534fac4ea6c20a60f719e3694252220.tar.xz
Introduce a CChainParameters singleton class and regtest mode.
The new class is accessed via the Params() method and holds most things that vary between main, test and regtest networks. The regtest mode has two purposes, one is to run the bitcoind/bitcoinj comparison tool which compares two separate implementations of the Bitcoin protocol looking for divergence. The other is that when run, you get a local node which can mine a single block instantly, which is highly convenient for testing apps during development as there's no need to wait 10 minutes for a block on the testnet.
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