Skip to content

Commit 9a8dad3

Browse files
authored
Merge pull request #1081 from AntelopeIO/GH-1078-distributed-trx-test
Test: Wait for finalization to verify fund transfers
2 parents ae0f627 + 24ffc3c commit 9a8dad3

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

tests/TestHarness/Cluster.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ def launchUnstarted(self, numToLaunch=1):
756756

757757
# Spread funds across accounts with transactions spread through cluster nodes.
758758
# Validate transactions are synchronized on root node
759-
def spreadFunds(self, source, accounts, amount=1):
759+
def spreadFunds(self, source, accounts, amount=1, waitForFinalization=False):
760760
assert(source)
761761
assert(isinstance(source, Account))
762762
assert(accounts)
@@ -819,9 +819,14 @@ def spreadFunds(self, source, accounts, amount=1):
819819
# As an extra step wait for last transaction on the root node
820820
node=self.nodes[0]
821821
if Utils.Debug: Utils.Print("Wait for transaction id %s on node port %d" % (transId, node.port))
822-
if node.waitForTransactionInBlock(transId) is False:
823-
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, node.port))
824-
return False
822+
if waitForFinalization:
823+
if node.waitForTransFinalization(transId) is False:
824+
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a final block on server port %d." % (transId, node.port))
825+
return False
826+
else:
827+
if node.waitForTransactionInBlock(transId) is False:
828+
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, node.port))
829+
return False
825830

826831
return True
827832

@@ -850,7 +855,7 @@ def validateSpreadFunds(self, initialBalances, transferAmount, source, accounts)
850855

851856
return True
852857

853-
def spreadFundsAndValidate(self, transferAmount=1):
858+
def spreadFundsAndValidate(self, transferAmount=1, waitForFinalization=False):
854859
"""Sprays 'transferAmount' funds across configured accounts and validates action. The spray is done in a trickle down fashion with account 1
855860
receiving transferAmount*n SYS and forwarding x-transferAmount funds. Transfer actions are spread round-robin across the cluster to vaidate system cohesiveness."""
856861

@@ -859,7 +864,7 @@ def spreadFundsAndValidate(self, transferAmount=1):
859864
assert(initialBalances)
860865
assert(isinstance(initialBalances, dict))
861866

862-
if False == self.spreadFunds(self.defproduceraAccount, self.accounts, transferAmount):
867+
if False == self.spreadFunds(self.defproduceraAccount, self.accounts, transferAmount, waitForFinalization=waitForFinalization):
863868
Utils.Print("ERROR: Failed to spread funds across nodes.")
864869
return False
865870

tests/distributed-transactions-test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
errorExit("Accounts creation failed.")
101101

102102
Print("Spread funds and validate")
103-
if not cluster.spreadFundsAndValidate(10):
103+
# if activateIF then irreversible node needs funds to be irreversible before validation
104+
if not cluster.spreadFundsAndValidate(10, waitForFinalization=activateIF):
104105
errorExit("Failed to spread and validate funds.")
105106

106107
print("Funds spread validated")

0 commit comments

Comments
 (0)