-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package e2e_test | ||
|
||
import ( | ||
sdkmath "cosmossdk.io/math" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/staking/types" | ||
|
||
"github.com/kava-labs/kava/tests/util" | ||
) | ||
|
||
func (suite *IntegrationTestSuite) TestValMinCommission() { | ||
suite.SkipIfUpgradeDisabled() | ||
|
||
beforeUpgradeCtx := util.CtxAtHeight(suite.UpgradeHeight - 1) | ||
afterUpgradeCtx := util.CtxAtHeight(suite.UpgradeHeight) | ||
|
||
suite.Run("before upgrade", func() { | ||
// Before params | ||
beforeParams, err := suite.Kava.Staking.Params(beforeUpgradeCtx, &types.QueryParamsRequest{}) | ||
suite.Require().NoError(err) | ||
|
||
suite.Require().Equal( | ||
sdkmath.LegacyZeroDec().String(), | ||
beforeParams.Params.MinCommissionRate.String(), | ||
"min commission rate should be 0%% before upgrade", | ||
) | ||
|
||
// Before validators | ||
beforeValidators, err := suite.Kava.Staking.Validators(beforeUpgradeCtx, &types.QueryValidatorsRequest{}) | ||
suite.Require().NoError(err) | ||
|
||
for _, val := range beforeValidators.Validators { | ||
expectedRate := sdkmath.LegacyMustNewDecFromStr("0.1") | ||
|
||
suite.Require().Equalf( | ||
expectedRate.String(), | ||
val.Commission.CommissionRates.Rate.String(), | ||
"validator %s should have commission rate of %s before upgrade", | ||
val.OperatorAddress, | ||
expectedRate, | ||
) | ||
} | ||
}) | ||
|
||
suite.Run("after upgrade", func() { | ||
// After params | ||
afterParams, err := suite.Kava.Staking.Params(afterUpgradeCtx, &types.QueryParamsRequest{}) | ||
suite.Require().NoError(err) | ||
|
||
suite.Require().Equal( | ||
sdkmath.LegacyMustNewDecFromStr("0.05").String(), | ||
afterParams.Params.MinCommissionRate.String(), | ||
"min commission rate should be 5%% after upgrade", | ||
) | ||
|
||
// After validators | ||
afterValidators, err := suite.Kava.Staking.Validators(afterUpgradeCtx, &types.QueryValidatorsRequest{}) | ||
suite.Require().NoError(err) | ||
|
||
for _, val := range afterValidators.Validators { | ||
suite.Require().Truef( | ||
val.Commission.CommissionRates.Rate.GTE(sdk.MustNewDecFromStr("0.05")), | ||
"validator %s should have commission rate of at least 5%%", | ||
val.OperatorAddress, | ||
) | ||
} | ||
}) | ||
} |