Skip to content

Commit

Permalink
chore: fixing simulation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chatton committed Nov 21, 2024
1 parent a195296 commit 47eb259
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package simulation_test

import (
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
"math/rand"
"testing"

Expand All @@ -23,6 +24,7 @@ func TestProposalMsgs(t *testing.T) {
r := rand.New(s)

ctx := sdk.NewContext(nil, true, nil)
codec := codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())
accounts := simtypes.RandomAccounts(r, 3)

tests := []struct {
Expand Down Expand Up @@ -84,7 +86,7 @@ func TestProposalMsgs(t *testing.T) {
require.Equal(t, simulation.OpWeightMsgUpdateParams, weightedMsg.AppParamsKey())
require.Equal(t, simulation.DefaultWeightMsgUpdateParams, weightedMsg.DefaultWeight())

msg, err := weightedMsg.MsgSimulatorFn()(ctx, r, accounts, nil)
msg, err := weightedMsg.MsgSimulatorFn()(ctx, r, accounts, codec)
require.NoError(t, err)

if msgUpdateHostParams, ok := msg.(*hosttypes.MsgUpdateParams); ok {
Expand Down
12 changes: 5 additions & 7 deletions modules/apps/transfer/simulation/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (

"github.com/stretchr/testify/require"

codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
typesaddress "github.com/cosmos/cosmos-sdk/types/address"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

"github.com/cosmos/ibc-go/v9/modules/apps/transfer/simulation"
Expand All @@ -28,15 +29,12 @@ func TestProposalMsgs(t *testing.T) {

w0 := weightedProposalMsgs[0]

// tests w0 interface:
require.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey())
require.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight())

msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, nil)
codec := codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())
msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, codec)
require.NoError(t, err)
msgUpdateParams, ok := msg.(*types.MsgUpdateParams)
require.True(t, ok)

require.Equal(t, sdk.AccAddress(address.Module("gov")).String(), msgUpdateParams.Signer)
require.Equal(t, sdk.AccAddress(typesaddress.Module("gov")).String(), msgUpdateParams.Signer)
require.EqualValues(t, msgUpdateParams.Params.SendEnabled, false)
}
4 changes: 3 additions & 1 deletion modules/core/simulation/proposals_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package simulation_test

import (
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
"math/rand"
"testing"
"time"
Expand Down Expand Up @@ -34,7 +35,8 @@ func TestProposalMsgs(t *testing.T) {
require.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey())
require.Equal(t, simulation.DefaultWeight, w0.DefaultWeight())

msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, nil)
codec := codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())
msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, codec)
require.NoError(t, err)
msgUpdateParams, ok := msg.(*clienttypes.MsgUpdateParams)
require.True(t, ok)
Expand Down
4 changes: 3 additions & 1 deletion modules/light-clients/08-wasm/simulation/proposals_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package simulation_test

import (
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
"math/rand"
"testing"

Expand Down Expand Up @@ -30,7 +31,8 @@ func TestProposalMsgs(t *testing.T) {
require.Equal(t, simulation.OpWeightMsgStoreCode, w0.AppParamsKey())
require.Equal(t, simulation.DefaultWeightMsgStoreCode, w0.DefaultWeight())

msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, nil)
codec := codecaddress.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())
msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, codec)
require.NoError(t, err)
msgStoreCode, ok := msg.(*types.MsgStoreCode)
require.True(t, ok)
Expand Down

0 comments on commit 47eb259

Please sign in to comment.