Skip to content

Commit

Permalink
Add test for get actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cijujohn committed May 9, 2018
1 parent 08666f9 commit ac4c8a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/nodeos_run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def cmdError(name, cmdCode=0, exitNow=False):
if trans is None:
cmdError("%s transfer" % (ClientName))
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, initaAccount.name, testeraAccount.name))
transferAmount, testeraAccount.name, currencyAccount.name))
transId=testUtils.Node.getTransId(trans)

expectedAmount="98.0311 EOS" # 5000 initial deposit
Expand All @@ -299,6 +299,15 @@ def cmdError(name, cmdCode=0, exitNow=False):
cmdError("FAILURE - transfer failed")
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)
try:
assert(actions["actions"][0]["action_trace"]["act"]["name"] == "transfer")
except AssertionError as e:
print("Last action validation failed. Actions: %s" % (actions))
raise

# Pre-mature exit on slim branch. This will pushed futher out as code stablizes.
testSuccessful=True
exit(0)
Expand Down
16 changes: 16 additions & 0 deletions tests/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,25 @@ def getAccountsByKey(self, key):
Utils.Print("ERROR: Exception during accounts by key retrieval. %s" % (msg))
return None

# Get actions mapped to an account (cleos get actions)
def getActions(self, account, pos=-1, offset=-1):
assert(isinstance(account, Account), isinstance(pos, int), isinstance(offset, int))

cmd="%s %s get actions -j %s %d %d" % (Utils.EosClientPath, self.endpointArgs, account.name, pos, offset)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
try:
actions=Node.runCmdReturnJson(cmd)
return actions
except subprocess.CalledProcessError as ex:
msg=ex.output.decode("utf-8")
Utils.Print("ERROR: Exception during actions by account retrieval. %s" % (msg))
return None

# Gets accounts mapped to key. Returns array
def getAccountsArrByKey(self, key):
trans=self.getAccountsByKey(key)
assert(trans)
assert("account_names" in trans)
accounts=trans["account_names"]
return accounts

Expand Down

0 comments on commit ac4c8a4

Please sign in to comment.