@@ -544,7 +544,8 @@ BOOST_AUTO_TEST_CASE(util_GetChainName)
544
544
const char * argv_both[] = {" cmd" , " -testnet" , " -regtest" };
545
545
546
546
// equivalent to "-testnet"
547
- const char * testnetconf = " testnet=1\n regtest=0\n " ;
547
+ // regtest in testnet section is ignored
548
+ const char * testnetconf = " testnet=1\n regtest=0\n [test]\n regtest=1" ;
548
549
549
550
test_args.ParseParameters (0 , (char **)argv_testnet);
550
551
BOOST_CHECK_EQUAL (test_args.GetChainName (), " main" );
@@ -580,6 +581,30 @@ BOOST_AUTO_TEST_CASE(util_GetChainName)
580
581
test_args.ParseParameters (3 , (char **)argv_both);
581
582
test_args.ReadConfigString (testnetconf);
582
583
BOOST_CHECK_THROW (test_args.GetChainName (), std::runtime_error);
584
+
585
+ // check setting the network to test (and thus making
586
+ // [test] regtest=1 potentially relevent) doesn't break things
587
+ test_args.SelectConfigNetwork (" test" );
588
+
589
+ test_args.ParseParameters (0 , (char **)argv_testnet);
590
+ test_args.ReadConfigString (testnetconf);
591
+ BOOST_CHECK_EQUAL (test_args.GetChainName (), " test" );
592
+
593
+ test_args.ParseParameters (2 , (char **)argv_testnet);
594
+ test_args.ReadConfigString (testnetconf);
595
+ BOOST_CHECK_EQUAL (test_args.GetChainName (), " test" );
596
+
597
+ test_args.ParseParameters (2 , (char **)argv_regtest);
598
+ test_args.ReadConfigString (testnetconf);
599
+ BOOST_CHECK_THROW (test_args.GetChainName (), std::runtime_error);
600
+
601
+ test_args.ParseParameters (2 , (char **)argv_test_no_reg);
602
+ test_args.ReadConfigString (testnetconf);
603
+ BOOST_CHECK_EQUAL (test_args.GetChainName (), " test" );
604
+
605
+ test_args.ParseParameters (3 , (char **)argv_both);
606
+ test_args.ReadConfigString (testnetconf);
607
+ BOOST_CHECK_THROW (test_args.GetChainName (), std::runtime_error);
583
608
}
584
609
585
610
BOOST_AUTO_TEST_CASE (util_FormatMoney)
0 commit comments