Skip to content

Commit

Permalink
Add new param to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed May 15, 2024
1 parent 48a1aba commit 66139cc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
1 change: 1 addition & 0 deletions x/ccv/provider/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestParams(t *testing.T) {
Amount: sdk.NewInt(10000000),
},
600,
180,
)
providerKeeper.SetParams(ctx, newParams)
params = providerKeeper.GetParams(ctx)
Expand Down
26 changes: 13 additions & 13 deletions x/ccv/provider/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -102,7 +102,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -123,7 +123,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -144,7 +144,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -171,7 +171,7 @@ func TestValidateGenesisState(t *testing.T) {
types.DefaultVscTimeoutPeriod,
types.DefaultSlashMeterReplenishPeriod,
types.DefaultSlashMeterReplenishFraction,
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -198,7 +198,7 @@ func TestValidateGenesisState(t *testing.T) {
types.DefaultVscTimeoutPeriod,
types.DefaultSlashMeterReplenishPeriod,
types.DefaultSlashMeterReplenishFraction,
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -225,7 +225,7 @@ func TestValidateGenesisState(t *testing.T) {
types.DefaultVscTimeoutPeriod,
types.DefaultSlashMeterReplenishPeriod,
types.DefaultSlashMeterReplenishFraction,
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000000)}, 600),
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -252,7 +252,7 @@ func TestValidateGenesisState(t *testing.T) {
types.DefaultVscTimeoutPeriod,
types.DefaultSlashMeterReplenishPeriod,
types.DefaultSlashMeterReplenishFraction,
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -279,7 +279,7 @@ func TestValidateGenesisState(t *testing.T) {
0, // 0 vsc timeout here
types.DefaultSlashMeterReplenishPeriod,
types.DefaultSlashMeterReplenishFraction,
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -306,7 +306,7 @@ func TestValidateGenesisState(t *testing.T) {
types.DefaultVscTimeoutPeriod,
0, // 0 slash meter replenish period here
types.DefaultSlashMeterReplenishFraction,
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -333,7 +333,7 @@ func TestValidateGenesisState(t *testing.T) {
types.DefaultVscTimeoutPeriod,
types.DefaultSlashMeterReplenishPeriod,
"1.15",
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600),
sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}, 600),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}, 600, 180),
nil,
nil,
nil,
Expand All @@ -706,7 +706,7 @@ func TestValidateGenesisState(t *testing.T) {
nil,
types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1000000)}, 600),
types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1000000)}, 600, 180),
nil,
nil,
nil,
Expand Down
24 changes: 12 additions & 12 deletions x/ccv/provider/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,39 @@ func TestValidateParams(t *testing.T) {
{"custom valid params", types.NewParams(
ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), true},
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), true},
{"custom invalid params", types.NewParams(
ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"blank client", types.NewParams(&ibctmtypes.ClientState{},
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
{"nil client", types.NewParams(nil, "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"nil client", types.NewParams(nil, "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
// Check if "0.00" is valid or if a zero dec TrustFraction needs to return an error
{"0 trusting period fraction", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.00", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), true},
"0.00", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), true},
{"0 ccv timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", 0, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", 0, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"0 init timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, 0, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", time.Hour, 0, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"0 vsc timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, 0, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", time.Hour, time.Hour, 0, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"0 slash meter replenish period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, 24*time.Hour, 0, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", time.Hour, time.Hour, 24*time.Hour, 0, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"slash meter replenish fraction over 1", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"invalid consumer reward denom registration fee denom", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}, 1000), false},
"0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}, 1000, 180), false},
{"invalid consumer reward denom registration fee amount", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0,
time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}),
"0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10000000)}, 1000), false},
"0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10000000)}, 1000, 180), false},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 66139cc

Please sign in to comment.