Add ReplyOn fields to SubMsg, state is bech32 not canonical addresses

This commit is contained in:
Ethan Frey 2021-04-12 21:39:19 +02:00
parent 39856bf028
commit 6189e17271
5 changed files with 23 additions and 21 deletions

View File

@ -68,9 +68,9 @@ func TestInitGenesis(t *testing.T) {
assertContractList(t, q, data.ctx, 1, []string{contractBech32Addr})
assertContractInfo(t, q, data.ctx, contractBech32Addr, 1, creator)
assertContractState(t, q, data.ctx, contractBech32Addr, state{
Verifier: []byte(fred),
Beneficiary: []byte(bob),
Funder: []byte(creator),
Verifier: fred.String(),
Beneficiary: bob.String(),
Funder: creator.String(),
})
// export into genstate
@ -90,8 +90,8 @@ func TestInitGenesis(t *testing.T) {
assertContractList(t, q2, newData.ctx, 1, []string{contractBech32Addr})
assertContractInfo(t, q2, newData.ctx, contractBech32Addr, 1, creator)
assertContractState(t, q2, newData.ctx, contractBech32Addr, state{
Verifier: []byte(fred),
Beneficiary: []byte(bob),
Funder: []byte(creator),
Verifier: fred.String(),
Beneficiary: bob.String(),
Funder: creator.String(),
})
}

View File

@ -933,11 +933,11 @@ func TestMigrate(t *testing.T) {
// and verify contract state
raw := keepers.WasmKeeper.QueryRaw(ctx, contractAddr, []byte("config"))
var stored map[string][]byte
var stored map[string]string
require.NoError(t, json.Unmarshal(raw, &stored))
require.Contains(t, stored, "verifier")
require.NoError(t, err)
assert.Equal(t, spec.expVerifier, sdk.AccAddress(stored["verifier"]))
assert.Equal(t, spec.expVerifier.String(), stored["verifier"])
})
}
}

View File

@ -381,7 +381,7 @@ func TestReflectStargateQuery(t *testing.T) {
}
type reflectState struct {
Owner []byte `json:"owner"`
Owner string `json:"owner"`
}
func TestMaskReflectWasmQueries(t *testing.T) {
@ -418,7 +418,7 @@ func TestMaskReflectWasmQueries(t *testing.T) {
raw := keeper.QueryRaw(ctx, reflectAddr, configKey)
var stateRes reflectState
mustParse(t, raw, &stateRes)
require.Equal(t, stateRes.Owner, []byte(creator))
require.Equal(t, stateRes.Owner, creator.String())
// now, let's reflect a smart query into the x/wasm handlers and see if we get the same result
reflectOwnerQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Wasm: &wasmvmtypes.WasmQuery{
@ -453,7 +453,7 @@ func TestMaskReflectWasmQueries(t *testing.T) {
// now, with the raw data, we can parse it into state
var reflectStateRes reflectState
mustParse(t, reflectRawRes.Data, &reflectStateRes)
require.Equal(t, reflectStateRes.Owner, []byte(creator))
require.Equal(t, reflectStateRes.Owner, creator.String())
}
func TestWasmRawQueryWithNil(t *testing.T) {

View File

@ -61,6 +61,7 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) {
Msgs: []wasmvmtypes.SubMsg{{
ID: 7,
Msg: msg,
ReplyOn: wasmvmtypes.ReplyAlways,
}},
},
}
@ -322,6 +323,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
ID: tc.submsgID,
Msg: msg,
GasLimit: tc.gasLimit,
ReplyOn: wasmvmtypes.ReplyAlways,
}},
},
}
@ -423,6 +425,7 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) {
Msgs: []wasmvmtypes.SubMsg{{
ID: 7,
Msg: msg,
ReplyOn: wasmvmtypes.ReplyAlways,
}},
},
}

View File

@ -8,7 +8,6 @@ import (
"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/types"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
@ -135,9 +134,9 @@ type initMsg struct {
}
type state struct {
Verifier wasmvmtypes.CanonicalAddress `json:"verifier"`
Beneficiary wasmvmtypes.CanonicalAddress `json:"beneficiary"`
Funder wasmvmtypes.CanonicalAddress `json:"funder"`
Verifier string `json:"verifier"`
Beneficiary string `json:"beneficiary"`
Funder string `json:"funder"`
}
func TestHandleInstantiate(t *testing.T) {
@ -192,9 +191,9 @@ func TestHandleInstantiate(t *testing.T) {
assertContractList(t, q, data.ctx, 1, []string{contractBech32Addr})
assertContractInfo(t, q, data.ctx, contractBech32Addr, 1, creator)
assertContractState(t, q, data.ctx, contractBech32Addr, state{
Verifier: []byte(fred),
Beneficiary: []byte(bob),
Funder: []byte(creator),
Verifier: fred.String(),
Beneficiary: bob.String(),
Funder: creator.String(),
})
}
@ -311,9 +310,9 @@ func TestHandleExecute(t *testing.T) {
assertContractList(t, q, data.ctx, 1, []string{contractBech32Addr})
assertContractInfo(t, q, data.ctx, contractBech32Addr, 1, creator)
assertContractState(t, q, data.ctx, contractBech32Addr, state{
Verifier: []byte(fred),
Beneficiary: []byte(bob),
Funder: []byte(creator),
Verifier: fred.String(),
Beneficiary: bob.String(),
Funder: creator.String(),
})
}