Skip to content

Commit

Permalink
add observe slashed amounts validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Feb 2, 2024
1 parent 7fb0ffc commit cc356a8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions x/emissions/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

sdkmath "cosmossdk.io/math"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
keepertest "github.com/zeta-chain/zetacore/testutil/keeper"
emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types"
)
Expand All @@ -20,7 +19,7 @@ func TestKeeper_GetParams(t *testing.T) {
name: "Successfully set params",
params: emissionstypes.Params{
MaxBondFactor: "1.25",
MinBondFactor: "0.85",
MinBondFactor: "0.75",
AvgBlockTime: "6.00",
TargetBondRatio: "00.67",
ValidatorEmissionPercentage: "00.50",
Expand All @@ -31,6 +30,21 @@ func TestKeeper_GetParams(t *testing.T) {
},
isPanic: "",
},
{
name: "negative observer slashed amount",
params: emissionstypes.Params{
MaxBondFactor: "1.25",
MinBondFactor: "0.75",
AvgBlockTime: "6.00",
TargetBondRatio: "00.67",
ValidatorEmissionPercentage: "00.50",
ObserverEmissionPercentage: "00.25",
TssSignerEmissionPercentage: "00.25",
DurationFactorConstant: "0.001877876953694702",
ObserverSlashAmount: sdkmath.NewInt(-10),
},
isPanic: "slash amount cannot be less than 0",
},
{
name: "MaxBondFactor too high",
params: emissionstypes.Params{
Expand All @@ -42,6 +56,7 @@ func TestKeeper_GetParams(t *testing.T) {
ObserverEmissionPercentage: "00.25",
TssSignerEmissionPercentage: "00.25",
DurationFactorConstant: "0.001877876953694702",
ObserverSlashAmount: sdkmath.NewInt(100000000000000000),
},
isPanic: "max bond factor cannot be higher that 0.25",
},
Expand Down Expand Up @@ -215,7 +230,6 @@ func TestKeeper_GetParams(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
k, ctx := keepertest.EmissionsKeeper(t)
defaultParams := k.GetParams(ctx)
require.NotEqualf(t, tt.params, defaultParams, "expected: %v, got: %v", tt.params, defaultParams)
assertPanic(t, func() {
k.SetParams(ctx, tt.params)
}, tt.isPanic)
Expand Down

0 comments on commit cc356a8

Please sign in to comment.