diff options
author | Anthony Towns <aj@erisian.com.au> | 2018-03-29 15:05:00 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2018-04-06 04:46:32 +1000 |
commit | af173c2bec390d5a47f98e7bbf6559d50be35f07 (patch) | |
tree | 4a4b31c70886d88c6920c033db7d4a6c445c0ceb | |
parent | fa27f1c23e03c8f8e8b06ea86a640a62a0f8768c (diff) |
[tests] Check GetChainName works with config entries
-rw-r--r-- | src/test/util_tests.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 3a0668a2b5..951bc0fa52 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -406,6 +406,9 @@ BOOST_AUTO_TEST_CASE(util_GetChainName) const char* argv_test_no_reg[] = {"cmd", "-testnet", "-noregtest"}; const char* argv_both[] = {"cmd", "-testnet", "-regtest"}; + // equivalent to "-testnet" + const char* testnetconf = "testnet=1\nregtest=0\n"; + test_args.ParseParameters(0, (char**)argv_testnet); BOOST_CHECK_EQUAL(test_args.GetChainName(), "main"); @@ -420,6 +423,26 @@ BOOST_AUTO_TEST_CASE(util_GetChainName) test_args.ParseParameters(3, (char**)argv_both); BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error); + + 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(3, (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) |