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

refactor(x/ecocredit): update credit to basket conversion and docs #1559

Merged
merged 10 commits into from
Nov 1, 2022

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Oct 19, 2022

Description

  • updates basket docs
  • adds fuzz test to credit to basket token conversion function

ref: #1456


Author Checklist

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 in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

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 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)

@technicallyty technicallyty requested a review from a team October 19, 2022 02:40
@technicallyty technicallyty marked this pull request as draft October 19, 2022 15:50
@ryanchristo ryanchristo mentioned this pull request Oct 19, 2022
40 tasks
@technicallyty technicallyty marked this pull request as ready for review October 19, 2022 21:46
@codecov
Copy link

codecov bot commented Oct 19, 2022

Codecov Report

Merging #1559 (634b589) into main (c8d12d3) will decrease coverage by 0.00%.
The diff coverage is 53.84%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1559      +/-   ##
==========================================
- Coverage   78.68%   78.68%   -0.01%     
==========================================
  Files         251      251              
  Lines       18850    18849       -1     
==========================================
- Hits        14833    14832       -1     
  Misses       3153     3153              
  Partials      864      864              
Impacted Files Coverage Δ
x/ecocredit/basket/keeper/utils.go 58.82% <45.45%> (-3.68%) ⬇️
x/ecocredit/basket/keeper/msg_put.go 66.66% <100.00%> (+1.19%) ⬆️


// creditAmountToBasketCoin calculates the coins to mint to the credit depositor using the following formula:
// coinAmount = creditAmt * (1 * 10^exp)
func creditAmountToBasketCoin(creditAmt math.Dec, exp uint32, denom string) (sdk.Coin, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

simplified this to 1 Coin, since we never returned more than one

@@ -87,6 +89,58 @@ func TestGetBasketBalances(t *testing.T) {
require.Equal(t, IDToBalance[2], amtToDeposit)
}

func FuzzCreditAmountToBasketCoin(f *testing.F) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a fuzz test to ensure we are properly converting credit decimal amounts to basket token integers.

Copy link
Contributor

@aleem1314 aleem1314 left a comment

Choose a reason for hiding this comment

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

Lgtm

@ryanchristo
Copy link
Member

Should we break this out into separate pull requests? Or at least update the title?

@technicallyty technicallyty changed the title docs: update basket proto docs to match implementation chore: audit basket submodule Oct 25, 2022
@technicallyty
Copy link
Contributor Author

Should we break this out into separate pull requests? Or at least update the title?

no preference here, i updated title to something more generic, can break apart if that makes more sense

Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Oof. Forgot to submit my review comments. A couple small suggestions / questions.

Also, chore should only be used when updating non-production code.

If we are making doc updates, adding a test, and refactoring production code in the same pull request, the title should probably favor the production code changes. This is a blend of docs, test, and refactor so maybe refactor would make the most sense?

proto/regen/ecocredit/basket/v1/tx.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/basket/v1/tx.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/basket/v1/tx.proto Outdated Show resolved Hide resolved
Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Pre-approving. Just a couple more minor comments/suggestions.

proto/regen/ecocredit/basket/v1/tx.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/basket/v1/tx.proto Outdated Show resolved Hide resolved
x/ecocredit/basket/keeper/utils_test.go Outdated Show resolved Hide resolved
technicallyty and others added 3 commits October 31, 2022 17:30
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
@ryanchristo ryanchristo changed the title chore: audit basket submodule refactor(x/ecocredit): update credit to basket conversion and docs Nov 1, 2022
@ryanchristo ryanchristo merged commit 323a953 into main Nov 1, 2022
@ryanchristo ryanchristo deleted the ty/1456-basket_proto_docs branch November 1, 2022 01:40
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.

3 participants