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

cli: fix TestNEP17Balance test #3319

Closed
wants to merge 1 commit into from
Closed

Conversation

AliceInHunterland
Copy link
Contributor

As there was a race in gas balance the e.Chain.GetTokenLastUpdated needed before checking the balance for synchronisation rpc request result and chain's value.

Close #2960

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.96%. Comparing base (630bd29) to head (8fcfb4d).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3319      +/-   ##
==========================================
- Coverage   84.96%   84.96%   -0.01%     
==========================================
  Files         328      328              
  Lines       44789    44789              
==========================================
- Hits        38057    38055       -2     
  Misses       5221     5221              
- Partials     1511     1513       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 68 to 84
getUtilityTokenBalance := func(acc util.Uint160) *big.Int {
_, err := e.Chain.GetTokenLastUpdated(acc)
require.NoError(t, err)
return e.Chain.GetUtilityTokenBalance(acc)
}
Copy link
Member

Choose a reason for hiding this comment

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

How this could prevent the described test failure? Have you checked, is it a race or something else? Why the race is happening (if it's a race)?

Copy link
Member

Choose a reason for hiding this comment

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

I'm asking because I'd like to make 100% sure that we found and fixed the source of the problem correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the initial hypothesis was that if on the server side, we do GetTokenLastUpdated(acc), then we need it in test https://github.com/nspcc-dev/neo-go/blob/master/pkg/services/rpcsrv/server.go#L1185
however, with the last changes here, I could reproduce the failure of the test.

gasState := e.Chain.GetContractState(gasHash)
require.NotNil(t, gasState)

lub, err := e.Chain.GetTokenLastUpdated(acc)
Copy link
Member

Choose a reason for hiding this comment

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

I don't see how call to last updated height is connected with this race. Could you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't...

@AliceInHunterland AliceInHunterland marked this pull request as draft February 28, 2024 11:39
@AliceInHunterland AliceInHunterland force-pushed the test-token-balance branch 2 times, most recently from 03ad7f4 to 5ad949a Compare February 28, 2024 12:00
Signed-off-by: Ekaterina Pavlova <[email protected]>
@AnnaShaleva
Copy link
Member

Replaced by #3332.

@AliceInHunterland AliceInHunterland deleted the test-token-balance branch March 4, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible race in TestNEP17Balance/all_accounts
2 participants