提交 14ec763a 编写于 作者: B Brian Johnson

Cleanup of errorExit method. GH #5199

上级 3df60605
......@@ -446,10 +446,10 @@ class Cluster(object):
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))
Utils.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))
Utils.errorExit("Failed to retrieve node %d" % (nodeId))
return self.nodes[nodeId]
def getNodes(self):
......
......@@ -289,7 +289,7 @@ class Node(object):
errorMsg="Exception during get db node get trans in mongodb with transaction id=%s. %s" % (transId,msg)
if exitOnError:
Utils.cmdError("" % (errorMsg))
errorExit("Failed to retrieve transaction in mongodb for transaction id=%s" % (transId))
Utils.errorExit("Failed to retrieve transaction in mongodb for transaction id=%s" % (transId))
elif not silentErrors:
Utils.Print("ERROR: %s" % (errorMsg))
return None
......@@ -469,7 +469,7 @@ class Node(object):
msg=ex.output.decode("utf-8")
if exitOnError:
Utils.cmdError("Exception during get account from db for %s. %s" % (name, msg))
errorExit("Failed during get account from db for %s. %s" % (name, msg))
Utils.errorExit("Failed during get account from db for %s. %s" % (name, msg))
Utils.Print("ERROR: Exception during get account from db for %s. %s" % (name, msg))
return None
......@@ -596,12 +596,12 @@ class Node(object):
Utils.Print("ERROR: Exception during funds transfer. %s" % (msg))
if exitOnError:
Utils.cmdError("could not transfer \"%s\" from %s to %s" % (amountStr, source, destination))
errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination))
Utils.errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination))
return None
if trans is None:
Utils.cmdError("could not transfer \"%s\" from %s to %s" % (amountStr, source, destination))
errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination))
Utils.errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination))
return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)
......@@ -901,7 +901,7 @@ class Node(object):
exitMsg=""
if exitOnError and trans is None:
Utils.cmdError("could not %s - %s" % (cmdDesc,exitMsg))
errorExit("Failed to %s" % (cmdDesc))
Utils.errorExit("Failed to %s" % (cmdDesc))
return trans
......@@ -913,7 +913,7 @@ class Node(object):
if not self.waitForTransInBlock(transId):
if exitOnError:
Utils.cmdError("transaction with id %s never made it to a block" % (transId))
errorExit("Failed to find transaction with id %s in a block before timeout" % (transId))
Utils.errorExit("Failed to find transaction with id %s in a block before timeout" % (transId))
return None
return trans
......
......@@ -71,7 +71,7 @@ class WalletMgr(object):
if m is None:
if exitOnError:
Utils.cmdError("could not create wallet %s" % (name))
errorExit("Failed to create wallet %s" % (name))
Utils.errorExit("Failed to create wallet %s" % (name))
Utils.Print("ERROR: wallet password parser failure")
return None
......
......@@ -13,6 +13,9 @@ import decimal
import math
import re
Print=Utils.Print
errorExit=Utils.errorExit
class NamedAccounts:
def __init__(self, cluster, numAccounts):
......@@ -50,8 +53,6 @@ class NamedAccounts:
# --dump-error-details <Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout>
# --keep-logs <Don't delete var/lib/node_* folders upon test completion>
###############################################################
Print=Utils.Print
errorExit=Utils.errorExit
args = TestHelper.parse_args({"--dump-error-details","--keep-logs","-v","--leave-running","--clean-run"})
Utils.Debug=args.v
......
......@@ -36,7 +36,7 @@ def getBlockProducer(node, blockNum):
blockProducer=block["producer"]
if blockProducer is None:
Utils.cmdError("could not get producer for block number %s" % (blockNum))
errorExit("Failed to get block's producer")
Utils.errorExit("Failed to get block's producer")
return blockProducer
def getNodeNum(cluster, node):
......@@ -55,10 +55,10 @@ def validBlockProducer(prodsActive, prodsSeen, blockNum, node):
blockProducer=getBlockProducer(node, blockNum)
if blockProducer not in prodsActive:
Utils.cmdError("unexpected block producer %s at blockNum=%s" % (blockProducer,blockNum))
errorExit("Failed because of invalid block producer")
Utils.errorExit("Failed because of invalid block producer")
if not prodsActive[blockProducer]:
Utils.cmdError("block producer %s for blockNum=%s not elected, belongs to node %s" % (blockProducer, blockNum, ProducerToNode.map[blockProducer]))
errorExit("Failed because of incorrect block producer")
Utils.errorExit("Failed because of incorrect block producer")
prodsSeen[blockProducer]=True
def getNextCleanProductionCycle(trans, node):
......@@ -149,7 +149,7 @@ def verifyProductionRounds(trans, node, prodsActive, rounds):
# each new set of 12 blocks should have a different blockProducer
if lastBlockProducer is not None and lastBlockProducer==getBlockProducer(node, blockNum):
Utils.cmdError("expected blockNum %s to be produced by any of the valid producers except %s" % (blockNum, lastBlockProducer))
errorExit("Failed because of incorrect block producer order")
Utils.errorExit("Failed because of incorrect block producer order")
# make sure that the next set of 12 blocks all have the same blockProducer
lastBlockProducer=getBlockProducer(node, blockNum)
......@@ -167,14 +167,14 @@ def verifyProductionRounds(trans, node, prodsActive, rounds):
printStr+=" "
newBlockNum+=1
Utils.cmdError("expected blockNum %s (started from %s) to be produced by %s, but produded by %s: round=%s, prod slot=%s, prod num=%s - %s" % (blockNum, startingFrom, lastBlockProducer, blockProducer, i, j, k, printStr))
errorExit("Failed because of incorrect block producer order")
Utils.errorExit("Failed because of incorrect block producer order")
blockNum+=1
# make sure that we have seen all 21 producers
prodsSeenKeys=prodsSeen.keys()
if len(prodsSeenKeys)!=21:
Utils.cmdError("only saw %s producers of expected 21. At blockNum %s only the following producers were seen: %s" % (len(prodsSeenKeys), blockNum, ",".join(prodsSeenKeys)))
errorExit("Failed because of missing block producers")
Utils.errorExit("Failed because of missing block producers")
Utils.Debug=temp
......@@ -211,14 +211,14 @@ try:
Print("Stand up cluster")
if cluster.launch(prodCount=prodCount, onlyBios=False, dontKill=dontKill, pnodes=totalNodes, totalNodes=totalNodes, totalProducers=totalNodes*21, p2pPlugin=p2pPlugin, useBiosBootFile=False) is False:
Utils.cmdError("launcher")
errorExit("Failed to stand up eos cluster.")
Utils.errorExit("Failed to stand up eos cluster.")
Print("Validating system accounts after bootstrap")
cluster.validateAccounts(None)
accounts=cluster.createAccountKeys(5)
if accounts is None:
errorExit("FAILURE - create keys")
Utils.errorExit("FAILURE - create keys")
accounts[0].name="tester111111"
accounts[1].name="tester222222"
accounts[2].name="tester333333"
......@@ -232,7 +232,7 @@ try:
walletMgr.cleanup()
if walletMgr.launch() is False:
Utils.cmdError("%s" % (WalletdName))
errorExit("Failed to stand up eos walletd.")
Utils.errorExit("Failed to stand up eos walletd.")
testWallet=walletMgr.create(testWalletName, [cluster.eosioAccount,accounts[0],accounts[1],accounts[2],accounts[3],accounts[4]])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册