提交 2ac055fa 编写于 作者: C Ciju John

General tests cleanup. Enabling more segments of nodeos test. Tighten...

General tests cleanup. Enabling more segments of nodeos test. Tighten transaction finalization to narrow down the exact block containing the transaction. Tighter error handling. Add currency balance test. Improve transaction distribution validation mechanism.
上级 cd979827
......@@ -53,8 +53,8 @@ add_test(NAME nodeos_run_remote_test COMMAND tests/nodeos_run_remote_test.py -v
# TODO: add_test(NAME p2p_sync_test_p2_d10 COMMAND tests/p2p_tests/sync/test.sh -p 2 -d 10 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME message_storm COMMAND tests/p2p_tests/sync/test.sh -m -p 21 -n 21 -d 5 -l WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME trans_sync_across_mixed_cluster_test COMMAND tests/trans_sync_across_mixed_cluster_test.sh -p 1 -n 2 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactions-test.py -p 1 -n 4 -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO removed on slim: add_test(NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactions-test.py -p 1 -n 4 -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO removed on slim: add_test(NAME restart-scenarios-test_resync COMMAND tests/restart-scenarios-test.py -c resync -p4 -v --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# add_test(NAME restart-scenarios-test_replay COMMAND tests/restart-scenarios-test.py -c replay -p4 -v --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME consensus-validation-malicious-producers COMMAND tests/consensus-validation-malicious-producers.py -w 80 --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
......
......@@ -13,7 +13,7 @@ def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
pnodes=3
pnodes=1
# nodesFile="tests/sample-cluster-map.json"
parser = argparse.ArgumentParser()
parser.add_argument("-p", type=int, help="producing nodes count", default=pnodes)
......@@ -36,7 +36,7 @@ killEosInstances=not dontKill
topo="mesh"
delay=1
prodCount=1 # producers per producer node
total_nodes=pnodes
total_nodes=pnodes+3
actualTest="tests/distributed-transactions-test.py"
testSuccessful=False
......
......@@ -72,15 +72,14 @@ try:
if cluster.launch(pnodes, total_nodes, topo=topo, delay=delay) is False:
errorExit("Failed to stand up eos cluster.")
#exit(0)
Print ("Wait for Cluster stabilization")
# wait for cluster to start producing blocks
if not cluster.waitOnClusterBlockNumSync(3):
errorExit("Cluster never stabilized")
#exit(0)
Print("Stand up EOS wallet keosd")
walletMgr.killall()
walletMgr.cleanup()
if walletMgr.launch() is False:
errorExit("Failed to stand up keosd.")
......@@ -99,18 +98,15 @@ try:
defproducerbAccount=cluster.defproducerbAccount
eosioAccount=cluster.eosioAccount
# TBD: get account is currently failing. Enable when ready
# Print("Create accounts.")
# if not cluster.createAccounts(eosioAccount):
# errorExit("Accounts creation failed.")
Print("Create accounts.")
if not cluster.createAccounts(eosioAccount):
errorExit("Accounts creation failed.")
# TBD: Known issue (Issue 2043) that 'get currency balance' doesn't return balance.
# Uncomment when functional
# Print("Spread funds and validate")
# if not cluster.spreadFundsAndValidate(10):
# errorExit("Failed to spread and validate funds.")
Print("Spread funds and validate")
if not cluster.spreadFundsAndValidate(10):
errorExit("Failed to spread and validate funds.")
# print("Funds spread validated")
print("Funds spread validated")
testSuccessful=True
finally:
......@@ -126,6 +122,5 @@ finally:
Print("Shut down the wallet and cleanup.")
walletMgr.killall()
walletMgr.cleanup()
pass
exit(0)
......@@ -325,10 +325,6 @@ try:
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)
# This API (get accounts) is no longer supported (Issue 2876)
# expectedAccounts=[testeraAccount.name, currencyAccount.name, exchangeAccount.name]
# Print("Get accounts by key %s, Expected: %s" % (PUB_KEY3, expectedAccounts))
......@@ -351,8 +347,8 @@ try:
# if len(noMatch) > 0:
# errorExit("FAILURE - Accounts lookup by key %s. Expected: %s, Actual: %s" % (
# PUB_KEY1, expectedAccounts, actualAccounts), raw=True)
#
# This API (get servants) is no longer supported.
# This API (get servants) is no longer supported. (Issue 3160)
# expectedServants=[testeraAccount.name, currencyAccount.name]
# Print("Get %s servants, Expected: %s" % (defproduceraAccount.name, expectedServants))
# actualServants=node.getServantsArr(defproduceraAccount.name)
......@@ -403,15 +399,6 @@ try:
if typeVal != "transfer" or amountVal != 975311:
errorExit("FAILURE - get transaction trans_id failed: %s %s %s" % (transId, typeVal, amountVal), raw=True)
# This API (get transactions) is no longer supported.
# Print("Get transactions for account %s" % (testeraAccount.name))
# actualTransactions=node.getTransactionsArrByAccount(testeraAccount.name)
# if actualTransactions is None:
# cmdError("%s get transactions testera11111" % (ClientName))
# errorExit("Failed to get transactions by account %s" % (testeraAccount.name))
# if transId not in actualTransactions:
# errorExit("FAILURE - get transactions testera11111 failed", raw=True)
Print("Currency Contract Tests")
Print("verify no contract in place")
Print("Get code hash for account %s" % (currencyAccount.name))
......@@ -456,47 +443,52 @@ try:
data="{\"issuer\":\"currency1111\",\"maximum_supply\":\"100000.0000 CUR\",\"can_freeze\":\"0\",\"can_recall\":\"0\",\"can_whitelist\":\"0\"}"
opts="--permission currency1111@active"
trans=node.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
errorExit("FAILURE - create action to currency1111 contract failed", raw=True)
try:
assert(trans)
assert(trans[0])
except (AssertionError, KeyError) as _:
Print("ERROR: Failed push create action to currency1111 contract assertion. %s" % (trans))
raise
Print("push issue action to currency1111 contract")
action="issue"
data="{\"to\":\"currency1111\",\"quantity\":\"100000.0000 CUR\",\"memo\":\"issue\"}"
opts="--permission currency1111@active"
trans=node.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
errorExit("FAILURE - issue action to currency1111 contract failed", raw=True)
try:
assert(trans)
assert(trans[0])
except (AssertionError, KeyError) as _:
Print("ERROR: Failed push issue action to currency1111 contract assertion. %s" % (trans))
raise
Print("Verify currency1111 contract has proper initial balance (via get table)")
contract="currency1111"
table="accounts"
row0=node.getTableRow(contract, currencyAccount.name, table, 0)
if row0 is None:
cmdError("%s get currency1111 table currency1111 account" % (ClientName))
errorExit("Failed to retrieve contract %s table %s" % (contract, table))
balanceKey="balance"
keyKey="key"
if row0[balanceKey] != "100000.0000 CUR":
errorExit("FAILURE - Wrong currency1111 balance", raw=True)
try:
assert(row0)
assert(row0["balance"] == "100000.0000 CUR")
except (AssertionError, KeyError) as _:
Print("ERROR: Failed get table row assertion. %s" % (row0))
raise
Print("Verify currency1111 contract has proper initial balance (via get currency1111 balance)")
amountStr=node.getNodeAccountBalance("currency1111", currencyAccount.name)
amountStr=node.getTableAccountBalance("currency1111", currencyAccount.name)
expected="100000.0000 CUR"
actual=amountStr
if actual != expected:
errorExit("FAILURE - currency1111 balance check failed. Expected: %s, Recieved %s" % (expected, actual), raw=True)
# TBD: "get currency1111 stats is still not working. Enable when ready.
# Print("Verify currency1111 contract has proper total supply of CUR (via get currency1111 stats)")
# res=node.getCurrencyStats(contract, "CUR")
# if res is None or not ("supply" in res):
# cmdError("%s get currency1111 stats" % (ClientName))
# errorExit("Failed to retrieve CUR stats from contract %s" % (contract))
# if res["supply"] != "100000.0000 CUR":
# errorExit("FAILURE - get currency1111 stats failed", raw=True)
Print("Verify currency1111 contract has proper total supply of CUR (via get currency1111 stats)")
res=node.getCurrencyStats(contract, "CUR")
try:
assert(res)
assert(res["CUR"]["supply"] == "100000.0000 CUR")
except (AssertionError, KeyError) as _:
Print("ERROR: Failed get currecy stats assertion. %s" % (res))
raise
Print("push transfer action to currency1111 contract")
contract="currency1111"
......@@ -516,20 +508,30 @@ try:
errorExit("Failed to verify push message transaction id.")
Print("read current contract balance")
amountStr=node.getNodeAccountBalance("currency1111", defproduceraAccount.name)
amountStr=node.getTableAccountBalance("currency1111", defproduceraAccount.name)
expected="0.0050 CUR"
actual=amountStr
if actual != expected:
errorExit("FAILURE - Wrong currency1111 balance (expected=%s, actual=%s)" % (str(expected), str(actual)), raw=True)
amountStr=node.getNodeAccountBalance("currency1111", currencyAccount.name)
amountStr=node.getTableAccountBalance("currency1111", currencyAccount.name)
expected="99999.9950 CUR"
actual=amountStr
if actual != expected:
errorExit("FAILURE - Wrong currency1111 balance (expected=%s, actual=%s)" % (str(expected), str(actual)), raw=True)
amountStr=node.getCurrencyBalance("currency1111", currencyAccount.name, "CUR")
try:
assert(actual)
assert(isinstance(actual, str))
actual=amountStr.strip()
assert(expected == actual)
except (AssertionError, KeyError) as _:
Print("ERROR: Failed get currecy balance assertion. (expected=<%s>, actual=<%s>)" % (str(expected), str(actual)))
raise
Print("Test for block decoded packed transaction (issue 2932)")
blockId=node.getBlockIdByTransId(transId)
assert(blockId)
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册