Skip to content

Commit

Permalink
Cleanup of errorExit method. GH EOSIO#5199
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjohnson5972 committed Sep 6, 2018
1 parent 3df6060 commit 14ec763
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions tests/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,10 @@ def populateWallet(self, accountsCount, wallet):
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):
Expand Down
12 changes: 6 additions & 6 deletions tests/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def getTransactionMdb(self, transId, silentErrors=False, exitOnError=False):
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
Expand Down Expand Up @@ -469,7 +469,7 @@ def getEosAccountFromDb(self, name, exitOnError=False):
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
Expand Down Expand Up @@ -596,12 +596,12 @@ def transferFunds(self, source, destination, amountStr, memo="memo", force=False
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)

Expand Down Expand Up @@ -901,7 +901,7 @@ def processCmd(self, cmd, cmdDesc, silentErrors=True, exitOnError=False, exitMsg
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

Expand All @@ -913,7 +913,7 @@ def waitForTransBlockIfNeeded(self, trans, waitForTransBlock, exitOnError=False)
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

Expand Down
2 changes: 1 addition & 1 deletion tests/WalletMgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def create(self, name, accounts=None, exitOnError=True):
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
Expand Down
5 changes: 3 additions & 2 deletions tests/nodeos_under_min_avail_ram.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import math
import re

Print=Utils.Print
errorExit=Utils.errorExit

class NamedAccounts:

def __init__(self, cluster, numAccounts):
Expand Down Expand Up @@ -50,8 +53,6 @@ def setName(self, num):
# --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
Expand Down
18 changes: 9 additions & 9 deletions tests/nodeos_voting_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -211,14 +211,14 @@ def verifyProductionRounds(trans, node, prodsActive, rounds):
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"
Expand All @@ -232,7 +232,7 @@ def verifyProductionRounds(trans, node, prodsActive, rounds):
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]])

Expand Down

0 comments on commit 14ec763

Please sign in to comment.