diff options
author | Anthony Towns <aj@erisian.com.au> | 2018-04-04 18:10:00 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2018-04-11 23:15:28 +1000 |
commit | 5e3cbe020ddeaf4abf51cb561122056cce726d8b (patch) | |
tree | 5fb5a4cfd966a7a28ccb5a63afbf21a1d4aa5dfe /src/test | |
parent | 005ad266491f43d7a9bfd959396037416cb32a55 (diff) |
[tests] Unit tests for -testnet/-regtest in [test]/[regtest] sections
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/util_tests.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 98ded7bc8c..fa49d6d7ff 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -544,7 +544,8 @@ BOOST_AUTO_TEST_CASE(util_GetChainName) const char* argv_both[] = {"cmd", "-testnet", "-regtest"}; // equivalent to "-testnet" - const char* testnetconf = "testnet=1\nregtest=0\n"; + // regtest in testnet section is ignored + const char* testnetconf = "testnet=1\nregtest=0\n[test]\nregtest=1"; test_args.ParseParameters(0, (char**)argv_testnet); BOOST_CHECK_EQUAL(test_args.GetChainName(), "main"); @@ -580,6 +581,30 @@ BOOST_AUTO_TEST_CASE(util_GetChainName) test_args.ParseParameters(3, (char**)argv_both); test_args.ReadConfigString(testnetconf); BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error); + + // check setting the network to test (and thus making + // [test] regtest=1 potentially relevent) doesn't break things + test_args.SelectConfigNetwork("test"); + + test_args.ParseParameters(0, (char**)argv_testnet); + test_args.ReadConfigString(testnetconf); + BOOST_CHECK_EQUAL(test_args.GetChainName(), "test"); + + test_args.ParseParameters(2, (char**)argv_testnet); + test_args.ReadConfigString(testnetconf); + BOOST_CHECK_EQUAL(test_args.GetChainName(), "test"); + + test_args.ParseParameters(2, (char**)argv_regtest); + test_args.ReadConfigString(testnetconf); + BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error); + + test_args.ParseParameters(2, (char**)argv_test_no_reg); + test_args.ReadConfigString(testnetconf); + BOOST_CHECK_EQUAL(test_args.GetChainName(), "test"); + + test_args.ParseParameters(3, (char**)argv_both); + test_args.ReadConfigString(testnetconf); + BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error); } BOOST_AUTO_TEST_CASE(util_FormatMoney) |