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 test cases for invalid pagination key #66

Merged
merged 5 commits into from
Aug 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add invalid pagination key test in AllContractState
Signed-off-by: 170210 <j170210@icloud.com>
  • Loading branch information
170210 committed Aug 10, 2023
commit 0a61da120a5043ea70c8602104cfa92f40775fc0
14 changes: 12 additions & 2 deletions x/wasm/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestQueryAllContractState(t *testing.T) {
srcQuery *types.QueryAllContractStateRequest
expModelContains []types.Model
expModelContainsNot []types.Model
expErr *sdkErrors.Error
expErr error
}{
"query all": {
srcQuery: &types.QueryAllContractStateRequest{Address: contractAddr.String()},
Expand All @@ -67,6 +67,16 @@ func TestQueryAllContractState(t *testing.T) {
{Key: []byte{0x0, 0x1}, Value: []byte(`{"count":8}`)},
},
},
"with invalid pagination key": {
srcQuery: &types.QueryAllContractStateRequest{
Address: contractAddr.String(),
Pagination: &query.PageRequest{
Offset: 1,
Key: []byte("test"),
},
},
expErr: fmt.Errorf("invalid request, either offset or key is expected, got both"),
},
"with pagination limit": {
srcQuery: &types.QueryAllContractStateRequest{
Address: contractAddr.String(),
Expand Down Expand Up @@ -99,8 +109,8 @@ func TestQueryAllContractState(t *testing.T) {
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
got, err := q.AllContractState(sdk.WrapSDKContext(ctx), spec.srcQuery)
require.True(t, spec.expErr.Is(err), err)
if spec.expErr != nil {
assert.Equal(t, spec.expErr, err)
return
}
for _, exp := range spec.expModelContains {
Expand Down