e2e

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 38 Imported by: 0

README

End To End Testing

E2e tests are categorized into files as follows:

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

To run the e2e 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

This section is empty.

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 e2e functionality of ccv enabled chains. Any method implemented for this struct will be ran when suite.Run() is called.

func NewCCVTestSuite

func NewCCVTestSuite[Tp e2eutil.ProviderApp, Tc e2eutil.ConsumerApp](
	providerAppIniter ibctesting.AppIniter, consumerAppIniter ibctesting.AppIniter, skippedTests []string) *CCVTestSuite

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

func (*CCVTestSuite) BeforeTest added in v1.0.0

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) GetConsumerEndpointClientAndConsState added in v0.2.1

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) SendEmptyVSCPacket

func (suite *CCVTestSuite) SendEmptyVSCPacket()

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

func (*CCVTestSuite) SetupAllCCVChannels added in v1.0.0

func (suite *CCVTestSuite) SetupAllCCVChannels()

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

func (*CCVTestSuite) TestBasicSlashPacketThrottling added in v1.0.0

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) TestConsumerPacketSendExpiredClient added in v1.0.0

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 added in v1.0.0

func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling()

func (*CCVTestSuite) TestEndBlockRD added in v1.0.0

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 e2e test to avoid excessive mocking.

func (*CCVTestSuite) TestHandleSlashPacketDowntime added in v1.0.0

func (suite *CCVTestSuite) TestHandleSlashPacketDowntime()

TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with e2e 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) TestInitTimeout

func (suite *CCVTestSuite) TestInitTimeout()

TestInitTimeout tests the init timeout

func (*CCVTestSuite) TestKeyAssignment added in v1.0.0

func (s *CCVTestSuite) TestKeyAssignment()

func (*CCVTestSuite) TestLeadingVSCMaturedAreDequeued added in v1.0.0

func (s *CCVTestSuite) TestLeadingVSCMaturedAreDequeued()

func (*CCVTestSuite) TestMultiConsumerSlashPacketThrottling added in v1.0.0

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 added in v1.0.0

func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors()

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

func (*CCVTestSuite) TestPacketRoundtrip

func (s *CCVTestSuite) TestPacketRoundtrip()

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

func (*CCVTestSuite) TestPacketSpam added in v1.0.0

func (s *CCVTestSuite) TestPacketSpam()

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

func (*CCVTestSuite) TestProviderChannelClosed

func (suite *CCVTestSuite) TestProviderChannelClosed()

TestProviderChannelClosed checks that a consumer chain panics when the provider channel was established and then closed

func (*CCVTestSuite) TestQueueAndSendSlashPacket added in v1.0.0

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 added in v1.0.0

func (suite *CCVTestSuite) TestQueueAndSendVSCMaturedPackets()

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

func (*CCVTestSuite) TestQueueOrdering added in v1.0.0

func (s *CCVTestSuite) TestQueueOrdering()

TestQueueOrdering validates that the ordering of slash packet entries in the global queue (relevant to a single chain) matches the ordering of slash packet data in the chain specific queues, even in the presence of packet spam.

Note: The global queue is ordered by: time, then IBC sequence number, see GlobalSlashEntryKey. The chain specific queue is ordered by: IBC sequence number, see ThrottledPacketDataKey.

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

func (s *CCVTestSuite) TestSendRewardsRetries()

TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks

func (CCVTestSuite) TestSlashAllValidators added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

func (s *CCVTestSuite) TestSlashPacketAcknowledgement()

func (*CCVTestSuite) TestSlashSameValidator added in v1.0.0

func (s *CCVTestSuite) TestSlashSameValidator()

TestSlashSameValidator tests the edge case that that the total slashed validator power queued up for a single block exceeds the slash meter allowance, but some of the slash packets are for the same validator, and therefore some packets will be applied to a validator that is already jailed but still not unbonded (ie. still slashable).

func (*CCVTestSuite) TestSlashingSmallValidators added in v1.0.0

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) 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 added in v1.0.0

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 e2eutil.DemocConsumerApp](
	democConsumerAppIniter ibctesting.AppIniter) *ConsumerDemocracyTestSuite

NewCCVTestSuite 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) TestDemocracyRewardsDistribution

func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution()

type DemocSetupCallback

type DemocSetupCallback func(t *testing.T) (
	coord *ibctesting.Coordinator,
	consumerChain *ibctesting.TestChain,
	consumerApp e2eutil.DemocConsumerApp,
)

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

type SetupConsumerCallback added in v1.0.0

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 added in v1.0.0

type SetupProviderCallback func(t *testing.T) (
	coord *ibctesting.Coordinator,
	providerChain *ibctesting.TestChain,
	providerApp e2eutil.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