integration

package
v5.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 52 Imported by: 0

README

Integration Testing

Integration tests are categorized into files as follows:

  • setup.go - setup for the integration tests
  • common.go - helper functions
  • channel_init.go - integration tests for the Channel Initialization sub-protocol
  • valset_update.go - integration tests for the Validator Set Update sub-protocol
  • unbonding.go - integration tests for the Completion of Unbonding Operations
  • slashing.go - integration tests for the Consumer Initiated Slashing sub-protocol
  • distribution.go - integration tests for the Reward Distribution sub-protocol
  • stop_consumer.go - integration tests for the Consumer Chain Removal sub-protocol
  • normal_operations.go - integration tests for normal operations of ICS enabled chains
  • expired_client.go - integration tests for testing expired clients
  • key_assignment.go - integration tests for testing key assignment
  • instance_test.go - ties the integration test structure into golang's standard test mechanism, with appropriate definitions for concrete app types and setup callback

To run the integration tests defined in this repo on any arbitrary consumer and provider implementation, copy the pattern exemplified in instance_test.go and specific_setup.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePacketsFromEvents

func ParsePacketsFromEvents(events []abci.Event) (packets []channeltypes.Packet)

ParsePacketsFromEvents returns all packets found in events.

Types

type CCVTestSuite

type CCVTestSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

CCVTestSuite is an in-mem test suite which implements the standard group of tests validating the integration functionality of ccv enabled chains. Any method implemented for this struct will be ran when suite.Run() is called.

func NewCCVTestSuite

func NewCCVTestSuite[Tp testutil.ProviderApp, Tc testutil.ConsumerApp](
	providerAppIniter icstestingutils.AppIniter,
	consumerAppIniter icstestingutils.ValSetAppIniter,
	skippedTests []string,
) *CCVTestSuite

NewCCVTestSuite returns a new instance of CCVTestSuite, ready to be tested against using suite.Run().

func (*CCVTestSuite) BeforeTest

func (suite *CCVTestSuite) BeforeTest(suiteName, testName string)

func (*CCVTestSuite) CreateCustomClient

func (suite *CCVTestSuite) CreateCustomClient(endpoint *ibctesting.Endpoint, unbondingPeriod time.Duration)

CreateCustomClient creates an IBC client on the endpoint using the given unbonding period. It will update the clientID for the endpoint if the message is successfully executed.

func (*CCVTestSuite) ExecuteCCVChannelHandshake

func (suite *CCVTestSuite) ExecuteCCVChannelHandshake(path *ibctesting.Path)

func (*CCVTestSuite) GetCCVPath

func (suite *CCVTestSuite) GetCCVPath() *ibctesting.Path

GetCCVPath returns the CCV path which is required to call SetupCCVChannel

func (*CCVTestSuite) GetConsumerEndpointClientAndConsState

func (suite *CCVTestSuite) GetConsumerEndpointClientAndConsState(
	consumerBundle icstestingutils.ConsumerBundle,
) (exported.ClientState, exported.ConsensusState)

GetConsumerEndpointClientAndConsState returns the client and consensus state for a particular consumer endpoint, as specified by the consumer's bundle.

func (*CCVTestSuite) GetProviderChain

func (suite *CCVTestSuite) GetProviderChain() *ibctesting.TestChain

GetProviderChain returns the provider chain struct which is required to get context and have control over the blocks

func (*CCVTestSuite) SendEmptyVSCPacket

func (suite *CCVTestSuite) SendEmptyVSCPacket()

SendEmptyVSCPacket sends a VSC packet without any changes to ensure that the channel gets established

func (*CCVTestSuite) SetupAllCCVChannels

func (suite *CCVTestSuite) SetupAllCCVChannels()

func (*CCVTestSuite) SetupAllTransferChannels added in v5.1.0

func (suite *CCVTestSuite) SetupAllTransferChannels()

SetupAllTransferChannel setup all consumer chains transfer channel

func (*CCVTestSuite) SetupCCVChannel

func (suite *CCVTestSuite) SetupCCVChannel(path *ibctesting.Path)

func (*CCVTestSuite) SetupTest

func (suite *CCVTestSuite) SetupTest()

SetupTest sets up in-mem state before every test

func (*CCVTestSuite) SetupTransferChannel

func (suite *CCVTestSuite) SetupTransferChannel()

TODO: Make SetupTransferChannel functional for multiple consumers by pattern matching SetupCCVChannel. See: https://github.com/cosmos/interchain-security/issues/506 SetupTransferChannel setup the transfer channel of the first consumer chain among multiple

