Skip to content

Commit

Permalink
fix: rename function name and add a contract for order
Browse files Browse the repository at this point in the history
  • Loading branch information
Kynea0b committed Aug 22, 2023
1 parent d4ca2ea commit 31a7073
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* [\#71](https://github.com/Finschia/wasmd/pull/71) add test cases in ContractsByCode
* [\#82](https://github.com/Finschia/wasmd/pull/82) add test case to QueryInactiveContracts


### Bug Fixes
* [\#62](https://github.com/Finschia/wasmd/pull/62) fill ContractHistory querier result's Updated field
* [\#52](https://github.com/Finschia/wasmd/pull/52) fix cli_test error of wasmplus and add cli_test ci
Expand Down
14 changes: 9 additions & 5 deletions x/wasmplus/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ func TestQueryInactiveContracts(t *testing.T) {
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
example2 := InstantiateHackatomExampleContract(t, ctx, keepers)
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
example3 := InstantiateHackatomExampleContract(t, ctx, keepers)
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)

// Address order of contracts is ascending order of byte array whose address is decoded by bech32
expAddrs := CreateOrderedAddresses(example1.Contract.Bytes(), example2.Contract.Bytes())
expAddrs := GenerateSortedBech32Address(example1.Contract.Bytes(), example2.Contract.Bytes(), example3.Contract.Bytes())

// set inactive
err := keeper.deactivateContract(ctx, example1.Contract)
require.NoError(t, err)
err = keeper.deactivateContract(ctx, example2.Contract)
require.NoError(t, err)
err = keeper.deactivateContract(ctx, example3.Contract)
require.NoError(t, err)

q := Querier(keeper)
specs := map[string]struct {
Expand All @@ -47,16 +51,16 @@ func TestQueryInactiveContracts(t *testing.T) {
"query all": {
srcQuery: &types.QueryInactiveContractsRequest{},
expAddrs: expAddrs,
expPaginationTotal: 2,
expPaginationTotal: 3,
},
"with pagination offset": {
srcQuery: &types.QueryInactiveContractsRequest{
Pagination: &query.PageRequest{
Offset: 1,
},
},
expAddrs: []string{expAddrs[1]},
expPaginationTotal: 2,
expAddrs: []string{expAddrs[1], expAddrs[2]},
expPaginationTotal: 3,
},
"with invalid pagination key": {
srcQuery: &types.QueryInactiveContractsRequest{
Expand All @@ -82,7 +86,7 @@ func TestQueryInactiveContracts(t *testing.T) {
Key: fromBase64("reSl9YA6Q5g1xjY5Wo1kje5XsvyQ2Y3Bf6iHFZtpY4s="),
},
},
expAddrs: []string{expAddrs[1]},
expAddrs: []string{expAddrs[1], expAddrs[2]},
expPaginationTotal: 0,
},
}
Expand Down
2 changes: 1 addition & 1 deletion x/wasmplus/keeper/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) {
return key, pub, addr
}

func CreateOrderedAddresses(addrs ...[]byte) []string {
func GenerateSortedBech32Address(addrs ...[]byte) []string {
sort.Slice(addrs, func(i, j int) bool {
return string(addrs[i]) < string(addrs[j])
})
Expand Down

0 comments on commit 31a7073

Please sign in to comment.