-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(sim): add sim genesis state for custom modules (#1759)
* test(sim): add randomized inflation genesis state * test(sim): add tokenfactory random genesis state * test(sim): add tokenfactory random genesis state * test(sim): update sudo random genesis * test(sim): add devgas random genesis * test(sim): add perp random genesis * test(sim): wire spot sim genesis * chore: update changelog
- Loading branch information
Showing
13 changed files
with
335 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package simulation | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"math/rand" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
|
||
"github.com/NibiruChain/nibiru/x/devgas/v1/types" | ||
) | ||
|
||
const ( | ||
DeveloperFeeShare = "developer_fee_share" | ||
) | ||
|
||
func GenDeveloperFeeShare(r *rand.Rand) sdk.Dec { | ||
return sdk.NewDecWithPrec(int64(r.Intn(100)), 2) | ||
} | ||
|
||
func RandomizedGenState(simState *module.SimulationState) { | ||
var developerFeeShare sdk.Dec | ||
simState.AppParams.GetOrGenerate( | ||
simState.Cdc, DeveloperFeeShare, &developerFeeShare, simState.Rand, | ||
func(r *rand.Rand) { developerFeeShare = GenDeveloperFeeShare(r) }, | ||
) | ||
|
||
devgasGenesis := types.GenesisState{ | ||
Params: types.ModuleParams{ | ||
EnableFeeShare: true, | ||
DeveloperShares: developerFeeShare, | ||
AllowedDenoms: []string{}, | ||
}, | ||
FeeShare: []types.FeeShare{}, | ||
} | ||
|
||
bz, err := json.MarshalIndent(&devgasGenesis, "", " ") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Printf("Selected randomly generated x/devgas parameters:\n%s\n", bz) | ||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&devgasGenesis) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package simulation | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
|
||
"github.com/NibiruChain/nibiru/x/inflation/types" | ||
) | ||
|
||
// RandomizedGenState generates a random GenesisState for distribution | ||
func RandomizedGenState(simState *module.SimulationState) { | ||
inflationGenesis := types.GenesisState{ | ||
Params: types.Params{ | ||
InflationEnabled: true, | ||
PolynomialFactors: []sdk.Dec{ | ||
sdk.MustNewDecFromStr("-0.00014903"), | ||
sdk.MustNewDecFromStr("0.07527647"), | ||
sdk.MustNewDecFromStr("-19.11742154"), | ||
sdk.MustNewDecFromStr("3170.0969905"), | ||
sdk.MustNewDecFromStr("-339271.31060432"), | ||
sdk.MustNewDecFromStr("18063678.8582418"), | ||
}, | ||
InflationDistribution: types.InflationDistribution{ | ||
CommunityPool: sdk.NewDecWithPrec(35_159141, 8), // 35.159141% | ||
StakingRewards: sdk.NewDecWithPrec(27_757217, 8), // 27.757217% | ||
StrategicReserves: sdk.NewDecWithPrec(37_083642, 8), // 37.083642% | ||
}, | ||
EpochsPerPeriod: 30, | ||
PeriodsPerYear: 12, | ||
MaxPeriod: 8 * 12, | ||
}, | ||
Period: 0, | ||
SkippedEpochs: 0, | ||
} | ||
|
||
bz, err := json.MarshalIndent(&inflationGenesis, "", " ") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Printf("Selected randomly generated x/inflation parameters:\n%s\n", bz) | ||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&inflationGenesis) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package simulation | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/module" | ||
|
||
"github.com/NibiruChain/nibiru/x/perp/v2/types" | ||
) | ||
|
||
// RandomizedGenState generates a random GenesisState for distribution | ||
func RandomizedGenState(simState *module.SimulationState) { | ||
perpGenesis := *types.DefaultGenesis() | ||
|
||
bz, err := json.MarshalIndent(&perpGenesis, "", " ") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Printf("Selected randomly generated x/tokenfactory parameters:\n%s\n", bz) | ||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&perpGenesis) | ||
} |
Oops, something went wrong.