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

native: clear LastGasPerVote when voting for NULL #3349

Merged
merged 1 commit into from
Mar 15, 2024
Merged

Conversation

AliceInHunterland
Copy link
Contributor

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.67%. Comparing base (9c83bef) to head (0e6fbad).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3349      +/-   ##
==========================================
- Coverage   84.68%   84.67%   -0.01%     
==========================================
  Files         331      331              
  Lines       44932    44935       +3     
==========================================
  Hits        38050    38050              
- Misses       5371     5373       +2     
- Partials     1511     1512       +1     

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

pkg/core/native/native_neo.go Show resolved Hide resolved
pkg/core/native/native_test/neo_test.go Outdated Show resolved Hide resolved
pkg/core/native/native_test/neo_test.go Outdated Show resolved Hide resolved
pkg/core/native/native_test/neo_test.go Outdated Show resolved Hide resolved
pkg/core/native/native_test/neo_test.go Outdated Show resolved Hide resolved
pkg/core/native/native_test/neo_test.go Outdated Show resolved Hide resolved
pkg/core/native/native_test/neo_test.go Outdated Show resolved Hide resolved
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM, the second test is not needed, since it'll require nontrivial modifications to cause error in the middle of voteInternal, just doesn't worth it.

as := new(state.NEOBalance)
err = as.FromStackItem(res)
require.NoError(t, err)
return as, res.Value().([]stackitem.Item)[3].Value().(*big.Int).Uint64()
Copy link
Member

Choose a reason for hiding this comment

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

Second return value is not needed, it's enough that you've checked require.Equal(t, 4, len(res.Value().([]stackitem.Item))).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but the fourth one is zero integer no need to check it?

Copy link
Member

Choose a reason for hiding this comment

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

but the fourth one is zero integer no need to check it?

If you have 4 items, then (s *NEOBalance) FromStackItem will deserialize 4-th item in some particular value. And in test you check that this value is 0. That's enough.

My primary concern here was about the check that 4-th item is present.

Copy link
Member

Choose a reason for hiding this comment

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

if len(structItem) >= 4 {
lastGasPerVote, err := structItem[3].TryInteger()
if err != nil {
return fmt.Errorf("invalid last vote reward per neo stackitem: %w", err)
}
s.LastGasPerVote = *lastGasPerVote
}

pkg/core/native/native_test/neo_test.go Show resolved Hide resolved
pkg/core/native/native_test/neo_test.go Outdated Show resolved Hide resolved
@AnnaShaleva AnnaShaleva merged commit bfc3aa6 into master Mar 15, 2024
17 of 20 checks passed
@AnnaShaleva AnnaShaleva deleted the LastGasPerVote branch March 15, 2024 09:06
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.

Clear LastGasPerVote when voting for NULL
3 participants