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

test: add validation & unit tests in fswap module #1382

Merged
merged 16 commits into from
May 21, 2024

Conversation

170210
Copy link
Contributor

@170210 170210 commented May 13, 2024

Description

closes: #XXXX

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

Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
@170210
Copy link
Contributor Author

170210 commented May 13, 2024

Is it necessary to add the following validate in validateBasic:

  • Whether Swaps[0].AmountCapForToDenom is greater than Swappeds[0].ToDenom.Amount
    if swap.AmountCapForToDenom.LT(swapped.ToCoinAmount.Amount) {
    return ErrInvalidState.Wrap("AmountCapForToDenom cannot be exceeded")

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.68%. Comparing base (92ad675) to head (1f01fc9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1382      +/-   ##
==========================================
+ Coverage   69.58%   69.68%   +0.10%     
==========================================
  Files         668      668              
  Lines       56231    56242      +11     
==========================================
+ Hits        39126    39194      +68     
+ Misses      14834    14775      -59     
- Partials     2271     2273       +2     
Files Coverage Δ
simapp/app.go 80.00% <100.00%> (ø)
x/fswap/keeper/keeper.go 60.16% <100.00%> (+9.30%) ⬆️
x/fswap/types/genesis.go 81.25% <100.00%> (+53.25%) ⬆️

... and 3 files with indirect coverage changes

Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 marked this pull request as ready for review May 13, 2024 05:55
@170210 170210 self-assigned this May 13, 2024
@170210 170210 added A: improvement Changes in existing functionality backport/v0.49.x labels May 13, 2024
Signed-off-by: 170210 <j170210@icloud.com>
x/fswap/keeper/keeper.go Outdated Show resolved Hide resolved
x/fswap/keeper/keeper.go Outdated Show resolved Hide resolved
x/fswap/keeper/keeper.go Outdated Show resolved Hide resolved
x/fswap/keeper/keeper.go Outdated Show resolved Hide resolved
x/fswap/types/genesis.go Show resolved Hide resolved
Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
0Tech
0Tech previously approved these changes May 20, 2024
@0Tech 0Tech self-requested a review May 20, 2024 01:36
Copy link
Contributor

@jaeseung-bae jaeseung-bae left a comment

Choose a reason for hiding this comment

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

Can you check failed test in CI?

Signed-off-by: 170210 <j170210@icloud.com>
jaeseung-bae
jaeseung-bae previously approved these changes May 21, 2024
zemyblue
zemyblue previously approved these changes May 21, 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.

How about adding unvalidated case unittest for genesis.go?

@zemyblue zemyblue self-requested a review May 21, 2024 02:32
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 dismissed stale reviews from zemyblue and jaeseung-bae via 9b04493 May 21, 2024 05:15
Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 closed this May 21, 2024
@170210 170210 reopened this May 21, 2024
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 requested a review from jaeseung-bae May 21, 2024 06:51
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 requested a review from jaeseung-bae May 21, 2024 07:04
@170210 170210 merged commit dab544e into Finschia:main May 21, 2024
38 checks passed
@170210 170210 deleted the refactor/uttests branch May 21, 2024 07:26
mergify bot pushed a commit that referenced this pull request May 21, 2024
* chore: add logic validation & tests

Signed-off-by: 170210 <j170210@icloud.com>

* test: add genesisState tests

Signed-off-by: 170210 <j170210@icloud.com>

* chore: update CHANGLOG.md

Signed-off-by: 170210 <j170210@icloud.com>

* chore: fix lint

Signed-off-by: 170210 <j170210@icloud.com>

* chore: add newKeeper test

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comment

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix test

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comments

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix failed tests

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comment

Signed-off-by: 170210 <j170210@icloud.com>

* fix: remove unused keeper in appmodule

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for merge (FSwapQueryTestSuite Setup up)

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for codecov

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comment

Signed-off-by: 170210 <j170210@icloud.com>

---------

Signed-off-by: 170210 <j170210@icloud.com>
(cherry picked from commit dab544e)
170210 added a commit that referenced this pull request May 21, 2024
* chore: add logic validation & tests

Signed-off-by: 170210 <j170210@icloud.com>

* test: add genesisState tests

Signed-off-by: 170210 <j170210@icloud.com>

* chore: update CHANGLOG.md

Signed-off-by: 170210 <j170210@icloud.com>

* chore: fix lint

Signed-off-by: 170210 <j170210@icloud.com>

* chore: add newKeeper test

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comment

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix test

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comments

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix failed tests

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comment

Signed-off-by: 170210 <j170210@icloud.com>

* fix: remove unused keeper in appmodule

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for merge (FSwapQueryTestSuite Setup up)

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for codecov

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix for comment

Signed-off-by: 170210 <j170210@icloud.com>

---------

Signed-off-by: 170210 <j170210@icloud.com>
(cherry picked from commit dab544e)

Co-authored-by: 170210 <85928898+170210@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: improvement Changes in existing functionality backport/v0.49.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants