Skip to content

Commit

Permalink
chore: remove SendVoucher operation in simulation (#760)
Browse files Browse the repository at this point in the history
* remove operation

* gomod
  • Loading branch information
lumtis authored May 5, 2022
1 parent de73982 commit 096ed50
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 55 deletions.
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ require (
github.com/goccy/go-yaml v1.9.4 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
Expand All @@ -85,7 +84,6 @@ require (
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
Expand Down Expand Up @@ -169,7 +167,6 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
nhooyr.io/websocket v1.8.6 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace (
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,6 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2V
github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -726,8 +724,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 h1:ESEyqQqXXFIcImj/BE8oKEX37Zsuceb2cZI+EL/zNCY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0/go.mod h1:XnLCLFp3tjoZJszVKjfpyAK6J8sYIcQXWQxmqLWF21I=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
Expand Down Expand Up @@ -2059,6 +2055,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
12 changes: 0 additions & 12 deletions x/campaign/module_simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const (
defaultWeightMsgBurnVouchers = 20
defaultWeightMsgRedeemVouchers = 20
defaultWeightMsgUnredeemVouchers = 20
defaultWeightMsgSendVouchers = 20

opWeightMsgCreateCampaign = "op_weight_msg_create_campaign"
opWeightMsgEditCampaign = "op_weight_msg_edit_campaign"
Expand All @@ -36,7 +35,6 @@ const (
opWeightMsgBurnVouchers = "op_weight_msg_burn_vouchers"
opWeightMsgRedeemVouchers = "op_weight_msg_redeem_vouchers"
opWeightMsgUnredeemVouchers = "op_weight_msg_unredeem_vouchers"
opWeightMsgSendVouchers = "op_weight_msg_send_vouchers"

// this line is used by starport scaffolding # simapp/module/const
)
Expand Down Expand Up @@ -81,7 +79,6 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
weightMsgBurnVouchers int
weightMsgRedeemVouchers int
weightMsgUnredeemVouchers int
weightMsgSendVouchers int
)

appParams := simState.AppParams
Expand Down Expand Up @@ -136,11 +133,6 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
weightMsgUnredeemVouchers = defaultWeightMsgUnredeemVouchers
},
)
appParams.GetOrGenerate(cdc, opWeightMsgSendVouchers, &weightMsgSendVouchers, nil,
func(_ *rand.Rand) {
weightMsgSendVouchers = defaultWeightMsgSendVouchers
},
)

return []simtypes.WeightedOperation{
simulation.NewWeightedOperation(
Expand Down Expand Up @@ -183,9 +175,5 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
weightMsgUnredeemVouchers,
campaignsim.SimulateMsgUnredeemVouchers(am.accountKeeper, am.bankKeeper, am.keeper),
),
simulation.NewWeightedOperation(
weightMsgSendVouchers,
campaignsim.SimulateMsgSendVouchers(am.accountKeeper, am.bankKeeper, am.keeper),
),
}
}
34 changes: 0 additions & 34 deletions x/campaign/simulation/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
sdksimulation "github.com/cosmos/cosmos-sdk/x/simulation"

"github.com/tendermint/spn/testutil/sample"
Expand Down Expand Up @@ -335,36 +334,3 @@ func SimulateMsgUnredeemVouchers(
return deliverSimTx(r, app, ctx, ak, bk, simAccount, msg, sdk.NewCoins())
}
}

// SimulateMsgSendVouchers simulates a Msg message from the bank module with vouchers
func SimulateMsgSendVouchers(
ak types.AccountKeeper,
bk types.BankKeeper,
k keeper.Keeper,
) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
_, simAccount, vouchers, found := GetAccountWithVouchers(r, ctx, bk, k, accs, false)
if !found {
return simtypes.NoOpMsg(banktypes.ModuleName, banktypes.TypeMsgSend, "skip send vouchers"), nil, nil
}

// Select a random receiver account
accountNb := r.Intn(len(accs))
if accs[accountNb].Address.Equals(simAccount.Address) {
if accountNb == 0 {
accountNb++
} else {
accountNb--
}
}

msg := banktypes.NewMsgSend(
simAccount.Address,
accs[accountNb].Address,
vouchers,
)
return deliverSimTx(r, app, ctx, ak, bk, simAccount, msg, vouchers)
}
}

0 comments on commit 096ed50

Please sign in to comment.