Skip to content

Commit

Permalink
fix: use newer MsgStoreCode
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed Jan 24, 2024
1 parent efdca66 commit 5393bba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
17 changes: 10 additions & 7 deletions wasmbinding/test/custom_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,25 @@ func storeReflectCode(t *testing.T, ctx sdk.Context, quicksilverApp *app.Quicksi

require.NoError(t, err)

src := wasmtypes.MsgStoreCode{
src := &wasmtypes.MsgStoreCode{
Sender: addr.String(),
WASMByteCode: wasmCode,
}

msgContent, err := govv1.NewMsgSubmitProposal([]sdk.Msg{src}, sdk.NewCoins(sdk.NewInt64Coin("qck", 100000000)), govAddress, "test", "test", "test", true)
msgProposal, err := govv1.NewMsgSubmitProposal([]sdk.Msg{src}, sdk.NewCoins(sdk.NewInt64Coin("qck", 100000000)), govAddress, "test", "test", "test", true)
require.NoError(t, err)

// when stored
_, err = govKeeper.SubmitProposal(ctx, []sdk.Msg{msgContent}, "testing123")
require.NoError(t, err)
// _, err = govKeeper.SubmitProposal(ctx, []sdk.Msg{msgContent}, "testing123")
// require.NoError(t, err)

// and proposal execute
em := sdk.NewEventManager()
handler := govKeeper.LegacyRouter().GetRoute(src.ProposalRoute())
err = handler(ctx.WithEventManager(em), src)
// em := sdk.NewEventManager()
handler := govKeeper.Router().Handler(msgProposal)
if handler == nil {
t.Fatal("proposal handler not found")
}
_, err = handler(ctx, msgProposal)
require.NoError(t, err)
}

Expand Down
31 changes: 18 additions & 13 deletions wasmbinding/test/store_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,28 @@ func storeCodeViaProposal(t *testing.T, ctx sdk.Context, quicksilverApp *app.Qui
wasmCode, err := os.ReadFile("../testdata/hackatom.wasm")
require.NoError(t, err)

src := types.StoreCodeProposalFixture(func(p *types.StoreCodeProposal) {
p.RunAs = addr.String()
p.WASMByteCode = wasmCode
})

govAddress := govKeeper.GetGovernanceAccount(ctx).GetAddress().String()
msgContent, err := govv1.NewLegacyContent(src, govAddress)
src := &types.MsgStoreCode{
Sender: addr.String(),
WASMByteCode: wasmCode,
}
// types.StoreCodeProposal
msgProposal, err := govv1.NewMsgSubmitProposal([]sdk.Msg{src}, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))), addr.String(), "test", "test", "test", false)
require.NoError(t, err)
// govAddress := govKeeper.GetGovernanceAccount(ctx).GetAddress().String()
// msgContent, err := govv1.NewLegacyContent(src, govAddress)
// require.NoError(t, err)

// when stored
_, err = govKeeper.SubmitProposal(ctx, []sdk.Msg{msgContent}, "testing123")
require.NoError(t, err)
// // when stored
// _, err = govKeeper.SubmitProposal(ctx, []sdk.Msg{msgProposal}, "testing123", "test", "test", addr, false)
// require.NoError(t, err)

// and proposal execute
em := sdk.NewEventManager()
handler := govKeeper.LegacyRouter().GetRoute(src.ProposalRoute())
err = handler(ctx.WithEventManager(em), src)
// em := sdk.NewEventManager()
handler := govKeeper.Router().Handler(msgProposal)
if handler == nil {
t.Fatal("proposal handler not found")
}
_, err = handler(ctx, msgProposal)
require.NoError(t, err)
}

Expand Down

0 comments on commit 5393bba

Please sign in to comment.