func (*CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded

func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded()

tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks hooks require adding a proposal in the gov module and regitering a consumer chain with the provider module

func (*CCVTestSuite) TestAllocateTokens added in v5.1.0

func (s *CCVTestSuite) TestAllocateTokens()

TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool

func (*CCVTestSuite) TestAllocateTokensToConsumerValidators added in v5.1.0

func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators()

func (*CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights added in v5.1.0

func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights()

TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards.

func (*CCVTestSuite) TestBasicSlashPacketThrottling

func (s *CCVTestSuite) TestBasicSlashPacketThrottling()

TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario.

func (*CCVTestSuite) TestCISBeforeCCVEstablished

func (suite *CCVTestSuite) TestCISBeforeCCVEstablished()

TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.

func (*CCVTestSuite) TestCheckMisbehaviour

func (s *CCVTestSuite) TestCheckMisbehaviour()

func (*CCVTestSuite) TestConsumerPacketSendExpiredClient

func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient()

TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired. While the provider client is expired all packets will be queued and and cleared once the provider client is upgraded.

func (*CCVTestSuite) TestDoubleSignDoesNotAffectThrottling

func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling()

func (*CCVTestSuite) TestEndBlockRD

func (s *CCVTestSuite) TestEndBlockRD()

TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed.

Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking.

func (*CCVTestSuite) TestGetByzantineValidators

func (s *CCVTestSuite) TestGetByzantineValidators()

func (*CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp

func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp()

func (*CCVTestSuite) TestHandleConsumerDoubleVoting

func (s *CCVTestSuite) TestHandleConsumerDoubleVoting()

TestHandleConsumerDoubleVoting verifies that handling a double voting evidence of a consumer chain results in the expected tombstoning, jailing, and slashing of the misbehaved validator

func (*CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations

func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations()

TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations

func (*CCVTestSuite) TestHandleConsumerMisbehaviour

func (s *CCVTestSuite) TestHandleConsumerMisbehaviour()

TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour, with conflicting headers forming an equivocation, results in the jailing of the validators

func (*CCVTestSuite) TestHandleSlashPacketDowntime

func (suite *CCVTestSuite) TestHandleSlashPacketDowntime()

TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests. Note that only downtime slash packets are processed by HandleSlashPacket.

func (CCVTestSuite) TestHistoricalInfo

func (k CCVTestSuite) TestHistoricalInfo()

Tests the tracking of historical info in the context of new blocks being committed

func (*CCVTestSuite) TestIBCTransferMiddleware added in v5.1.0

func (s *CCVTestSuite) TestIBCTransferMiddleware()

TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback

func (*CCVTestSuite) TestInitTimeout

func (suite *CCVTestSuite) TestInitTimeout()

TestInitTimeout tests the init timeout

func (*CCVTestSuite) TestKeyAssignment

func (s *CCVTestSuite) TestKeyAssignment()

func (*CCVTestSuite) TestMultiConsumerRewardsDistribution added in v5.1.0

func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution()

TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains

func (*CCVTestSuite) TestMultiConsumerSlashPacketThrottling

func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling()

TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around.

func (*CCVTestSuite) TestOnRecvSlashPacketErrors

func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors()

TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting

func (*CCVTestSuite) TestPacketRoundtrip

func (s *CCVTestSuite) TestPacketRoundtrip()

TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on provider

func (*CCVTestSuite) TestPacketSpam

func (s *CCVTestSuite) TestPacketSpam()

TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.

func (*CCVTestSuite) TestQueueAndSendSlashPacket

func (suite *CCVTestSuite) TestQueueAndSendSlashPacket()

TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.

func (*CCVTestSuite) TestQueueAndSendVSCMaturedPackets

func (suite *CCVTestSuite) TestQueueAndSendVSCMaturedPackets()

TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.

func (*CCVTestSuite) TestRecycleTransferChannel

func (suite *CCVTestSuite) TestRecycleTransferChannel()

func (*CCVTestSuite) TestRedelegationNoConsumer

func (s *CCVTestSuite) TestRedelegationNoConsumer()

TestRedelegationNoConsumer tests a redelegate transaction submitted on a provider chain with no consumers

func (*CCVTestSuite) TestRedelegationProviderFirst

func (s *CCVTestSuite) TestRedelegationProviderFirst()

TestRedelegationWithConsumer tests a redelegate transaction submitted on a provider chain when the unbonding period elapses first on the provider chain

func (*CCVTestSuite) TestRelayAndApplyDoubleSignPacket

func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket()

Similar setup to TestRelayAndApplyDowntimePacket, but with a double sign slash packet. Note that double-sign slash packets should not affect the provider validator set.

func (*CCVTestSuite) TestRelayAndApplyDowntimePacket

func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket()

TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider.

Note: This method does not test the actual slash packet sending logic for downtime and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for those types of tests.

func (*CCVTestSuite) TestRewardsDistribution

func (s *CCVTestSuite) TestRewardsDistribution()

This test is valid for minimal viable consumer chain

func (*CCVTestSuite) TestSendRewardsRetries

func (s *CCVTestSuite) TestSendRewardsRetries()

TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks

func (*CCVTestSuite) TestSendRewardsToProvider

func (s *CCVTestSuite) TestSendRewardsToProvider()

TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.

func (CCVTestSuite) TestSlashAllValidators

func (s CCVTestSuite) TestSlashAllValidators()

Similar to TestSlashSameValidator, but 100% of val power is jailed a single block, and in the first packets recv for that block. This edge case should not occur in practice, but is useful to validate that the slash meter can allow any number of slash packets to be handled in a single block when its allowance is set to "1.0".

func (*CCVTestSuite) TestSlashMeterAllowanceChanges

func (s *CCVTestSuite) TestSlashMeterAllowanceChanges()

TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.

TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges.

func (*CCVTestSuite) TestSlashPacketAcknowledgement

func (s *CCVTestSuite) TestSlashPacketAcknowledgement()

func (*CCVTestSuite) TestSlashRetries

func (s *CCVTestSuite) TestSlashRetries()

TestSlashRetries tests the throttling v2 retry logic at an integration level.

func (*CCVTestSuite) TestSlashingSmallValidators

func (s *CCVTestSuite) TestSlashingSmallValidators()

TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.

func (*CCVTestSuite) TestStopConsumerChain

func (s *CCVTestSuite) TestStopConsumerChain()

Tests the functionality of stopping a consumer chain at a higher level than unit tests

func (*CCVTestSuite) TestStopConsumerOnChannelClosed

func (s *CCVTestSuite) TestStopConsumerOnChannelClosed()

TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end

func (*CCVTestSuite) TestTooManyLastValidators added in v5.1.0

func (s *CCVTestSuite) TestTooManyLastValidators()

This test reproduces a fixed bug when an inactive validator enters back into the active set. It used to cause a panic in the provider module hook called by AfterUnbondingInitiated during the staking module EndBlock.

func (*CCVTestSuite) TestUnbondingNoConsumer

func (s *CCVTestSuite) TestUnbondingNoConsumer()

Bond some tokens on provider Unbond them to create unbonding op Check unbonding ops on both sides Advance time so that provider's unbonding op completes Check that unbonding has completed in provider staking

func (*CCVTestSuite) TestUndelegationDuringInit

func (s *CCVTestSuite) TestUndelegationDuringInit()

TestUndelegationDuringInit checks that before the CCV channel is established

  • no undelegations can complete, even if the provider unbonding period elapses
  • all the VSC packets are stored in state as pending
  • if the channel handshake times out, then the undelegation completes

func (*CCVTestSuite) TestUndelegationNormalOperation

func (s *CCVTestSuite) TestUndelegationNormalOperation()

TestUndelegationNormalOperation tests that undelegations complete after the unbonding period elapses on both the consumer and provider, without VSC packets timing out.

func (*CCVTestSuite) TestUndelegationVscTimeout

func (s *CCVTestSuite) TestUndelegationVscTimeout()

TestUndelegationVscTimeout tests that an undelegation completes after vscTimeoutPeriod even if it does not reach maturity on the consumer chain. In this case, the consumer chain is removed.

func (*CCVTestSuite) TestVSCPacketSendExpiredClient

func (s *CCVTestSuite) TestVSCPacketSendExpiredClient()

TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. While the consumer client is expired (or inactive for some reason) all packets will be queued and and cleared once the consumer client is established.

func (*CCVTestSuite) TestValidatorDoubleSigning

func (suite *CCVTestSuite) TestValidatorDoubleSigning()

TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module

func (*CCVTestSuite) TestValidatorDowntime

func (suite *CCVTestSuite) TestValidatorDowntime()

TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module

type ChainType

type ChainType int

ChainType defines the type of chain (either provider or consumer)

const (
	Provider ChainType = iota
	Consumer
)

type ConsumerDemocracyTestSuite

type ConsumerDemocracyTestSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

func NewConsumerDemocracyTestSuite

func NewConsumerDemocracyTestSuite[T testutil.DemocConsumerApp](
	democConsumerAppIniter icstestingutils.ValSetAppIniter,
) *ConsumerDemocracyTestSuite

NewConsumerDemocracyTestSuite returns a new instance of ConsumerDemocracyTestSuite, ready to be tested against using suite.Run().

func (*ConsumerDemocracyTestSuite) SetupTest

func (suite *ConsumerDemocracyTestSuite) SetupTest()

SetupTest sets up in-mem state before every test relevant to ccv with a democracy consumer

func (*ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting

func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting()

func (*ConsumerDemocracyTestSuite) TestDemocracyMsgUpdateParams

func (s *ConsumerDemocracyTestSuite) TestDemocracyMsgUpdateParams()

func (*ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution

func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution()

type DemocSetupCallback

type DemocSetupCallback func(s *suite.Suite) (
	coord *ibctesting.Coordinator,
	consumerChain *ibctesting.TestChain,
	consumerApp testutil.DemocConsumerApp,
)

Callback for instantiating a new coordinator, consumer test chain, and consumer app before every test defined on the suite.

type SetupConsumerCallback

type SetupConsumerCallback func(s *suite.Suite, coord *ibctesting.Coordinator, index int) (
	consumerBundle *icstestingutils.ConsumerBundle,
)

Callback for instantiating a new consumer test chain and consumer app before every test defined on the suite.

type SetupProviderCallback

type SetupProviderCallback func(t *testing.T) (
	coord *ibctesting.Coordinator,
	providerChain *ibctesting.TestChain,
	providerApp testutil.ProviderApp,
)

Callback for instantiating a new coordinator with a provider test chains and provider app before every test defined on the suite.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL