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 the test case for invalid address #88

Merged
merged 29 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5d9dc40
test: add test case to `QueryInactiveContracts`
Kynea0b Aug 17, 2023
52ba9b8
chore: add this pr for changelog.md
Kynea0b Aug 17, 2023
e2d6f44
Merge branch 'main' into test-add-to-InactiveContracts
Kynea0b Aug 18, 2023
6e2e797
test: add the test case for invalid address
Kynea0b Aug 20, 2023
8b6ceb9
test: add the test case for invalid address
Kynea0b Aug 20, 2023
2aa2c60
chore: add this pr to CHANGE.log
Kynea0b Aug 21, 2023
423ce6b
Merge branch 'main' into test-invalid-address
Kynea0b Aug 21, 2023
7e3daa9
fix: Fix address judgment and pagination key
Kynea0b Aug 21, 2023
2ca9f9d
Merge remote-tracking branch 'origin/test-add-to-InactiveContracts' i…
Kynea0b Aug 21, 2023
31f724b
feat: add the function for byte array to use addresses order check
Kynea0b Aug 22, 2023
a6d3577
test: add func for make test data for addresses order
Kynea0b Aug 22, 2023
fac0982
fix: Add a function to create an ordered address array
Kynea0b Aug 22, 2023
ec5f793
fix: fix lint error
Kynea0b Aug 22, 2023
64d554f
fix: add the error handling for lint
Kynea0b Aug 22, 2023
69f73de
fix: fix `Error: unreachable: unreachable code (govet)` for `golangci…
Kynea0b Aug 22, 2023
159ef4b
fix: fix panic message
Kynea0b Aug 22, 2023
27a7bd7
refactor: Changed []byte array comparison to string comparison
Kynea0b Aug 22, 2023
d119436
fix: revert commit for go.mod go.sum
Kynea0b Aug 22, 2023
5fd58ab
fix: fix lint
Kynea0b Aug 22, 2023
760fc35
fix: fix lint
Kynea0b Aug 22, 2023
d4ca2ea
fix: delete unnecessary code
Kynea0b Aug 22, 2023
31a7073
fix: rename function name and add a contract for order
Kynea0b Aug 22, 2023
ccd9140
fix: Changed to equal judgment as before with wrap error as expected …
Kynea0b Aug 22, 2023
268a4da
Merge remote-tracking branch 'origin/test-add-to-InactiveContracts' i…
Kynea0b Aug 22, 2023
c011c9b
Merge remote-tracking branch 'origin/test-invalid-address' into test-…
Kynea0b Aug 22, 2023
24fe19c
Merge branch 'main' into test-invalid-address
Kynea0b Aug 22, 2023
0b3c700
test: add the invalid address test case to `TestQueryContractInfo` an…
Kynea0b Aug 23, 2023
559370d
Merge branch 'main' into test-invalid-address
Kynea0b Aug 23, 2023
d4c7dfc
Merge branch 'main' into test-invalid-address
Kynea0b Aug 23, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* [\#82](https://github.com/Finschia/wasmd/pull/82) add test case to QueryInactiveContracts
* [\#87](https://github.com/Finschia/wasmd/pull/87) add an integration test for TestExecuteContract
* [\#79](https://github.com/Finschia/wasmd/pull/79) add an integration test for TestStoreAndInstantiateContract
* [\#88](https://github.com/Finschia/wasmd/pull/88) add the test case for invalid address

### Bug Fixes
* [\#62](https://github.com/Finschia/wasmd/pull/62) fill ContractHistory querier result's Updated field
Expand Down
27 changes: 27 additions & 0 deletions x/wasm/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
"time"

"github.com/cosmos/btcutil/bech32"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -55,6 +56,10 @@ func TestQueryAllContractState(t *testing.T) {
srcQuery: &types.QueryAllContractStateRequest{Address: RandomBech32AccountAddress(t)},
expErr: types.ErrNotFound,
},
"query all with invalid address": {
srcQuery: &types.QueryAllContractStateRequest{Address: "abcde"},
expErr: fmt.Errorf("decoding bech32 failed: %w", bech32.ErrInvalidLength(5)),
},
"with pagination offset": {
srcQuery: &types.QueryAllContractStateRequest{
Address: contractAddr.String(),
Expand Down Expand Up @@ -163,6 +168,10 @@ func TestQuerySmartContractState(t *testing.T) {
srcQuery: &types.QuerySmartContractStateRequest{Address: RandomBech32AccountAddress(t), QueryData: []byte(`{"verifier":{}}`)},
expErr: types.ErrNotFound,
},
"query smart with invalid address": {
srcQuery: &types.QuerySmartContractStateRequest{Address: "abcde", QueryData: []byte(`{"verifier":{}}`)},
expErr: bech32.ErrInvalidLength(5),
},
"with empty request": {
srcQuery: nil,
expErr: status.Error(codes.InvalidArgument, "empty request"),
Expand Down Expand Up @@ -267,6 +276,10 @@ func TestQueryRawContractState(t *testing.T) {
srcQuery: &types.QueryRawContractStateRequest{Address: RandomBech32AccountAddress(t), QueryData: []byte("foo")},
expErr: types.ErrNotFound,
},
"query raw with invalid address": {
srcQuery: &types.QueryRawContractStateRequest{Address: "abcde", QueryData: []byte("foo")},
expErr: bech32.ErrInvalidLength(5),
},
"with empty request": {
srcQuery: nil,
expErr: status.Error(codes.InvalidArgument, "empty request"),
Expand Down Expand Up @@ -633,6 +646,16 @@ func TestQueryContractHistory(t *testing.T) {
}},
expErr: types.ErrEmpty,
},
"query with invalid address": {
req: &types.QueryContractHistoryRequest{Address: "abcde"},
srcHistory: []types.ContractCodeHistoryEntry{{
Operation: types.ContractCodeHistoryOperationTypeGenesis,
CodeID: firstCodeID,
Updated: types.NewAbsoluteTxPosition(ctx),
Msg: []byte(`"init message"`),
}},
expErr: fmt.Errorf("decoding bech32 failed: %w", bech32.ErrInvalidLength(5)),
},
"with empty request": {
req: nil,
expErr: status.Error(codes.InvalidArgument, "empty request"),
Expand Down Expand Up @@ -872,6 +895,10 @@ func TestQueryContractInfo(t *testing.T) {
stored: types.ContractInfoFixture(),
expErr: types.ErrNotFound,
},
"query with invalid address": {
src: &types.QueryContractInfoRequest{Address: "abcde"},
expErr: bech32.ErrInvalidLength(5),
},
"with empty request": {
src: nil,
expErr: status.Error(codes.InvalidArgument, "empty request"),
Expand Down