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

add sorted check for the coins sub/add fun parameter #9240

Merged
merged 10 commits into from
May 5, 2021

Conversation

robert-zaremba
Copy link
Collaborator

Description

When looking at #9159 and the Coins structure usage in the SDK, I noticed that we don't assure if the Coins.Sub and Coins.Add is not checked if the coins are sorted. We have IsValidate function, but it's not always used.

NOTE: I was thinking about adding a check for the object receiver (self), but it seams we construct it correctly with a constructor (NewCoins).


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented May 1, 2021

Codecov Report

Merging #9240 (aa954e7) into master (42a4e4b) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head aa954e7 differs from pull request most recent head f0ceeb1. Consider uploading reports for the commit f0ceeb1 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9240      +/-   ##
==========================================
+ Coverage   60.13%   60.14%   +0.01%     
==========================================
  Files         595      595              
  Lines       37185    37201      +16     
==========================================
+ Hits        22360    22376      +16     
  Misses      12846    12846              
  Partials     1979     1979              
Impacted Files Coverage Δ
types/coin.go 93.53% <100.00%> (+0.26%) ⬆️
x/bank/types/balance.go 89.18% <0.00%> (+2.52%) ⬆️

@colin-axner colin-axner requested a review from alessio May 3, 2021 13:45
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Show resolved Hide resolved
types/coin.go Show resolved Hide resolved
types/coin.go Outdated
Comment on lines 247 to 249
if len(coins) < 2 {
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this extra check is not necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right, the loop condition will handle it.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is early return. A very good practice AFAICT

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

utACK

types/coin.go Outdated Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

utACK

types/coin.go Outdated Show resolved Hide resolved
@robert-zaremba robert-zaremba requested a review from atheeshp May 5, 2021 15:30
@robert-zaremba robert-zaremba added the A:automerge Automatically merge PR once all prerequisites pass. label May 5, 2021
@robert-zaremba robert-zaremba removed the A:automerge Automatically merge PR once all prerequisites pass. label May 5, 2021
@robert-zaremba robert-zaremba added the A:automerge Automatically merge PR once all prerequisites pass. label May 5, 2021
Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot merged commit 68d4610 into master May 5, 2021
@mergify mergify bot deleted the robert/bank-coins-set branch May 5, 2021 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants