Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
insumity committed Sep 26, 2023
1 parent f96f1bc commit d3dc0bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
12 changes: 6 additions & 6 deletions tests/integration/double_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
// we create two votes that only differ by their Block IDs and
// signed them using the same validator private key and chain ID
// of the consumer chain
"valid double voting evidence - should pass",
"valid double voting evidence 1 - should pass",
&tmtypes.DuplicateVoteEvidence{
VoteA: consuVote,
VoteB: consuBadVote,
Expand All @@ -141,7 +141,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
},
{
// create a double voting evidence using the provider validator key
"valid double voting evidence - should not pass because validator tombstoned in the previous test case",
"valid double voting evidence 2 - should pass",
&tmtypes.DuplicateVoteEvidence{
VoteA: provVote,
VoteB: provBadVote,
Expand All @@ -151,7 +151,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
},
s.consumerChain.ChainID,
provVal.PubKey,
false,
true,
},
}

Expand Down Expand Up @@ -190,10 +190,10 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
s.Require().True(s.providerApp.GetTestStakingKeeper().IsValidatorJailed(provCtx, provAddr.ToSdkConsAddr()))
s.Require().True(s.providerApp.GetTestSlashingKeeper().IsTombstoned(provCtx, provAddr.ToSdkConsAddr()))

// verifies that the validator gets slashed and has fewer tokens after the slashing
validator, _ := s.providerApp.GetTestStakingKeeper().GetValidator(provCtx, provAddr.ToSdkConsAddr().Bytes())
// verifies that the val gets slashed and has fewer tokens after the slashing
val, _ := s.providerApp.GetTestStakingKeeper().GetValidator(provCtx, provAddr.ToSdkConsAddr().Bytes())
slashFraction := s.providerApp.GetTestSlashingKeeper().SlashFractionDoubleSign(provCtx)
actualTokens := validator.GetTokens().ToDec()
actualTokens := val.GetTokens().ToDec()
s.Require().True(initialTokens.Sub(initialTokens.Mul(slashFraction)).Equal(actualTokens))
} else {
s.Require().Error(err)
Expand Down
8 changes: 0 additions & 8 deletions x/ccv/provider/keeper/punish_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,9 @@ func TestComputePowerToSlash(t *testing.T) {
}).AnyTimes(),
)

tokensBeforeCall := validator.GetTokens()
delegatorSharesBeforeCall := validator.GetDelegatorShares()

actualPower := providerKeeper.ComputePowerToSlash(ctx, validator,
tc.undelegations, tc.redelegations, tc.power, tc.powerReduction)

// safeguard check that validator remains unmodified after a call to `ComputePowerToSlash`
// `ComputePowerToSlash` only computes the power and does not modify the state of the system in any way
require.Equal(t, tokensBeforeCall, validator.GetTokens())
require.Equal(t, delegatorSharesBeforeCall, validator.GetDelegatorShares())

if tc.expectedPower != actualPower {
require.Fail(t, fmt.Sprintf("\"%s\" failed", tc.name),
"expected is %d but actual is %d", tc.expectedPower, actualPower)
Expand Down

0 comments on commit d3dc0bc

Please sign in to comment.