Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update simulation #470

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/coinswap/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func RandomizedGenState(simState *module.SimulationState) {

simState.AppParams.GetOrGenerate(
keyPoolCreationFee, &poolCreationFee, simState.Rand,
func(r *rand.Rand) { poolCreationFee = sdk.NewInt64Coin(sdk.DefaultBondDenom, r.Int63n(100)) },
func(r *rand.Rand) { poolCreationFee = sdk.NewInt64Coin(sdk.DefaultBondDenom, r.Int63n(100)+1) },
)

simState.AppParams.GetOrGenerate(
Expand Down
2 changes: 1 addition & 1 deletion modules/service/keeper/invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (k Keeper) UpdateRequestContext(
repeatedFreq = requestContext.RepeatedFrequency
}

if repeatedFreq < uint64(timeout) {
if requestContext.Repeated && repeatedFreq < uint64(timeout) {
return errorsmod.Wrapf(
types.ErrInvalidRepeatedFreq,
"repeated frequency [%d] must not be less than the timeout [%d]",
Expand Down
22 changes: 17 additions & 5 deletions modules/service/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package simulation
import (
"errors"
"fmt"
"math/rand"

"cosmossdk.io/math"
tmbytes "github.com/cometbft/cometbft/libs/bytes"
Expand All @@ -14,6 +13,7 @@ import (
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"math/rand"

"mods.irisnet.org/modules/service/keeper"
"mods.irisnet.org/modules/service/types"
Expand Down Expand Up @@ -990,12 +990,15 @@ func SimulateMsgCallService(
}
timeout := int64(simtypes.RandIntBetween(r, 1, int(k.MaxRequestTimeout(ctx))))

repeated := true
repeatedFrequency := uint64(100)
repeatedTotal := int64(10)
repeated := r.Intn(2) == 0
var repeatedFrequency, repeatedTotal uint64
if repeated {
repeatedFrequency = uint64(100)
repeatedTotal = uint64(10)
}

msg := types.NewMsgCallService(serviceName, providers, consumer, input,
serviceFeeCap, timeout, repeated, repeatedFrequency, repeatedTotal)
serviceFeeCap, timeout, repeated, repeatedFrequency, int64(repeatedTotal))

spendable := bk.SpendableCoins(ctx, account.GetAddress())
spendable, hasNeg := spendable.SafeSub(serviceFeeCap...)
Expand Down Expand Up @@ -1158,6 +1161,15 @@ func SimulateMsgPauseRequestContext(
"not authorized operation",
), nil, nil
}

if !requestContext.Repeated {
return simtypes.NoOpMsg(
types.ModuleName,
types.TypeMsgPauseRequestContext,
"requestContext non repeated",
), nil, nil
}

consumer, err := sdk.AccAddressFromBech32(requestContext.Consumer)
if err != nil {
return simtypes.NoOpMsg(
Expand Down
2 changes: 1 addition & 1 deletion modules/token/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func RandomizedGenState(simState *module.SimulationState) {
)

tokenGenesis := v1.NewGenesisState(
v1.NewParams(tokenTaxRate, sdk.NewCoin(sdk.DefaultBondDenom, issueTokenBaseFee), mintTokenFeeRatio, enableErc20, ""),
v1.NewParams(tokenTaxRate, sdk.NewCoin(v1.GetNativeToken().Symbol, issueTokenBaseFee), mintTokenFeeRatio, enableErc20, ""),
tokens,
)

Expand Down
Loading