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: Fix restClientFixture test flaking #4484

Merged
merged 4 commits into from
Aug 29, 2022

Conversation

ghost
Copy link

@ghost ghost commented Aug 29, 2022

Summary

Many tests that use the restClientFixture flake for the following reason: The test spins up 2 nodes, Node A and Node B. Node A observes it is currently round r, but node B is still on round r-1. Node A then sends a tx with validity range (r, r+1000). Node B then discards the tx since r-1 is outside of the tx’s validity range. Then the test fails because the tx's are never processed if the proposer of each round happens to be Node B.

This test fixes the issue by changing the validity window.

Test Plan

This is a test.

@ghost ghost added the Team Carbon-11 label Aug 29, 2022
@ghost ghost requested a review from algorandskiy August 29, 2022 16:46
@ghost ghost self-assigned this Aug 29, 2022
@ghost ghost marked this pull request as draft August 29, 2022 16:46
algorandskiy
algorandskiy previously approved these changes Aug 29, 2022
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

Good job Nicholas!

@@ -328,7 +329,7 @@ func (f *RestClientFixture) SendMoneyAndWait(curRound, amountToSend, transaction
// SendMoneyAndWaitFromWallet is as above, but for a specific wallet
func (f *RestClientFixture) SendMoneyAndWaitFromWallet(walletHandle, walletPassword []byte, curRound, amountToSend, transactionFee uint64, fromAccount, toAccount string, closeToAccount string) (txn v1.Transaction) {
client := f.LibGoalClient
fundingTx, err := client.SendPaymentFromWallet(walletHandle, walletPassword, fromAccount, toAccount, transactionFee, amountToSend, nil, closeToAccount, 0, 0)
fundingTx, err := client.SendPaymentFromWallet(walletHandle, walletPassword, fromAccount, toAccount, transactionFee, amountToSend, nil, closeToAccount, basics.Round(curRound).SubSaturate(1), basics.Round(curRound+1000))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fundingTx, err := client.SendPaymentFromWallet(walletHandle, walletPassword, fromAccount, toAccount, transactionFee, amountToSend, nil, closeToAccount, basics.Round(curRound).SubSaturate(1), basics.Round(curRound+1000))
fundingTx, err := client.SendPaymentFromWallet(walletHandle, walletPassword, fromAccount, toAccount, transactionFee, amountToSend, nil, closeToAccount, basics.Round(curRound).SubSaturate(1), 0)

I guess it is better to let the API to determine last valid that is proto (MaxTxnLife) dependant

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good. Another question: do you think its reasonable to just use basics.Round(curRound).SubSaturate(1)?

Copy link
Contributor

@algorandskiy algorandskiy Aug 29, 2022

Choose a reason for hiding this comment

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

basics.Round(curRound).SubSaturate(1) looks good to me as first valid

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like the problem we get curRound too early, and then it takes 3+ rounds more to fill rest of fields and submit the txn. Well, please set last valid to firstValid + maxTxnLife like computeValidityRounds does.

Copy link
Author

Choose a reason for hiding this comment

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

The problem was that for that specific test, it inputted current round as current round + 5.

@ghost ghost marked this pull request as ready for review August 29, 2022 18:48
@codecov
Copy link

codecov bot commented Aug 29, 2022

Codecov Report

Merging #4484 (db21d24) into master (9e4e84c) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4484      +/-   ##
==========================================
+ Coverage   55.23%   55.25%   +0.01%     
==========================================
  Files         398      398              
  Lines       50297    50297              
==========================================
+ Hits        27784    27791       +7     
+ Misses      20180    20177       -3     
+ Partials     2333     2329       -4     
Impacted Files Coverage Δ
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
ledger/blockqueue.go 85.63% <0.00%> (-2.88%) ⬇️
ledger/acctupdates.go 69.59% <0.00%> (-0.60%) ⬇️
ledger/accountdb.go 73.03% <0.00%> (+0.15%) ⬆️
network/wsNetwork.go 64.91% <0.00%> (+0.28%) ⬆️
catchup/service.go 68.64% <0.00%> (+0.49%) ⬆️
ledger/acctonline.go 78.64% <0.00%> (+0.52%) ⬆️
cmd/tealdbg/debugger.go 73.49% <0.00%> (+0.80%) ⬆️
ledger/tracker.go 79.57% <0.00%> (+0.85%) ⬆️
data/transactions/verify/txn.go 44.64% <0.00%> (+0.89%) ⬆️
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants