未验证 提交 ce5c3c2b 编写于 作者: K Kevin Heifner 提交者: GitHub

Merge pull request #4866 from brianjohnson5972/4864-script-cleanup

Script Cleanup
......@@ -244,7 +244,7 @@ class Cluster(object):
node.setWalletEndpointArgs(self.walletEndpointArgs)
if Utils.Debug: Utils.Print("Node: %s", str(node))
node.checkPulse()
node.checkPulse(exitOnError=True)
self.nodes=[node]
if defproduceraPrvtKey is not None:
......@@ -284,7 +284,7 @@ class Cluster(object):
node.setWalletEndpointArgs(self.walletEndpointArgs)
if Utils.Debug: Utils.Print("Node:", node)
node.checkPulse()
node.checkPulse(exitOnError=True)
nodes.append(node)
self.nodes=nodes
......@@ -313,7 +313,6 @@ class Cluster(object):
for node in nodes:
try:
if (not node.killed) and (not node.isBlockPresent(targetBlockNum)):
#if (not node.killed) and (not node.isBlockFinalized(targetBlockNum)):
return False
except (TypeError) as _:
# This can happen if client connects before server is listening
......@@ -430,7 +429,13 @@ class Cluster(object):
self.accounts=accounts
return True
def getNode(self, nodeId=0):
def getNode(self, nodeId=0, exitOnError=True):
if exitOnError and nodeId >= len(self.nodes):
Utils.cmdError("cluster never created node %d" % (nodeId))
errorExit("Failed to retrieve node %d" % (nodeId))
if exitOnError and self.nodes[nodeId] is None:
Utils.cmdError("cluster has None value for node %d" % (nodeId))
errorExit("Failed to retrieve node %d" % (nodeId))
return self.nodes[nodeId]
def getNodes(self):
......@@ -455,7 +460,6 @@ class Cluster(object):
Utils.Print("Transfer %s units from account %s to %s on eos server port %d" % (
transferAmountStr, fromm.name, to.name, node.port))
trans=node.transferFunds(fromm, to, transferAmountStr)
assert(trans)
transId=Node.getTransId(trans)
if transId is None:
return False
......@@ -571,8 +575,7 @@ class Cluster(object):
"""create account, verify account and return transaction id"""
assert(len(self.nodes) > 0)
node=self.nodes[0]
trans=node.createInitializeAccount(account, creator, stakedDeposit, stakeNet=stakeNet, stakeCPU=stakeCPU, buyRAM=buyRAM)
assert(trans)
trans=node.createInitializeAccount(account, creator, stakedDeposit, stakeNet=stakeNet, stakeCPU=stakeCPU, buyRAM=buyRAM, exitOnError=True)
assert(node.verifyAccount(account))
return trans
......@@ -589,7 +592,7 @@ class Cluster(object):
# return transId
# return None
def createInitializeAccount(self, account, creatorAccount, stakedDeposit=1000, waitForTransBlock=False, stakeNet=100, stakeCPU=100, buyRAM=100):
def createInitializeAccount(self, account, creatorAccount, stakedDeposit=1000, waitForTransBlock=False, stakeNet=100, stakeCPU=100, buyRAM=100, exitOnError=False):
assert(len(self.nodes) > 0)
node=self.nodes[0]
trans=node.createInitializeAccount(account, creatorAccount, stakedDeposit, waitForTransBlock, stakeNet=stakeNet, stakeCPU=stakeCPU, buyRAM=buyRAM)
......@@ -707,9 +710,6 @@ class Cluster(object):
try:
ignWallet=walletMgr.create("ignition")
if ignWallet is None:
Utils.Print("ERROR: Failed to create ignition wallet.")
return False
eosioName="eosio"
eosioKeys=producerKeys[eosioName]
......@@ -807,7 +807,7 @@ class Cluster(object):
return False
# wait for block production handover (essentially a block produced by anyone but eosio).
lam = lambda: biosNode.getInfo()["head_block_producer"] != "eosio"
lam = lambda: biosNode.getInfo(exitOnError=True)["head_block_producer"] != "eosio"
ret=Utils.waitForBool(lam)
if not ret:
Utils.Print("ERROR: Block production handover failed.")
......
此差异已折叠。
......@@ -47,7 +47,7 @@ class WalletMgr(object):
time.sleep(1)
return True
def create(self, name, accounts=None):
def create(self, name, accounts=None, exitOnError=True):
wallet=self.wallets.get(name)
if wallet is not None:
if Utils.Debug: Utils.Print("Wallet \"%s\" already exists. Returning same." % name)
......@@ -59,6 +59,10 @@ class WalletMgr(object):
#Utils.Print("create: %s" % (retStr))
m=p.search(retStr)
if m is None:
if exitOnError:
Utils.cmdError("could not create wallet %s" % (name))
errorExit("Failed to create wallet %s" % (name))
Utils.Print("ERROR: wallet password parser failure")
return None
p=m.group(1)
......
......@@ -21,6 +21,7 @@ import shutil
Print=testUtils.Utils.Print
errorExit=Utils.errorExit
StagedNodeInfo=namedtuple("StagedNodeInfo", "config logging")
......@@ -192,11 +193,6 @@ def stageScenario(stagedNodeInfos):
def cleanStaging():
os.path.exists(stagingDir) and shutil.rmtree(stagingDir)
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
def error(msg="", errorCode=1):
Print("ERROR:", msg)
......@@ -269,9 +265,6 @@ def myTest(transWillEnterBlock):
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))
......@@ -281,9 +274,6 @@ def myTest(transWillEnterBlock):
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
defproduceraAccount=testUtils.Cluster.defproduceraAccount
......@@ -338,14 +328,14 @@ def myTest(transWillEnterBlock):
return False
Print("Get details for transaction %s" % (transId))
transaction=node2.getTransaction(transId)
transaction=node2.getTransaction(transId, exitOnError=True)
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)
block=node2.getBlock(blockNum, exitOnError=True)
cycles=block["cycles"]
if len(cycles) > 0:
blockTransSignature=cycles[0][0]["user_input"][0]["signatures"][0]
......
......@@ -15,10 +15,7 @@ import os
###############################################################
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
errorExit=Utils.errorExit
args = TestHelper.parse_args({"-p","--dump-error-details","-v","--leave-running","--clean-run"})
pnodes=args.p
......
......@@ -8,10 +8,7 @@ from TestHelper import TestHelper
import random
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
errorExit=Utils.errorExit
args=TestHelper.parse_args({"-p","-n","-d","-s","--nodes-file","--seed"
,"--dump-error-details","-v","--leave-running","--clean-run"})
......
......@@ -13,10 +13,7 @@ import subprocess
###############################################################
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
errorExit=Utils.errorExit
args = TestHelper.parse_args({"--dump-error-details","-v","--leave-running","--only-bios","--clean-run"})
debug=args.v
......
......@@ -17,16 +17,9 @@ import re
Print=Utils.Print
errorExit=Utils.errorExit
cmdError=Utils.cmdError
from core_symbol import CORE_SYMBOL
def cmdError(name, cmdCode=0, exitNow=False):
msg="FAILURE - %s%s" % (name, ("" if cmdCode == 0 else (" returned error code %d" % cmdCode)))
if exitNow:
errorExit(msg, True)
else:
Print(msg)
args = TestHelper.parse_args({"--host","--port","--prod-count","--defproducera_prvt_key","--defproducerb_prvt_key","--mongodb"
,"--dump-error-details","--dont-launch","--keep-logs","-v","--leave-running","--only-bios","--clean-run"
,"--sanity-test"})
......@@ -121,9 +114,6 @@ try:
testWalletName="test"
Print("Creating wallet \"%s\"." % (testWalletName))
testWallet=walletMgr.create(testWalletName, [cluster.eosioAccount,cluster.defproduceraAccount,cluster.defproducerbAccount])
if testWallet is None:
cmdError("eos wallet create")
errorExit("Failed to create wallet %s." % (testWalletName))
Print("Wallet \"%s\" password=%s." % (testWalletName, testWallet.password.encode("utf-8")))
......@@ -136,9 +126,6 @@ try:
defproduceraWalletName="defproducera"
Print("Creating wallet \"%s\"." % (defproduceraWalletName))
defproduceraWallet=walletMgr.create(defproduceraWalletName)
if defproduceraWallet is None:
cmdError("eos wallet create")
errorExit("Failed to create wallet %s." % (defproduceraWalletName))
Print("Wallet \"%s\" password=%s." % (defproduceraWalletName, defproduceraWallet.password.encode("utf-8")))
......@@ -209,30 +196,19 @@ try:
errorExit("FAILURE - wallet keys did not include %s" % (noMatch), raw=True)
node=cluster.getNode(0)
if node is None:
errorExit("Cluster in bad state, received None node")
Print("Validating accounts before user accounts creation")
cluster.validateAccounts(None)
# create accounts via eosio as otherwise a bid is needed
Print("Create new account %s via %s" % (testeraAccount.name, cluster.eosioAccount.name))
transId=node.createInitializeAccount(testeraAccount, cluster.eosioAccount, stakedDeposit=0, waitForTransBlock=False)
if transId is None:
cmdError("%s create account" % (testeraAccount.name))
errorExit("Failed to create account %s" % (testeraAccount.name))
transId=node.createInitializeAccount(testeraAccount, cluster.eosioAccount, stakedDeposit=0, waitForTransBlock=False, exitOnError=True)
Print("Create new account %s via %s" % (currencyAccount.name, cluster.eosioAccount.name))
transId=node.createInitializeAccount(currencyAccount, cluster.eosioAccount, stakedDeposit=5000)
if transId is None:
cmdError("%s create account" % (ClientName))
errorExit("Failed to create account %s" % (currencyAccount.name))
transId=node.createInitializeAccount(currencyAccount, cluster.eosioAccount, stakedDeposit=5000, exitOnError=True)
Print("Create new account %s via %s" % (exchangeAccount.name, cluster.eosioAccount.name))
transId=node.createInitializeAccount(exchangeAccount, cluster.eosioAccount, waitForTransBlock=True)
if transId is None:
cmdError("%s create account" % (ClientName))
errorExit("Failed to create account %s" % (exchangeAccount.name))
transId=node.createInitializeAccount(exchangeAccount, cluster.eosioAccount, waitForTransBlock=True, exitOnError=True)
Print("Validating accounts after user accounts creation")
accounts=[testeraAccount, currencyAccount, exchangeAccount]
......@@ -244,10 +220,7 @@ try:
transferAmount="97.5321 {0}".format(CORE_SYMBOL)
Print("Transfer funds %s from account %s to %s" % (transferAmount, defproduceraAccount.name, testeraAccount.name))
if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer") is None:
cmdError("%s transfer" % (ClientName))
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, defproduceraAccount.name, testeraAccount.name))
node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer")
expectedAmount=transferAmount
Print("Verify transfer, Expected: %s" % (expectedAmount))
......@@ -259,10 +232,7 @@ try:
transferAmount="0.0100 {0}".format(CORE_SYMBOL)
Print("Force transfer funds %s from account %s to %s" % (
transferAmount, defproduceraAccount.name, testeraAccount.name))
if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer", force=True) is None:
cmdError("%s transfer" % (ClientName))
errorExit("Failed to force transfer funds %d from account %s to %s" % (
transferAmount, defproduceraAccount.name, testeraAccount.name))
node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer", force=True)
expectedAmount="97.5421 {0}".format(CORE_SYMBOL)
Print("Verify transfer, Expected: %s" % (expectedAmount))
......@@ -289,10 +259,6 @@ try:
Print("Transfer funds %s from account %s to %s" % (
transferAmount, testeraAccount.name, currencyAccount.name))
trans=node.transferFunds(testeraAccount, currencyAccount, transferAmount, "test transfer a->b")
if trans is None:
cmdError("%s transfer" % (ClientName))
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, testeraAccount.name, currencyAccount.name))
transId=Node.getTransId(trans)
expectedAmount="98.0311 {0}".format(CORE_SYMBOL) # 5000 initial deposit
......@@ -303,8 +269,7 @@ try:
errorExit("Transfer verification failed. Excepted %s, actual: %s" % (expectedAmount, actualAmount))
Print("Validate last action for account %s" % (testeraAccount.name))
actions=node.getActions(testeraAccount, -1, -1)
assert(actions)
actions=node.getActions(testeraAccount, -1, -1, exitOnError=True)
try:
if not enableMongo:
assert(actions["actions"][0]["action_trace"]["act"]["name"] == "transfer")
......@@ -316,14 +281,10 @@ try:
node.waitForTransInBlock(transId)
transaction=node.getTransaction(transId)
if transaction is None:
cmdError("%s get transaction trans_id" % (ClientName))
errorExit("Failed to retrieve transaction details %s" % (transId))
transaction=node.getTransaction(transId, exitOnError=True)
typeVal=None
amountVal=None
assert(transaction)
key=""
try:
if not enableMongo:
......@@ -428,9 +389,8 @@ try:
errorExit("FAILURE - currency1111 balance check failed. Expected: %s, Recieved %s" % (expected, actual), raw=True)
Print("Verify currency1111 contract has proper total supply of CUR (via get currency1111 stats)")
res=node.getCurrencyStats(contract, "CUR")
res=node.getCurrencyStats(contract, "CUR", exitOnError=True)
try:
assert(res)
assert(res["CUR"]["supply"] == "100000.0000 CUR")
except (AssertionError, KeyError) as _:
Print("ERROR: Failed get currecy stats assertion. %s" % (res))
......@@ -508,8 +468,8 @@ try:
Print("Test for block decoded packed transaction (issue 2932)")
blockId=node.getBlockIdByTransId(transId)
assert(blockId)
block=node.getBlock(blockId)
assert(block)
block=node.getBlock(blockId, exitOnError=True)
transactions=None
try:
if not enableMongo:
......@@ -669,17 +629,11 @@ try:
code="currency1111"
pType="transfer"
requirement="active"
trans=node.setPermission(testeraAccount.name, code, pType, requirement, waitForTransBlock=True)
if trans is None:
cmdError("%s set action permission set" % (ClientName))
errorExit("Failed to set permission")
trans=node.setPermission(testeraAccount.name, code, pType, requirement, waitForTransBlock=True, exitOnError=True)
Print("remove permission")
requirement="null"
trans=node.setPermission(testeraAccount.name, code, pType, requirement, waitForTransBlock=True)
if trans is None:
cmdError("%s set action permission set" % (ClientName))
errorExit("Failed to remove permission")
trans=node.setPermission(testeraAccount.name, code, pType, requirement, waitForTransBlock=True, exitOnError=True)
Print("Locking all wallets.")
if not walletMgr.lockAllWallets():
......@@ -692,10 +646,7 @@ try:
errorExit("Failed to unlock wallet %s" % (defproduceraWallet.name))
Print("Get account defproducera")
account=node.getEosAccount(defproduceraAccount.name)
if account is None:
cmdError("%s get account" % (ClientName))
errorExit("Failed to get account %s" % (defproduceraAccount.name))
account=node.getEosAccount(defproduceraAccount.name, exitOnError=True)
Print("Unlocking wallet \"%s\"." % (defproduceraWallet.name))
if not walletMgr.unlockWallet(testWallet):
......@@ -711,14 +662,11 @@ try:
if enableMongo:
start=2 # block 1 (genesis block) is not signaled to the plugins, so not available in DB
for blockNum in range(start, currentBlockNum+1):
block=node.getBlock(blockNum, silentErrors=False)
if block is None:
cmdError("%s get block" % (ClientName))
errorExit("get block by num %d" % blockNum)
block=node.getBlock(blockNum, silentErrors=False, exitOnError=True)
if enableMongo:
blockId=block["block_id"]
block2=node.getBlockById(blockId)
block2=node.getBlockByIdMdb(blockId)
if block2 is None:
errorExit("mongo get block by id %s" % blockId)
......
......@@ -102,9 +102,6 @@ try:
errorExit("Failed to stand up eos walletd.")
testWallet=walletMgr.create(testWalletName, [cluster.eosioAccount])
if testWallet is None:
Utils.cmdError("eos wallet create")
errorExit("Failed to create wallet %s." % (testWalletName))
for _, account in cluster.defProducerAccounts.items():
walletMgr.importKey(account, testWallet, ignoreDupKeyWarning=True)
......@@ -113,17 +110,9 @@ try:
nodes=[]
nodes.append(cluster.getNode(0))
if nodes[0] is None:
errorExit("Cluster in bad state, received None node")
nodes.append(cluster.getNode(1))
if nodes[1] is None:
errorExit("Cluster in bad state, received None node")
nodes.append(cluster.getNode(2))
if nodes[2] is None:
errorExit("Cluster in bad state, received None node")
nodes.append(cluster.getNode(3))
if nodes[3] is None:
errorExit("Cluster in bad state, received None node")
for account in accounts:
......@@ -132,37 +121,21 @@ try:
# create accounts via eosio as otherwise a bid is needed
for account in accounts:
Print("Create new account %s via %s" % (account.name, cluster.eosioAccount.name))
trans=nodes[0].createInitializeAccount(account, cluster.eosioAccount, stakedDeposit=500000, waitForTransBlock=False, stakeNet=50000, stakeCPU=50000, buyRAM=50000)
if trans is None:
Utils.cmdError("%s create account" % (account.name))
errorExit("Failed to create account %s" % (account.name))
trans=nodes[0].createInitializeAccount(account, cluster.eosioAccount, stakedDeposit=500000, waitForTransBlock=False, stakeNet=50000, stakeCPU=50000, buyRAM=50000, exitOnError=True)
transferAmount="70000000.0000 {0}".format(CORE_SYMBOL)
Print("Transfer funds %s from account %s to %s" % (transferAmount, cluster.eosioAccount.name, account.name))
if nodes[0].transferFunds(cluster.eosioAccount, account, transferAmount, "test transfer") is None:
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, cluster.eosioAccount.name, account.name))
trans=nodes[0].delegatebw(account, 1000000.0000, 68000000.0000)
if trans is None:
Utils.cmdError("delegate bandwidth for %s" % (account.name))
errorExit("Failed to delegate bandwidth for %s" % (account.name))
nodes[0].transferFunds(cluster.eosioAccount, account, transferAmount, "test transfer")
trans=nodes[0].delegatebw(account, 1000000.0000, 68000000.0000, exitOnError=True)
contractAccount=cluster.createAccountKeys(1)[0]
contractAccount.name="contracttest"
walletMgr.importKey(contractAccount, testWallet)
Print("Create new account %s via %s" % (contractAccount.name, cluster.eosioAccount.name))
trans=nodes[0].createInitializeAccount(contractAccount, cluster.eosioAccount, stakedDeposit=500000, waitForTransBlock=False, stakeNet=50000, stakeCPU=50000, buyRAM=50000)
if trans is None:
Utils.cmdError("%s create account" % (contractAccount.name))
errorExit("Failed to create account %s" % (contractAccount.name))
trans=nodes[0].createInitializeAccount(contractAccount, cluster.eosioAccount, stakedDeposit=500000, waitForTransBlock=False, stakeNet=50000, stakeCPU=50000, buyRAM=50000, exitOnError=True)
transferAmount="90000000.0000 {0}".format(CORE_SYMBOL)
Print("Transfer funds %s from account %s to %s" % (transferAmount, cluster.eosioAccount.name, contractAccount.name))
if nodes[0].transferFunds(cluster.eosioAccount, contractAccount, transferAmount, "test transfer") is None:
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, cluster.eosioAccount.name, contractAccount.name))
trans=nodes[0].delegatebw(contractAccount, 1000000.0000, 88000000.0000)
if trans is None:
Utils.cmdError("delegate bandwidth for %s" % (contractAccount.name))
errorExit("Failed to delegate bandwidth for %s" % (contractAccount.name))
nodes[0].transferFunds(cluster.eosioAccount, contractAccount, transferAmount, "test transfer")
trans=nodes[0].delegatebw(contractAccount, 1000000.0000, 88000000.0000, exitOnError=True)
contractDir="contracts/integration_test"
wastFile="contracts/integration_test/integration_test.wast"
......
......@@ -27,18 +27,12 @@ class ProducerToNode:
def vote(node, account, producers):
Print("Votes for %s" % (account.name))
trans=node.vote(account, producers, waitForTransBlock=False)
if trans is None:
Utils.cmdError("voting with %s" % (account.name))
errorExit("Failed to vote with account %s" % (account.name))
trans=node.vote(account, producers, waitForTransBlock=False, exitOnError=True)
return trans
def getBlockProducer(node, blockNum):
node.waitForBlock(blockNum)
block=node.getBlock(blockNum)
if block is None:
Utils.cmdError("could not get block number %s" % (blockNum))
errorExit("Failed to get block")
block=node.getBlock(blockNum, exitOnError=True)
blockProducer=block["producer"]
if blockProducer is None:
Utils.cmdError("could not get producer for block number %s" % (blockNum))
......@@ -240,9 +234,6 @@ try:
errorExit("Failed to stand up eos walletd.")
testWallet=walletMgr.create(testWalletName, [cluster.eosioAccount,accounts[0],accounts[1],accounts[2],accounts[3],accounts[4]])
if testWallet is None:
Utils.cmdError("eos wallet create")
errorExit("Failed to create wallet %s." % (testWalletName))
for _, account in cluster.defProducerAccounts.items():
walletMgr.importKey(account, testWallet, ignoreDupKeyWarning=True)
......@@ -253,41 +244,22 @@ try:
node=cluster.getNode(i)
node.producers=Cluster.parseProducers(i)
for prod in node.producers:
trans=node.regproducer(cluster.defProducerAccounts[prod], "http::/mysite.com", 0, waitForTransBlock=False)
if trans is None:
Utils.cmdError("registering producer %s" % (prod.name))
errorExit("Failed registering producer %s" % (prod.name))
trans=node.regproducer(cluster.defProducerAccounts[prod], "http::/mysite.com", 0, waitForTransBlock=False, exitOnError=True)
node0=cluster.getNode(0)
if node0 is None:
errorExit("Cluster in bad state, received None node")
node1=cluster.getNode(1)
if node1 is None:
errorExit("Cluster in bad state, received None node")
node2=cluster.getNode(2)
if node2 is None:
errorExit("Cluster in bad state, received None node")
node3=cluster.getNode(3)
if node3 is None:
errorExit("Cluster in bad state, received None node")
node=node0
# create accounts via eosio as otherwise a bid is needed
for account in accounts:
Print("Create new account %s via %s" % (account.name, cluster.eosioAccount.name))
trans=node.createInitializeAccount(account, cluster.eosioAccount, stakedDeposit=0, waitForTransBlock=False, stakeNet=1000, stakeCPU=1000, buyRAM=1000)
if trans is None:
Utils.cmdError("%s create account" % (account.name))
errorExit("Failed to create account %s" % (account.name))
trans=node.createInitializeAccount(account, cluster.eosioAccount, stakedDeposit=0, waitForTransBlock=False, stakeNet=1000, stakeCPU=1000, buyRAM=1000, exitOnError=True)
transferAmount="100000000.0000 {0}".format(CORE_SYMBOL)
Print("Transfer funds %s from account %s to %s" % (transferAmount, cluster.eosioAccount.name, account.name))
if node.transferFunds(cluster.eosioAccount, account, transferAmount, "test transfer") is None:
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, cluster.eosioAccount.name, account.name))
trans=node.delegatebw(account, 20000000.0000, 20000000.0000)
if trans is None:
Utils.cmdError("delegate bandwidth for %s" % (account.name))
errorExit("Failed to delegate bandwidth for %s" % (account.name))
node.transferFunds(cluster.eosioAccount, account, transferAmount, "test transfer")
trans=node.delegatebw(account, 20000000.0000, 20000000.0000, exitOnError=True)
# containers for tracking producers
prodsActive={}
......
......@@ -23,7 +23,7 @@ DEFAULT_PORT=ports[0]
parser = argparse.ArgumentParser(add_help=False)
Print=testUtils.Utils.Print
errorExit=testUtils.Utils.errorExit
errorExit=Utils.errorExit
# Override default help argument so that only --help (and not -h) can call help
parser.add_argument('-?', action='help', default=argparse.SUPPRESS,
......@@ -111,9 +111,6 @@ if walletMgr.launch() is False:
testWalletName="test"
Print("Creating wallet \"%s\"." % (testWalletName))
testWallet=walletMgr.create(testWalletName)
if testWallet is None:
cmdError("eos wallet create")
errorExit("Failed to create wallet %s." % (testWalletName))
for account in accounts:
Print("Importing keys for account %s into wallet %s." % (account.name, testWallet.name))
......@@ -124,9 +121,6 @@ for account in accounts:
defproduceraWalletName="defproducera"
Print("Creating wallet \"%s\"." % (defproduceraWalletName))
defproduceraWallet=walletMgr.create(defproduceraWalletName)
if defproduceraWallet is None:
cmdError("eos wallet create")
errorExit("Failed to create wallet %s." % (defproduceraWalletName))
defproduceraAccount=testUtils.Cluster.defproduceraAccount
# defproducerbAccount=testUtils.Cluster.defproducerbAccount
......@@ -137,8 +131,6 @@ if not walletMgr.importKey(defproduceraAccount, defproduceraWallet):
errorExit("Failed to import key for account %s" % (defproduceraAccount.name))
node0=cluster.getNode(0)
if node0 is None:
errorExit("cluster in bad state, received None node")
# eosio should have the same key as defproducera
eosio = copy.copy(defproduceraAccount)
......@@ -146,7 +138,7 @@ eosio.name = "eosio"
Print("Info of each node:")
for i in range(len(hosts)):
node = cluster.getNode(0)
node = node0
cmd="%s %s get info" % (testUtils.Utils.EosClientPath, node.endpointArgs)
trans = node.runCmdReturnJson(cmd)
Print("host %s: %s" % (hosts[i], trans))
......
......@@ -34,7 +34,7 @@ class StressNetwork:
ta.name = self.randAcctName()
acc1 = copy.copy(ta)
print("creating new account %s" % (ta.name))
tr = node.createAccount(ta, eosio, stakedDeposit=0, waitForTransBlock=True)
tr = node.createAccount(ta, eosio, stakedDeposit=0, waitForTransBlock=True, exitOnError=True)
trid = node.getTransId(tr)
if trid is None:
return ([], "", 0.0, "failed to create account")
......@@ -43,7 +43,7 @@ class StressNetwork:
ta.name = self.randAcctName()
acc2 = copy.copy(ta)
print("creating new account %s" % (ta.name))
tr = node.createAccount(ta, eosio, stakedDeposit=0, waitForTransBlock=True)
tr = node.createAccount(ta, eosio, stakedDeposit=0, waitForTransBlock=True, exitOnError=True)
trid = node.getTransId(tr)
if trid is None:
return ([], "", 0.0, "failed to create account")
......
......@@ -6,7 +6,6 @@ from WalletMgr import WalletMgr
from TestHelper import TestHelper
import random
import traceback
###############################################################
# Test for different nodes restart scenarios.
......@@ -25,11 +24,7 @@ import traceback
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
traceback.print_stack(limit=-1)
exit(errorCode)
errorExit=Utils.errorExit
args=TestHelper.parse_args({"-p","-d","-s","-c","--kill-sig","--kill-count","--keep-logs","--p2p-plugin"
,"--dump-error-details","-v","--leave-running","--clean-run"})
......@@ -88,8 +83,6 @@ try:
walletName="MyWallet"
Print("Creating wallet %s if one doesn't already exist." % walletName)
wallet=walletMgr.create(walletName, [cluster.eosioAccount,cluster.defproduceraAccount,cluster.defproducerbAccount])
if wallet is None:
errorExit("Failed to create wallet %s" % (walletName))
Print ("Populate wallet with %d accounts." % (accountsCount))
if not cluster.populateWallet(accountsCount, wallet):
......
......@@ -6,6 +6,7 @@ import inspect
import json
import shlex
from sys import stdout
import traceback
###########################################################################################
class Utils:
......@@ -81,15 +82,13 @@ class Utils:
@staticmethod
def errorExit(msg="", raw=False, errorCode=1):
Utils.Print("ERROR:" if not raw else "", msg)
traceback.print_stack(limit=-1)
exit(errorCode)
@staticmethod
def cmdError(name, cmdCode=0, exitNow=False):
def cmdError(name, cmdCode=0):
msg="FAILURE - %s%s" % (name, ("" if cmdCode == 0 else (" returned error code %d" % cmdCode)))
if exitNow:
Utils.errorExit(msg, True)
else:
Utils.Print(msg)
Utils.Print(msg)
@staticmethod
def waitForObj(lam, timeout=None):
......
......@@ -14,10 +14,7 @@ import signal
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
errorExit=Utils.errorExit
args = TestHelper.parse_args({"--keep-logs","--dump-error-details","-v","--leave-running","--clean-run"})
debug=args.v
......@@ -81,8 +78,6 @@ try:
errorExit("Failed to stand up eos cluster.")
node=cluster.getNode(0)
if node is None:
errorExit("Cluster in bad state, received None node")
Print("Kill cluster nodes.")
cluster.killall(allInstances=killAll)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册