Skip to content

Commit

Permalink
Removed TestRelayAndApplyDoubleSignPacket test from slashing.go
Browse files Browse the repository at this point in the history
  • Loading branch information
kirdatatjana committed Sep 16, 2024
1 parent 9d357b4 commit cd3dd19
Showing 1 changed file with 0 additions and 93 deletions.
93 changes: 0 additions & 93 deletions tests/integration/slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,99 +175,6 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() {
s.Require().NoError(err)
}

// TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets,
// handled by provider, with a VSC and jailing eventually effective on consumer and provider.
// @Long Description@
// It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
// The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
// Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
// The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
// timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
// and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
// packet to confirm that it has been processed.
//
// Note that double-sign slash packets should not affect the provider validator set.
func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() {
// Setup CCV channel for all instantiated consumers
s.SetupAllCCVChannels()

providerStakingKeeper := s.providerApp.GetTestStakingKeeper()
providerKeeper := s.providerApp.GetProviderKeeper()
providerSlashingKeeper := s.providerApp.GetTestSlashingKeeper()

validatorsPerChain := len(s.consumerChain.Vals.Validators)

// pick first consumer validator
tmVal := s.consumerChain.Vals.Validators[0]
val, err := tmVal.ToProto()
s.Require().NoError(err)
pubkey, err := cryptocodec.FromCmtProtoPublicKey(val.GetPubKey())
s.Require().Nil(err)
consumerConsAddr := providertypes.NewConsumerConsAddress(sdk.GetConsAddress(pubkey))
// map consumer consensus address to provider consensus address
providerConsAddr, found := providerKeeper.GetValidatorByConsumerAddr(
s.providerCtx(),
s.getFirstBundle().ConsumerId,
consumerConsAddr)
s.Require().True(found)

stakingVal, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr())
s.Require().NoError(err)
valOldBalance := stakingVal.Tokens

// Setup first val with mapped consensus address to be jailed on provider by setting signing info
// convert validator to TM type
pk, err := stakingVal.ConsPubKey()
s.Require().NoError(err)
tmPk, err := cryptocodec.ToCmtPubKeyInterface(pk)
s.Require().NoError(err)
s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction)))

// Send slash packet from the first consumer chain
var (
timeoutHeight = clienttypes.Height{}
timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano())
)
slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, 1)
packet := sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData())

// Advance a few more blocks to make sure any voting power changes would be reflected
s.providerChain.NextBlock()
s.providerChain.NextBlock()
s.providerChain.NextBlock()

// Confirm validator was NOT removed from provider validator set
s.Require().Len(s.providerChain.Vals.Validators, validatorsPerChain)

// Get staking keeper's validator obj after the relayed slash packet
stakingValAfter, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr())
s.Require().NoError(err)

// check that the validator's tokens were NOT slashed on provider
valNewBalance := stakingValAfter.GetTokens()
s.Require().Equal(valOldBalance, valNewBalance)

// Get signing info for the validator
valSignInfo, err := providerSlashingKeeper.GetValidatorSigningInfo(s.providerCtx(), providerConsAddr.ToSdkConsAddr())
s.Require().NoError(err)

// check that the validator's unjailing time is NOT updated on provider
s.Require().Zero(valSignInfo.JailedUntil)

// check that the validator is not jailed and still bonded on provider
s.Require().False(stakingValAfter.Jailed)
s.Require().Equal(stakingValAfter.Status, stakingtypes.Bonded)

// check that validator was NOT tombstoned on provider
s.Require().False(valSignInfo.Tombstoned)

// check that slashing packet gets acknowledged successfully,
// provider returns V1Result acks for double sign packets
ack := channeltypes.NewResultAcknowledgement(ccv.V1Result)
err = s.path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement())
s.Require().NoError(err)
}

// TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.
// @Long Description@
// It sets up a provider and consumer chain, with channel initialization between them performed,
Expand Down

0 comments on commit cd3dd19

Please sign in to comment.