def main(): parser = argparse.ArgumentParser() parser.add_argument("-m", "--mainnet", action="store_true", default=False, help="use MainNet instead of the default TestNet") parser.add_argument("-c", "--config", action="store", help="Use a specific config file") parser.add_argument("-n", "--notifications", action="store_true", default=False, help="Bootstrap notification database") parser.add_argument( "-s", "--skipconfirm", action="store_true", default=False, help="Bypass warning about overwritting data in {}".format( settings.LEVELDB_PATH)) # Where to store stuff parser.add_argument("--datadir", action="store", help="Absolute path to use for database directories") args = parser.parse_args() if args.mainnet and args.config: print( "Cannot use both --config and --mainnet parameters, please use only one." ) exit(1) if args.skipconfirm: require_confirm = False else: require_confirm = True # Setting the datadir must come before setting the network, else the wrong path is checked at net setup. if args.datadir: settings.set_data_dir(args.datadir) # Setup depending on command line arguments. By default, the testnet settings are already loaded. if args.config: settings.setup(args.config) elif args.mainnet: settings.setup_mainnet() if args.notifications: BootstrapBlockchainFile(settings.notification_leveldb_path, settings.NOTIF_BOOTSTRAP_FILE, require_confirm) else: BootstrapBlockchainFile(settings.chain_leveldb_path, settings.BOOTSTRAP_FILE, require_confirm)
def main(): parser = argparse.ArgumentParser() parser.add_argument("-m", "--mainnet", action="store_true", default=False, help="use MainNet instead of the default TestNet") parser.add_argument("-c", "--config", action="store", help="Use a specific config file") parser.add_argument("-n", "--notifications", action="store_true", default=False, help="Bootstrap notification database") parser.add_argument( "-s", "--skipconfirm", action="store_true", default=False, help="Bypass warning about overwritting data in {}".format( settings.LEVELDB_PATH)) args = parser.parse_args() if args.mainnet and args.config: print( "Cannot use both --config and --mainnet parameters, please use only one." ) exit(1) if args.skipconfirm: require_confirm = False else: require_confirm = True # Setup depending on command line arguments. By default, the testnet settings are already loaded. if args.config: settings.setup(args.config) elif args.mainnet: settings.setup_mainnet() if args.notifications: BootstrapBlockchainFile(settings.NOTIFICATION_DB_PATH, settings.NOTIF_BOOTSTRAP_FILE, require_confirm) else: BootstrapBlockchainFile(settings.LEVELDB_PATH, settings.BOOTSTRAP_FILE, require_confirm)
def test_3_good_bootstrap_bad_path(self): with self.assertRaises(SystemExit): BootstrapBlockchainFile(self.bootstrap_target_dir_bad, self.bootstrap_file_good, require_confirm=False) self.assertFalse(os.path.exists(self.bootstrap_target_dir))
def test_2_good_bootstrap_file(self): with self.assertRaises(SystemExit): BootstrapBlockchainFile(self.bootstrap_target_dir, self.bootstrap_unittest_file_locations, "goodnet", require_confirm=False) self.assertTrue(os.path.exists(self.bootstrap_target_dir))
def test_4_good_bootstrap_file_good_confirm(self): with patch('neo.Prompt.Commands.Bootstrap.prompt', side_effect=["confirm"]): with self.assertRaises(SystemExit): BootstrapBlockchainFile(self.bootstrap_target_dir, self.bootstrap_unittest_file_locations, "goodnet") self.assertTrue(os.path.exists(self.bootstrap_target_dir))
def test_6_good_bootstrap_file_keyboard_interrupt(self): with patch('sys.stdout', new=StringIO()) as mock_print: with patch('neo.Prompt.Commands.Bootstrap.prompt', side_effect=[KeyboardInterrupt]): with self.assertRaises(SystemExit): BootstrapBlockchainFile( self.bootstrap_target_dir, self.bootstrap_unittest_file_locations, "goodnet") self.assertFalse(os.path.exists(self.bootstrap_target_dir)) self.assertIn("bootstrap cancelled", mock_print.getvalue())
def test_1_bad_bootstrap_file(self): # this should exit 0 print("*** ***") print("*** This test expects a `404 Not found` ***") print("*** ***") with self.assertRaises(SystemExit): BootstrapBlockchainFile(self.bootstrap_target_dir, self.bootstrap_file_bad, require_confirm=False) # make sure no files are left around self.assertFalse(os.path.exists(self.bootstrap_target_dir))