-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat(x/feegrant): feegrant autcli module query #16213
Merged
JeancarloBarrios
merged 18 commits into
main
from
JeancarloBarrios/feegrant-autcli-module-query
Jun 7, 2023
Merged
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bbd6fb7
feat(feegrant): add autocli config
JeancarloBarrios e7b690d
feat(feegrant): add autocli config
JeancarloBarrios a669fc2
feat(feegrant): add query autocli
JeancarloBarrios e1f5916
feat(feegrant): add query autocli
JeancarloBarrios 46ff913
Merge branch 'main' into JeancarloBarrios/feegrant-autcli-module-query
JeancarloBarrios 455196e
feat: add tests e2e
JeancarloBarrios 9f39b0a
feat: add tests e2e
JeancarloBarrios acb2dc2
feat: add tests e2e
JeancarloBarrios 61de61b
Merge branch 'main' into JeancarloBarrios/feegrant-autcli-module-query
JeancarloBarrios c387a0d
Merge branch 'main' into JeancarloBarrios/feegrant-autcli-module-query
JeancarloBarrios dd1dceb
nit
JeancarloBarrios e8c3dc8
Merge branch 'main' into JeancarloBarrios/feegrant-autcli-module-query
JeancarloBarrios 1041c32
nit
JeancarloBarrios 228a5b2
Merge branch 'JeancarloBarrios/feegrant-autcli-module-query' of githu…
JeancarloBarrios 5f2bfb4
nit
JeancarloBarrios e51b7ca
Delete grpc.go
JeancarloBarrios d14e319
Merge branch 'main' into JeancarloBarrios/feegrant-autcli-module-query
JeancarloBarrios 60fbda3
Merge branch 'main' into JeancarloBarrios/feegrant-autcli-module-query
JeancarloBarrios File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
package feegrant | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/testutil" | ||
) | ||
|
||
func (s *E2ETestSuite) TestGrantGRPCAllowance() { | ||
val := s.network.Validators[0] | ||
s.createGrant(s.addedGranter, s.addedGrantee) | ||
testCases := []struct { | ||
name string | ||
args struct { | ||
Granter string | ||
Grantee string | ||
} | ||
expectErr bool | ||
errorMsg string | ||
msg string | ||
}{ | ||
{ | ||
name: "correct grant", | ||
args: struct { | ||
Granter string | ||
Grantee string | ||
}{ | ||
Granter: s.addedGranter.String(), | ||
Grantee: s.addedGrantee.String(), | ||
}, | ||
expectErr: false, | ||
errorMsg: "", | ||
msg: "\"allowance\":{\"@type\":\"/cosmos.feegrant.v1beta1.BasicAllowance\",\"spend_limit\":[{\"denom\":\"stake\",\"amount\":\"100\"}]", | ||
}, | ||
{ | ||
name: "invalid grantee", | ||
args: struct { | ||
Granter string | ||
Grantee string | ||
}{ | ||
Granter: s.addedGranter.String(), | ||
Grantee: "incorrect_grantee", | ||
}, | ||
expectErr: true, | ||
errorMsg: "decoding bech32 failed", | ||
msg: "", | ||
}, | ||
{ | ||
name: "non existent grant", | ||
args: struct { | ||
Granter string | ||
Grantee string | ||
}{ | ||
Granter: "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", | ||
Grantee: s.addedGrantee.String(), | ||
}, | ||
expectErr: true, | ||
errorMsg: "fee-grant not found", | ||
msg: "", | ||
}, | ||
} | ||
|
||
grantAllowneceURL := val.APIAddress + "/cosmos/feegrant/v1beta1/allowance/%s/%s" | ||
for _, tc := range testCases { | ||
uri := fmt.Sprintf(grantAllowneceURL, tc.args.Granter, tc.args.Grantee) | ||
s.Run(tc.name, func() { | ||
resp, err := testutil.GetRequest(uri) | ||
if tc.expectErr { | ||
s.Require().Contains(string(resp), tc.errorMsg) | ||
} else { | ||
s.Require().NoError(err) | ||
s.Require().Contains(string(resp), tc.msg) | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
func (s *E2ETestSuite) TestGrantGRPCAllowanceByGrantee() { | ||
val := s.network.Validators[0] | ||
s.createGrant(s.addedGranter, s.addedGrantee) | ||
testCases := []struct { | ||
name string | ||
args struct { | ||
Grantee string | ||
} | ||
expectErr bool | ||
errorMsg string | ||
msg string | ||
}{ | ||
{ | ||
name: "correct grpc request", | ||
args: struct { | ||
Grantee string | ||
}{ | ||
Grantee: s.addedGrantee.String(), | ||
}, | ||
expectErr: false, | ||
errorMsg: "", | ||
msg: "\"allowance\":{\"@type\":\"/cosmos.feegrant.v1beta1.BasicAllowance\",\"spend_limit\":[{\"denom\":\"stake\",\"amount\":\"100\"}]", | ||
}, | ||
{ | ||
name: "invalid grantee", | ||
args: struct { | ||
Grantee string | ||
}{ | ||
Grantee: "incorrect_grantee", | ||
}, | ||
expectErr: true, | ||
errorMsg: "decoding bech32 failed", | ||
msg: "", | ||
}, | ||
{ | ||
name: "non existent grant", | ||
args: struct { | ||
Grantee string | ||
}{ | ||
Grantee: "cosmos1h6wddg9x0zsusswhchkfhwwtkdg62fehs5ees4", | ||
}, | ||
expectErr: false, | ||
errorMsg: "", | ||
msg: "{\"allowances\":[],\"pagination\":{\"next_key\":null,\"total\":\"0\"}}", | ||
}, | ||
} | ||
|
||
grantAllowneceURL := val.APIAddress + "/cosmos/feegrant/v1beta1/allowances/%s" | ||
for _, tc := range testCases { | ||
uri := fmt.Sprintf(grantAllowneceURL, tc.args.Grantee) | ||
s.Run(tc.name, func() { | ||
resp, err := testutil.GetRequest(uri) | ||
if tc.expectErr { | ||
s.Require().Contains(string(resp), tc.errorMsg) | ||
} else { | ||
s.Require().NoError(err) | ||
s.Require().Contains(string(resp), tc.msg) | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
func (s *E2ETestSuite) TestGrantGRPCAllowanceByGranter() { | ||
val := s.network.Validators[0] | ||
s.createGrant(s.addedGranter, s.addedGrantee) | ||
testCases := []struct { | ||
name string | ||
args struct { | ||
Granter string | ||
} | ||
expectErr bool | ||
errorMsg string | ||
msg string | ||
}{ | ||
{ | ||
name: "correct grpc request", | ||
args: struct { | ||
Granter string | ||
}{ | ||
Granter: s.addedGranter.String(), | ||
}, | ||
expectErr: false, | ||
errorMsg: "", | ||
msg: "\"allowance\":{\"@type\":\"/cosmos.feegrant.v1beta1.BasicAllowance\",\"spend_limit\":[{\"denom\":\"stake\",\"amount\":\"100\"}]", | ||
}, | ||
{ | ||
name: "invalid grantee", | ||
args: struct { | ||
Granter string | ||
}{ | ||
Granter: "incorrect_grantee", | ||
}, | ||
expectErr: true, | ||
errorMsg: "decoding bech32 failed", | ||
msg: "", | ||
}, | ||
{ | ||
name: "non existent grant", | ||
args: struct { | ||
Granter string | ||
}{ | ||
Granter: "cosmos1h6wddg9x0zsusswhchkfhwwtkdg62fehs5ees4", | ||
}, | ||
expectErr: false, | ||
errorMsg: "{\"allowances\":[],\"pagination\":{\"next_key\":null,\"total\":\"0\"}}", | ||
msg: "", | ||
}, | ||
} | ||
|
||
grantAllowneceURL := val.APIAddress + "/cosmos/feegrant/v1beta1/issued/%s" | ||
for _, tc := range testCases { | ||
uri := fmt.Sprintf(grantAllowneceURL, tc.args.Granter) | ||
s.Run(tc.name, func() { | ||
resp, err := testutil.GetRequest(uri) | ||
if tc.expectErr { | ||
s.Require().Contains(string(resp), tc.errorMsg) | ||
} else { | ||
s.Require().NoError(err) | ||
s.Require().Contains(string(resp), tc.msg) | ||
} | ||
}) | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make them non E2E? and put them here if they do not exist: https://github.com/cosmos/cosmos-sdk/blob/c8ab555174ef5b1f8557b80361d8b83754f62f6a/x/feegrant/keeper/grpc_query_test.go
It would be great to delete the E2E and improve existing grpc tests instead of adding new ones at a different place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that those ones are mocked, but If we don't think is necessary for them to be in e2e I will delete them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are already testing them in feegrant's
grpc_query_test.go
, but the only difference is we are using QueryRequests there and RPC URLs here, maybe we could improve the tests there instead of adding them in E2E tests