Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Wait for finalization to verify fund transfers #1081

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def launchUnstarted(self, numToLaunch=1):

# Spread funds across accounts with transactions spread through cluster nodes.
# Validate transactions are synchronized on root node
def spreadFunds(self, source, accounts, amount=1):
def spreadFunds(self, source, accounts, amount=1, waitForFinalization=False):
assert(source)
assert(isinstance(source, Account))
assert(accounts)
Expand Down Expand Up @@ -819,9 +819,14 @@ def spreadFunds(self, source, accounts, amount=1):
# As an extra step wait for last transaction on the root node
node=self.nodes[0]
if Utils.Debug: Utils.Print("Wait for transaction id %s on node port %d" % (transId, node.port))
if node.waitForTransactionInBlock(transId) is False:
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, node.port))
return False
if waitForFinalization:
if node.waitForTransFinalization(transId) is False:
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a final block on server port %d." % (transId, node.port))
return False
else:
if node.waitForTransactionInBlock(transId) is False:
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, node.port))
return False

return True

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

return True

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

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

if False == self.spreadFunds(self.defproduceraAccount, self.accounts, transferAmount):
if False == self.spreadFunds(self.defproduceraAccount, self.accounts, transferAmount, waitForFinalization=waitForFinalization):
Utils.Print("ERROR: Failed to spread funds across nodes.")
return False

Expand Down
3 changes: 2 additions & 1 deletion tests/distributed-transactions-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
errorExit("Accounts creation failed.")

Print("Spread funds and validate")
if not cluster.spreadFundsAndValidate(10):
# if activateIF then irreversible node needs funds to be irreversible before validation
if not cluster.spreadFundsAndValidate(10, waitForFinalization=activateIF):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if activeateIF, will always wait for finalization even in head and speculative modes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

errorExit("Failed to spread and validate funds.")

print("Funds spread validated")
Expand Down
Loading