parser.add_argument("-v", help="verbose", action='store_true') args = parser.parse_args() pnodes = args.p topo = args.s delay = args.d total_nodes = pnodes if args.n == 0 else args.n debug = args.v testUtils.Utils.Debug = debug Print("producing nodes:", pnodes, ", non-producing nodes: ", total_nodes - pnodes, ", topology:", topo, ", delay between nodes launch(seconds):", delay) cluster = testUtils.Cluster() walletMgr = testUtils.WalletMgr(False) cluster.killall() cluster.cleanup() random.seed(1) # Use a fixed seed for repeatability. try: cluster.setWalletMgr(walletMgr) Print("Stand up cluster") if cluster.launch(pnodes, total_nodes, topo, delay) is False: errorExit("Failed to stand up betterchain cluster.") Print("Wait for Cluster stabilization") # wait for cluster to start producing blocks if not cluster.waitOnClusterBlockNumSync(3): errorExit("Cluster never stabilized")
debug = args.v nodesFile = args.nodes_file seed = args.seed dontKill = args.dont_kill dumpErrorDetails = args.dump_error_details killWallet = not dontKill killEosInstances = not dontKill if nodesFile is not None: killEosInstances = False testUtils.Utils.Debug = debug testSuccessful = False random.seed(seed) # Use a fixed seed for repeatability. cluster = testUtils.Cluster(walletd=True) walletMgr = testUtils.WalletMgr(True) try: cluster.setWalletMgr(walletMgr) if nodesFile is not None: jsonStr = None with open(nodesFile, "r") as f: jsonStr = f.read() if not cluster.initializeNodesFromJson(jsonStr): errorExit("Failed to initilize nodes from Json string.") total_nodes = len(cluster.getNodes()) else: cluster.killall() cluster.cleanup()
host=args.wallet_host) if args.impaired_network: module = impaired_network.ImpairedNetwork() elif args.lossy_network: module = lossy_network.LossyNetwork() elif args.stress_network: module = p2p_stress.StressNetwork() else: errorExit( "one of impaired_network, lossy_network or stress_network must be set. Please also check peer configs in p2p_test_peers.py." ) cluster = testUtils.Cluster(walletd=True, enableMongo=enableMongo, defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey, walletHost=args.wallet_host, walletPort=args.wallet_port) print("BEGIN") print("number of hosts: %d, list of hosts:" % (len(hosts))) for i in range(len(hosts)): Print("%s:%d" % (hosts[i], ports[i])) init_str = '{"nodes":[' for i in range(len(hosts)): if i > 0: init_str = init_str + ',' init_str = init_str + '{"host":"' + hosts[i] + '", "port":' + str( ports[i]) + '}'
server = args.host port = args.port debug = args.v exitEarly = args.exit_early enableMongo = args.mongodb amINoon = not args.not_noon initaPrvtKey = args.inita_prvt_key initbPrvtKey = args.initb_prvt_key dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontLaunch = args.dont_launch testUtils.Utils.Debug = debug localTest = True if server == LOCAL_HOST else False cluster = testUtils.Cluster(walletd=True, enableMongo=enableMongo, initaPrvtKey=initaPrvtKey, initbPrvtKey=initbPrvtKey) walletMgr = testUtils.WalletMgr(True) testSuccessful = False killEosInstances = True killWallet = True WalletdName = "eos-walletd" ClientName = "eosc" if amINoon: WalletdName = "eosio-walletd" ClientName = "eosioc" # noon branch requires longer mongo sync time. testUtils.Utils.setMongoSyncTime(50)
def myTest(transWillEnterBlock): testSuccessful=False cluster=testUtils.Cluster(walletd=True, staging=True) walletMgr=testUtils.WalletMgr(True) try: cluster.killall() cluster.cleanup() walletMgr.killall() walletMgr.cleanup() pnodes=2 total_nodes=pnodes topo="mesh" delay=0 Print("Stand up cluster") if cluster.launch(pnodes, total_nodes, topo, delay) is False: error("Failed to stand up Enumivo cluster.") return False accounts=testUtils.Cluster.createAccountKeys(1) if accounts is None: error("FAILURE - create keys") return False currencyAccount=accounts[0] currencyAccount.name="currency" Print("Stand up walletd") if walletMgr.launch() is False: error("Failed to stand up Enumivo walletd.") return False testWalletName="test" Print("Creating wallet \"%s\"." % (testWalletName)) testWallet=walletMgr.create(testWalletName) if testWallet is None: error("Failed to create wallet %s." % (testWalletName)) return False for account in accounts: Print("Importing keys for account %s into wallet %s." % (account.name, testWallet.name)) if not walletMgr.importKey(account, testWallet): error("Failed to import key for account %s" % (account.name)) return False node=cluster.getNode(0) node2=cluster.getNode(1) if node is None or node2 is None: error("Cluster in bad state, received None node") return False initaAccount=testUtils.Cluster.initaAccount Print("Importing keys for account %s into wallet %s." % (initaAccount.name, testWallet.name)) if not walletMgr.importKey(initaAccount, testWallet): error("Failed to import key for account %s" % (initaAccount.name)) return False Print("Create new account %s via %s" % (currencyAccount.name, initaAccount.name)) transId=node.createAccount(currencyAccount, initaAccount, stakedDeposit=5000, waitForTransBlock=True) if transId is None: error("Failed to create account %s" % (currencyAccount.name)) return False wastFile="contracts/currency/currency.wast" abiFile="contracts/currency/currency.abi" Print("Publish contract") trans=node.publishContract(currencyAccount.name, wastFile, abiFile, waitForTransBlock=True) if trans is None: error("Failed to publish contract.") return False Print("push transfer action to currency contract") contract="currency" action="transfer" data="{\"from\":\"currency\",\"to\":\"inita\",\"quantity\":" if amINoon: data +="\"00.0050 CUR\",\"memo\":\"test\"}" else: data +="50}" opts="--permission currency@active" if not amINoon: opts += " --scope currency,inita" trans=node.pushMessage(contract, action, data, opts, silentErrors=True) transInBlock=False if not trans[0]: # On slower systems e.g Travis the transaction rejection can happen immediately # We want to handle fast and slow failures. if "allocated processing time was exceeded" in trans[1]: Print("Push message transaction immediately failed.") else: error("Exception in push message. %s" % (trans[1])) return False else: transId=testUtils.Node.getTransId(trans[1]) Print("verify transaction exists") if not node2.waitForTransIdOnNode(transId): error("Transaction never made it to node2") return False Print("Get details for transaction %s" % (transId)) transaction=node2.getTransaction(transId) signature=transaction["transaction"]["signatures"][0] blockNum=int(transaction["transaction"]["ref_block_num"]) blockNum += 1 Print("Our transaction is in block %d" % (blockNum)) block=node2.getBlock(blockNum) cycles=block["cycles"] if len(cycles) > 0: blockTransSignature=cycles[0][0]["user_input"][0]["signatures"][0] # Print("Transaction signature: %s\nBlock transaction signature: %s" % # (signature, blockTransSignature)) transInBlock=(signature == blockTransSignature) if transWillEnterBlock: if not transInBlock: error("Transaction did not enter the chain.") return False else: Print("SUCCESS: Transaction1 entered in the chain.") elif not transWillEnterBlock: if transInBlock: error("Transaction entered the chain.") return False else: Print("SUCCESS: Transaction2 did not enter the chain.") testSuccessful=True finally: if not testSuccessful and dumpErrorDetails: cluster.dumpErrorDetails() walletMgr.dumpErrorDetails() Print("== Errors see above ==") if killEnuInstances: Print("Shut down the cluster%s" % (" and cleanup." if (testSuccessful and not keepLogs) else ".")) cluster.killall() walletMgr.killall() if testSuccessful and not keepLogs: Print("Cleanup cluster and wallet data.") cluster.cleanup() walletMgr.cleanup() return True
parser.add_argument("--exit-early", help="Exit prior to known error point.", action='store_true') parser.add_argument("-v", help="verbose logging", action='store_true') parser.add_argument("--not-noon", help="This is not the Noon branch.", action='store_true') args = parser.parse_args() testOutputFile=args.output server=args.host port=args.port debug=args.v exitEarly=args.exit_early enableMongo=args.mongodb amINoon=not args.not_noon localTest=True if server == LOCAL_HOST else False testUtils.Utils.Debug=debug cluster=testUtils.Cluster(walletd=True, enableMongo=enableMongo) walletMgr=testUtils.WalletMgr(True) cluster.killall() cluster.cleanup() walletMgr.killall() walletMgr.cleanup() random.seed(1) # Use a fixed seed for repeatability. testSuccessful=False dumpErrorDetails=args.dump_error_details keepLogs=args.keep_logs killBetterChainInstances=True WalletdName="betterchain-walletd" ClientName="betterchainc"
debug = args.v enableMongo = args.mongodb defproduceraPrvtKey = args.defproducera_prvt_key defproducerbPrvtKey = args.defproducerb_prvt_key dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontLaunch = args.dont_launch dontKill = args.leave_running prodCount = args.prod_count onlyBios = args.only_bios killAll = args.clean_run testUtils.Utils.Debug = debug localTest = True if server == TestHelper.LOCAL_HOST else False cluster = testUtils.Cluster(walletd=True, enableMongo=enableMongo, defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey) walletMgr = testUtils.WalletMgr(True) testSuccessful = False killEosInstances = not dontKill killWallet = not dontKill WalletdName = "keosd" ClientName = "cleos" # testUtils.Utils.setMongoSyncTime(50) try: Print("BEGIN") Print("SERVER: %s" % (server)) Print("PORT: %d" % (port))
host=args.wallet_host) if args.impaired_network: module = impaired_network.ImpairedNetwork() elif args.lossy_network: module = lossy_network.LossyNetwork() elif args.stress_network: module = p2p_stress.StressNetwork() else: errorExit( "one of impaired_network, lossy_network or stress_network must be set. Please also check peer configs in p2p_test_peers.py." ) cluster = testUtils.Cluster(walletd=True, enableMongo=enableMongo, initaPrvtKey=initaPrvtKey, initbPrvtKey=initbPrvtKey, walletHost=args.wallet_host, walletPort=args.wallet_port) print("BEGIN") print("TEST_OUTPUT: %s" % (testOutputFile)) print("number of hosts: %d, list of hosts:" % (len(hosts))) for i in range(len(hosts)): Print("%s:%d" % (hosts[i], ports[i])) init_str = '{"nodes":[' for i in range(len(hosts)): if i > 0: init_str = init_str + ',' init_str = init_str + '{"host":"' + hosts[i] + '", "port":' + str(
debug = args.v enableMongo = args.mongodb amINoon = not args.not_noon initaPrvtKey = args.inita_prvt_key initbPrvtKey = args.initb_prvt_key dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontLaunch = args.dont_launch dontKill = args.dont_kill testUtils.Utils.Debug = debug localTest = True if server == LOCAL_HOST else False # launcher launched bios node listens on port DEFAULT_PORT-100 cluster = testUtils.Cluster(walletd=True, enableMongo=enableMongo, initaPrvtKey=initaPrvtKey, initbPrvtKey=initbPrvtKey, port=DEFAULT_PORT - 100) walletMgr = testUtils.WalletMgr(True, nodeosPort=DEFAULT_PORT - 100) testSuccessful = False killEosInstances = not dontKill killWallet = not dontKill WalletdName = "eos-walletd" ClientName = "eosc" if amINoon: WalletdName = "eosio-walletd" ClientName = "cleos" # noon branch requires longer mongo sync time. testUtils.Utils.setMongoSyncTime(50)
############################################################### # nodaac_voting_test # --dump-error-details <Upon error print etc/aacio/node_*/config.ini and var/lib/node_*/stderr.log to stdout> # --keep-logs <Don't delete var/lib/node_* folders upon test completion> ############################################################### Print = testUtils.Utils.Print errorExit = testUtils.Utils.errorExit cmdError = testUtils.Utils.cmdError from core_symbol import CORE_SYMBOL # create TestState with all common flags, except --mongodb testState = testUtils.TestState("--mongodb") args = testState.parse_args() testState.cluster = testUtils.Cluster(walletd=True) testState.pnodes = 4 testState.totalNodes = 4 testState.totalProducers = testState.pnodes * 21 try: testState.start(testUtils.Cluster(walletd=True)) testState.success() finally: testState.end() exit(0)
############################################################### # myeosnode_voting_test # --dump-error-details <Upon error print etc/myeosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout> # --keep-logs <Don't delete var/lib/node_* folders upon test completion> ############################################################### Print = testUtils.Utils.Print errorExit = testUtils.Utils.errorExit cmdError = testUtils.Utils.cmdError from core_symbol import CORE_SYMBOL # create TestState with all common flags, except --mongodb testState = testUtils.TestState("--mongodb") args = testState.parse_args() testState.cluster = testUtils.Cluster(mykeosdd=True) testState.pnodes = 4 testState.totalNodes = 4 testState.totalProducers = testState.pnodes * 21 try: testState.start(testUtils.Cluster(mykeosdd=True)) testState.success() finally: testState.end() exit(0)
topo=args.s delay=args.d chainSyncStrategyStr=args.c debug=args.v total_nodes = pnodes killCount=args.killCount if args.killCount > 0 else int((DefaultKillPercent/100.0)*total_nodes) killSignal=args.killSig killEosInstances= not args.dontKill dumpErrorDetails=args.dumpErrorDetails keepLogs=args.keepLogs testUtils.Utils.Debug=debug Print ("producing nodes: %d, topology: %s, delay between nodes launch(seconds): %d, chain sync strategy: %s" % (pnodes, topo, delay, chainSyncStrategyStr)) cluster=testUtils.Cluster(chainSyncStrategyStr) cluster.killall() cluster.cleanup() random.seed(1) # Use a fixed seed for repeatability. testSuccessful=False try: print("Stand up cluster") if cluster.launch(pnodes, total_nodes, topo, delay) is False: errorExit("Failed to stand up eos cluster.") Print ("Wait for Cluster stabilization") # wait for cluster to start producing blocks if not cluster.waitOnClusterBlockNumSync(3): errorExit("Cluster never stabilized")