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

x/feegrant audit: clean up / add test coverage to types package #9193

Merged
merged 9 commits into from
Apr 28, 2021

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Apr 23, 2021

Description

-cleans up the x/feegrant/types folder
-adds test cases to cli_test to cover filtered_fee functions
-adds line to msgs.go to cover case where NewMsgRevoke could have msg.granter == msg.grantee
-remove redundant constants from msgs.go

ref: #9115


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

commit 58dc50051226a9eeb8d0ebea5bb0908fe5b9637f
Author: technicallyty <[email protected]>
Date:   Fri Apr 23 15:09:27 2021 -0700

    remove comments

commit a84107e1b3eaa31324cb0f4f097b49f02af79c69
Author: technicallyty <[email protected]>
Date:   Fri Apr 23 15:02:41 2021 -0700

    add tests for msgs.go

commit 2ad16869237e9631b402c93cde650c3fc554daf2
Author: technicallyty <[email protected]>
Date:   Fri Apr 23 13:20:21 2021 -0700

    specify test name

commit b7121277c9be586a7c80d010ec401e50b510e02a
Merge: c0c134d971 3c65c3d
Author: technicallyty <[email protected]>
Date:   Fri Apr 23 12:54:55 2021 -0700

    Merge branch 'master' into ty-9115-types_tests

commit c0c134d97107194dc4f9d3c501a15d023ae083e5
Author: technicallyty <[email protected]>
Date:   Thu Apr 22 19:59:11 2021 -0700

    -add test case to cli_test.go for filtered fee
    -clean up identifiers
    -remove redundant import alias from filtered_fee.go

commit f7ab3699da39be3ab886f96962d28d23438d2e8e
Author: technicallyty <[email protected]>
Date:   Thu Apr 22 09:57:31 2021 -0700

    remove unecessary constant

commit 9db59a82a7337cf5a7a3569c6900a44a6c81e8b4
Merge: a3e75ceb8a e28271b
Author: technicallyty <[email protected]>
Date:   Thu Apr 22 09:19:20 2021 -0700

    Merge branch 'master' into ty-9115-types_tests

commit a3e75ceb8a510ad9db43dd96073c43b7a8b062b0
Merge: 4d3dafab85 bffcae5
Author: technicallyty <[email protected]>
Date:   Wed Apr 21 12:04:39 2021 -0700

    Merge branch 'master' into ty-9115-types_tests

commit 4d3dafab85d85526a7c94b045289605289ee6b0d
Author: technicallyty <[email protected]>
Date:   Wed Apr 21 12:03:41 2021 -0700

    cleanup id's / add test case

commit e8f6924931ba95e592bfc3057ba167700458da41
Author: technicallyty <[email protected]>
Date:   Wed Apr 21 10:55:29 2021 -0700

    add test for 0 allowance / remove unused field on exp test

commit 516b6ef89a4582ad681cc6c5c101cf50a9a54fb5
Author: technicallyty <[email protected]>
Date:   Tue Apr 20 15:22:48 2021 -0700

    make names more clear, remove unused field
@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #9193 (9ddb406) into master (15edf3c) will increase coverage by 0.09%.
The diff coverage is 100.00%.

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

@@            Coverage Diff             @@
##           master    #9193      +/-   ##
==========================================
+ Coverage   59.86%   59.95%   +0.09%     
==========================================
  Files         595      595              
  Lines       37355    37358       +3     
==========================================
+ Hits        22361    22398      +37     
+ Misses      13011    12974      -37     
- Partials     1983     1986       +3     
Impacted Files Coverage Δ
x/feegrant/types/filtered_fee.go 0.00% <ø> (ø)
x/feegrant/client/testutil/suite.go 99.66% <100.00%> (+0.50%) ⬆️
x/feegrant/types/msgs.go 72.09% <100.00%> (+72.09%) ⬆️
x/feegrant/types/basic_fee.go 75.00% <0.00%> (+10.00%) ⬆️

@blushi blushi mentioned this pull request Apr 26, 2021
7 tasks
@@ -15,32 +15,27 @@ func TestExpiresAt(t *testing.T) {

cases := map[string]struct {
example types.ExpiresAt
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename it to expiresAt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ExpiresAt is a proto message, we usually have these exported

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant rename the struct field name example into expiresAt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, changed it to expires to be consistent with the other tests in the file

@@ -49,6 +51,12 @@ func TestGrant(t *testing.T) {
})
require.NoError(t, err)

zeroAllowance, err := types.NewFeeAllowanceGrant(addr, addr2, &types.BasicFeeAllowance{
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe all these NewFeeAllowanceGrants test could be turned into table tests (using the one below)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that will be cleaner, uses table tests now

grant *types.BasicFeeAllowance
valid bool
}{
"valid":{
Copy link
Contributor

Choose a reason for hiding this comment

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

event though that's already tested elsewhere, could you add test cases for invalid granter and grantee for both messages?
Also I believe having two separate tests for both msgs types would be clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also I believe having two separate tests for both msgs types would be clearer.

moved out

event though that's already tested elsewhere, could you add test cases for invalid granter and grantee for both messages?

okay added some invalid granter/grantee cases

x/feegrant/types/msgs_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@blushi blushi left a comment

Choose a reason for hiding this comment

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

LGTM

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

@blushi blushi added the A:automerge Automatically merge PR once all prerequisites pass. label Apr 28, 2021
@mergify mergify bot merged commit 0cbed20 into master Apr 28, 2021
@mergify mergify bot deleted the ty-9115-cleanup_types branch April 28, 2021 14:18
@cyberbono3 cyberbono3 removed their assignment Apr 28, 2021
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. C:CLI C:x/feegrant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants