/
operations.go
73 lines (63 loc) · 2.14 KB
/
operations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// DO NOT COVER
package simulation
import (
"math/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/sentinel-official/hub/x/subscription/expected"
"github.com/sentinel-official/hub/x/subscription/keeper"
"github.com/sentinel-official/hub/x/subscription/types"
)
var (
typeMsgCancel = sdk.MsgTypeURL((*types.MsgCancelRequest)(nil))
typeMsgAllocate = sdk.MsgTypeURL((*types.MsgAllocateRequest)(nil))
)
func WeightedOperations(
cdc codec.Codec,
txConfig client.TxConfig,
params simtypes.AppParams,
ak expected.AccountKeeper,
bk expected.BankKeeper,
k keeper.Keeper,
) simulation.WeightedOperations {
var (
weightMsgCancel int
weightMsgAllocate int
)
params.GetOrGenerate(
cdc,
typeMsgCancel,
&weightMsgCancel,
nil,
func(_ *rand.Rand) {
weightMsgCancel = 100
},
)
params.GetOrGenerate(
cdc,
typeMsgAllocate,
&weightMsgAllocate,
nil,
func(_ *rand.Rand) {
weightMsgAllocate = 100
},
)
return simulation.WeightedOperations{
simulation.NewWeightedOperation(weightMsgCancel, SimulateMsgCancel(txConfig, ak, bk, k)),
simulation.NewWeightedOperation(weightMsgAllocate, SimulateMsgAllocate(txConfig, ak, bk, k)),
}
}
func SimulateMsgCancel(txConfig client.TxConfig, ak expected.AccountKeeper, bk expected.BankKeeper, k keeper.Keeper) simtypes.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
return simtypes.NoOpMsg(types.ModuleName, typeMsgCancel, ""), nil, nil
}
}
func SimulateMsgAllocate(txConfig client.TxConfig, ak expected.AccountKeeper, bk expected.BankKeeper, k keeper.Keeper) simtypes.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
return simtypes.NoOpMsg(types.ModuleName, typeMsgAllocate, ""), nil, nil
}
}