def main(): import optparse parser = optparse.optionparser(usage="%prog [options]") parser.add_option("--nocleanup", dest="nocleanup", default=false, action="store_true", help="leave moorecoinds and test.* datadir on exit or error") parser.add_option("--srcdir", dest="srcdir", default="../../src", help="source directory containing moorecoind/moorecoin-cli (default: %default%)") parser.add_option("--tmpdir", dest="tmpdir", default=tempfile.mkdtemp(prefix="test"), help="root directory for datadirs") (options, args) = parser.parse_args() os.environ['path'] = options.srcdir+":"+os.environ['path'] check_json_precision() success = false nodes = [] try: print("initializing test directory "+options.tmpdir) if not os.path.isdir(options.tmpdir): os.makedirs(options.tmpdir) initialize_chain(options.tmpdir) nodes = start_nodes(1, options.tmpdir) run_test(nodes, options.tmpdir) success = true except assertionerror as e: print("assertion failed: "+e.message) except jsonrpcexception as e: print("jsonrpc error: "+e.error['message']) traceback.print_tb(sys.exc_info()[2]) except exception as e: print("unexpected exception caught during testing: "+str(sys.exc_info()[0])) traceback.print_tb(sys.exc_info()[2]) if not options.nocleanup: print("cleaning up") stop_nodes(nodes) wait_moorecoinds() shutil.rmtree(options.tmpdir) if success: print("tests successful") sys.exit(0) else: print("failed") sys.exit(1)
def get_option_parser(): usage = "parse the gcov output and generate more human-readable code " +\ "coverage report." parser = optionparser(usage) parser.add_option( "--interested-files", "-i", dest="filenames", help="comma separated files names. if specified, we will display " + "the coverage report only for interested source files. " + "otherwise we will display the coverage report for all " + "source files." ) return parser
def main(): import optparse parser = optparse.optionparser(usage="%prog [options]") parser.add_option("--from", dest="fromaddresses", default=none, help="addresses to get moorecoins from") parser.add_option("--to", dest="to", default=none, help="address to get send moorecoins to") parser.add_option("--amount", dest="amount", default=none, help="amount to send") parser.add_option("--fee", dest="fee", default="0.0", help="fee to include") parser.add_option("--datadir", dest="datadir", default=determine_db_dir(), help="location of moorecoin.conf file with rpc username/password (default: %default)") parser.add_option("--testnet", dest="testnet", default=false, action="store_true", help="use the test network") parser.add_option("--dry_run", dest="dry_run", default=false, action="store_true", help="don't broadcast the transaction, just create and print the transaction data") (options, args) = parser.parse_args() check_json_precision() config = read_moorecoin_config(options.datadir) if options.testnet: config['testnet'] = true moorecoind = connect_json(config) if options.amount is none: address_summary = list_available(moorecoind) for address,info in address_summary.iteritems(): n_transactions = len(info['outputs']) if n_transactions > 1: print("%s %.8f %s (%d transactions)"%(address, info['total'], info['account'], n_transactions)) else: print("%s %.8f %s"%(address, info['total'], info['account'])) else: fee = decimal(options.fee) amount = decimal(options.amount) while unlock_wallet(moorecoind) == false: pass # keep asking for passphrase until they get it right txdata = create_tx(moorecoind, options.fromaddresses.split(","), options.to, amount, fee) sanity_test_fee(moorecoind, txdata, amount*decimal("0.01")) if options.dry_run: print(txdata) else: txid = moorecoind.sendrawtransaction(txdata) print(txid)
def get_agruments(): parser = optparse.optionparser() parser.add_option("-t", "--target", dest="target", help="target IP/IP range") (options,agruments) = parser.parse_args() return options
def main(self): import optparse parser = optparse.optionparser(usage="%prog [options]") parser.add_option("--nocleanup", dest="nocleanup", default=false, action="store_true", help="leave moorecoinds and test.* datadir on exit or error") parser.add_option("--noshutdown", dest="noshutdown", default=false, action="store_true", help="don't stop moorecoinds after the test execution") parser.add_option("--srcdir", dest="srcdir", default="../../src", help="source directory containing moorecoind/moorecoin-cli (default: %default)") parser.add_option("--tmpdir", dest="tmpdir", default=tempfile.mkdtemp(prefix="test"), help="root directory for datadirs") parser.add_option("--tracerpc", dest="trace_rpc", default=false, action="store_true", help="print out all rpc calls as they are made") self.add_options(parser) (self.options, self.args) = parser.parse_args() if self.options.trace_rpc: import logging logging.basicconfig(level=logging.debug) os.environ['path'] = self.options.srcdir+":"+os.environ['path'] check_json_precision() success = false try: if not os.path.isdir(self.options.tmpdir): os.makedirs(self.options.tmpdir) self.setup_chain() self.setup_network() self.run_test() success = true except jsonrpcexception as e: print("jsonrpc error: "+e.error['message']) traceback.print_tb(sys.exc_info()[2]) except assertionerror as e: print("assertion failed: "+e.message) traceback.print_tb(sys.exc_info()[2]) except exception as e: print("unexpected exception caught during testing: "+str(e)) traceback.print_tb(sys.exc_info()[2]) if not self.options.noshutdown: print("stopping nodes") stop_nodes(self.nodes) wait_moorecoinds() else: print("note: moorecoinds were not stopped and may still be running") if not self.options.nocleanup and not self.options.noshutdown: print("cleaning up") shutil.rmtree(self.options.tmpdir) if success: print("tests successful") sys.exit(0) else: print("failed") sys.exit(1)