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

fix: add missing nil checks (backport #1299) #1308

Merged
merged 3 commits into from
Mar 29, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Mar 26, 2024

Description

There are multiple functions in the codebase missing nil checks and this PR fixed them.

This pr cherry-pick the following upstream prs

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

This is an automatic backport of pull request #1299 done by [Mergify](https://mergify.com).

* fix: types: ensure .Amount is non-nil in Coin.Validate() (#15691)

This change fixes a scenario in which Coin.Validate() would panic when given a nil Amount.
While here, added a fuzz test along with unit/regression tests.

Fixes #15690

* fix: change math.NewInt to sdk.NewInt

Signed-off-by: 170210 <[email protected]>

* fix: change to finschia-sdk

Signed-off-by: 170210 <[email protected]>

* fix: prevent nil DecCoin creation when converting Coins to DecCoins (#12903)

Closes: #12902

---

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* chore: update CHANGELOG.md

Signed-off-by: 170210 <[email protected]>

* fix: fix lint

Signed-off-by: 170210 <[email protected]>

---------

Signed-off-by: 170210 <[email protected]>
Co-authored-by: Emmanuel T Odeke <[email protected]>
Co-authored-by: yys <[email protected]>
(cherry picked from commit a7a39e5)

# Conflicts:
#	CHANGELOG.md
@mergify mergify bot added the conflicts label Mar 26, 2024
Copy link
Contributor Author

mergify bot commented Mar 26, 2024

Cherry-pick of a7a39e5 has failed:

On branch mergify/bp/release/v0.48.x/pr-1299
Your branch is up to date with 'origin/release/v0.48.x'.

You are currently cherry-picking commit a7a39e570.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   types/coin.go
	modified:   types/coin_test.go
	modified:   types/dec_coin.go
	modified:   types/dec_coin_test.go
	new file:   types/fuzz_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   CHANGELOG.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 69.78%. Comparing base (c5fbc74) to head (98d7a10).

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##           release/v0.48.x    #1308      +/-   ##
===================================================
- Coverage            69.79%   69.78%   -0.01%     
===================================================
  Files                  646      646              
  Lines                67526    67532       +6     
===================================================
+ Hits                 47127    47129       +2     
- Misses               18213    18216       +3     
- Partials              2186     2187       +1     
Files Coverage Δ
types/coin.go 94.62% <100.00%> (+0.03%) ⬆️
types/dec_coin.go 77.45% <50.00%> (-0.63%) ⬇️

... and 1 file with indirect coverage changes

CHANGELOG.md Outdated Show resolved Hide resolved
@0Tech 0Tech self-assigned this Mar 29, 2024
@0Tech 0Tech added A: bug Something isn't working and removed conflicts labels Mar 29, 2024
Copy link
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

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

There is CI failure. Please check it.

@zemyblue
Copy link
Member

There is CI failure. Please check it.

Oh, coverage fail.
I think we can skip it in this case.

@0Tech 0Tech merged commit a496d32 into release/v0.48.x Mar 29, 2024
28 of 29 checks passed
@0Tech 0Tech deleted the mergify/bp/release/v0.48.x/pr-1299 branch March 29, 2024 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants