From c7177ec0c666358707721908abca6e53738a361a Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Wed, 11 Jul 2018 10:18:44 -0500 Subject: [PATCH] Added exitOnError processing to delegatebw, regproducer, and vote. --- tests/Node.py | 15 +++++++++------ tests/nodeos_voting_test.py | 15 +++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/tests/Node.py b/tests/Node.py index d7992e1fd..0cc0cfa5e 100644 --- a/tests/Node.py +++ b/tests/Node.py @@ -836,7 +836,7 @@ class Node(object): return None return trans - def delegatebw(self, fromAccount, netQuantity, cpuQuantity, toAccount=None, transferTo=False, waitForTransBlock=False): + def delegatebw(self, fromAccount, netQuantity, cpuQuantity, toAccount=None, transferTo=False, waitForTransBlock=False, exitOnError=False): if toAccount is None: toAccount=fromAccount @@ -844,29 +844,32 @@ class Node(object): transferStr="--transfer" if transferTo else "" cmd="%s -j %s %s \"%s %s\" \"%s %s\" %s" % ( cmdDesc, fromAccount.name, toAccount.name, netQuantity, CORE_SYMBOL, cpuQuantity, CORE_SYMBOL, transferStr) - trans=self.processCmd(cmd, cmdDesc, waitForTransBlock) + msg="fromAccount=%s, toAccount=%s" % (fromAccount.name, toAccount.name); + trans=self.processCmd(cmd, cmdDesc, waitForTransBlock, exitOnError=exitOnError, exitMsg=msg) transId=Node.getTransId(trans) if waitForTransBlock and not self.waitForTransInBlock(transId): return None return trans - def regproducer(self, producer, url, location, waitForTransBlock=False): + def regproducer(self, producer, url, location, waitForTransBlock=False, exitOnError=False): cmdDesc="system regproducer" cmd="%s -j %s %s %s %s" % ( cmdDesc, producer.name, producer.activePublicKey, url, location) - trans=self.processCmd(cmd, cmdDesc, waitForTransBlock) + msg="producer=%s" % (producer.name); + trans=self.processCmd(cmd, cmdDesc, waitForTransBlock, exitOnError=exitOnError, exitMsg=msg) transId=Node.getTransId(trans) if waitForTransBlock and not self.waitForTransInBlock(transId): return None return trans - def vote(self, account, producers, waitForTransBlock=False): + def vote(self, account, producers, waitForTransBlock=False, exitOnError=False): cmdDesc = "system voteproducer prods" cmd="%s -j %s %s" % ( cmdDesc, account.name, " ".join(producers)) - trans=self.processCmd(cmd, cmdDesc, waitForTransBlock) + msg="account=%s, producers=[ %s ]" % (account.name, ", ".join(producers)); + trans=self.processCmd(cmd, cmdDesc, waitForTransBlock, exitOnError=exitOnError, exitMsg=msg) transId=Node.getTransId(trans) if waitForTransBlock and not self.waitForTransInBlock(transId): diff --git a/tests/nodeos_voting_test.py b/tests/nodeos_voting_test.py index e8a46c269..e8c7612ca 100755 --- a/tests/nodeos_voting_test.py +++ b/tests/nodeos_voting_test.py @@ -27,10 +27,7 @@ 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): @@ -250,10 +247,7 @@ 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: @@ -278,10 +272,7 @@ try: 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)) + trans=node.delegatebw(account, 20000000.0000, 20000000.0000, exitOnError=True) # containers for tracking producers prodsActive={} -- GitLab