Skip to content

Commit

Permalink
ci: Move interchaintests into folders based on user stories
Browse files Browse the repository at this point in the history
  • Loading branch information
fastfadingviolets committed Nov 6, 2024
1 parent baa20b9 commit bc935c7
Show file tree
Hide file tree
Showing 23 changed files with 834 additions and 691 deletions.
6 changes: 3 additions & 3 deletions tests/interchain/chainsuite/chain_ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ConsumerConfig struct {
ChainName string
Version string
Denom string
ShouldCopyProviderKey [ValidatorCount]bool
ShouldCopyProviderKey []bool
TopN int
ValidatorSetCap int
ValidatorPowerCap int
Expand Down Expand Up @@ -100,8 +100,8 @@ func newProposalWaiter() *proposalWaiter {
func (p *Chain) AddConsumerChain(ctx context.Context, relayer *Relayer, config ConsumerConfig) (*Chain, error) {
dockerClient, dockerNetwork := GetDockerContext(ctx)

if len(config.ShouldCopyProviderKey) != ValidatorCount {
return nil, fmt.Errorf("shouldCopyProviderKey must be the same length as the number of validators")
if len(config.ShouldCopyProviderKey) < len(p.Validators) {
return nil, fmt.Errorf("shouldCopyProviderKey should have at least %d elements", len(p.Validators))
}

spawnTime := time.Now().Add(ChainSpawnWait)
Expand Down
16 changes: 12 additions & 4 deletions tests/interchain/chainsuite/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (
DowntimeJailDuration = 10 * time.Second
ProviderSlashingWindow = 10
GasPrices = "0.005" + Uatom
ValidatorCount = 6
// ValidatorCount = 1
UpgradeDelta = 30
ValidatorFunds = 11_000_000_000
ChainSpawnWait = 155 * time.Second
Expand All @@ -57,6 +57,12 @@ const (
ICSUidGuid = "1025:1025"
)

// These have to be vars so we can take their address
var (
OneValidator int = 1
SixValidators int = 6
)

func MergeChainSpecs(spec, other *interchaintest.ChainSpec) *interchaintest.ChainSpec {
if spec == nil {
return other
Expand Down Expand Up @@ -96,12 +102,15 @@ func (c SuiteConfig) Merge(other SuiteConfig) SuiteConfig {

func DefaultGenesisAmounts(denom string) func(i int) (types.Coin, types.Coin) {
return func(i int) (types.Coin, types.Coin) {
if i >= SixValidators {
panic("your chain has too many validators")
}
return types.Coin{
Denom: denom,
Amount: sdkmath.NewInt(ValidatorFunds),
}, types.Coin{
Denom: denom,
Amount: sdkmath.NewInt([ValidatorCount]int64{
Amount: sdkmath.NewInt([]int64{
30_000_000,
29_000_000,
20_000_000,
Expand All @@ -115,7 +124,6 @@ func DefaultGenesisAmounts(denom string) func(i int) (types.Coin, types.Coin) {

func DefaultChainSpec(env Environment) *interchaintest.ChainSpec {
fullNodes := 0
validators := ValidatorCount
var repository string
if env.DockerRegistry == "" {
repository = env.GaiaImageName
Expand All @@ -125,7 +133,7 @@ func DefaultChainSpec(env Environment) *interchaintest.ChainSpec {
return &interchaintest.ChainSpec{
Name: "gaia",
NumFullNodes: &fullNodes,
NumValidators: &validators,
NumValidators: &OneValidator,
Version: env.OldGaiaImageVersion,
ChainConfig: ibc.ChainConfig{
Denom: Uatom,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interchain_test
package consumer_chain_test

import (
"encoding/json"
Expand Down Expand Up @@ -145,7 +145,7 @@ func (s *ConsensusSuite) TestProviderJailing() {
s.Require().NoError(err)
s.Assert().True(jailed, "validator %d should be jailed", i)
}
for i := maxProviderConsensusValidators; i < chainsuite.ValidatorCount; i++ {
for i := maxProviderConsensusValidators; i < len(s.Chain.Validators); i++ {
jailed, err := s.Chain.IsValidatorJailedForConsumerDowntime(s.GetContext(), s.Relayer, s.Chain, i)
s.Require().NoError(err)
s.Assert().False(jailed, "validator %d should not be jailed", i)
Expand All @@ -161,7 +161,7 @@ func (s *ConsensusSuite) TestConsumerJailing() {
// Validator 4 will have been opted in automatically when the other ones went down
_, err := s.Chain.Validators[maxProviderConsensusValidators].ExecTx(s.GetContext(), s.Chain.ValidatorWallets[maxProviderConsensusValidators].Moniker, "provider", "opt-out", s.getConsumerID())
s.Require().NoError(err)
for i := maxProviderConsensusValidators; i < chainsuite.ValidatorCount; i++ {
for i := maxProviderConsensusValidators; i < len(s.Chain.Validators); i++ {
jailed, err := s.Chain.IsValidatorJailedForConsumerDowntime(s.GetContext(), s.Relayer, s.Consumer, i)
s.Require().NoError(err)
s.Assert().False(jailed, "validator %d should not be jailed", i)
Expand Down Expand Up @@ -219,7 +219,12 @@ func (s *ConsensusSuite) getConsumerID() string {

func TestConsensus(t *testing.T) {
s := &ConsensusSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}),
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
ChainSpec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
},
}),
}
suite.Run(t, s)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interchain_test
package consumer_chain_test

import (
"testing"
Expand All @@ -16,19 +16,19 @@ type ConsumerLaunchSuite struct {
OtherChain string
OtherChainVersionPreUpgrade string
OtherChainVersionPostUpgrade string
ShouldCopyProviderKey [chainsuite.ValidatorCount]bool
ShouldCopyProviderKey []bool
}

func noProviderKeysCopied() [chainsuite.ValidatorCount]bool {
return [chainsuite.ValidatorCount]bool{false, false, false, false, false, false}
func noProviderKeysCopied() []bool {
return []bool{false, false, false, false, false, false}
}

func allProviderKeysCopied() [chainsuite.ValidatorCount]bool {
return [chainsuite.ValidatorCount]bool{true, true, true, true, true, true}
func allProviderKeysCopied() []bool {
return []bool{true, true, true, true, true, true}
}

func someProviderKeysCopied() [chainsuite.ValidatorCount]bool {
return [chainsuite.ValidatorCount]bool{true, false, true, false, true, false}
func someProviderKeysCopied() []bool {
return []bool{true, false, true, false, true, false}
}

func (s *ConsumerLaunchSuite) TestChainLaunch() {
Expand Down Expand Up @@ -93,7 +93,12 @@ func selectConsumerVersion(preV21, postV21 string) string {

func TestICS4ChainLaunch(t *testing.T) {
s := &ConsumerLaunchSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}),
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
ChainSpec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
},
}),
OtherChain: "ics-consumer",
OtherChainVersionPreUpgrade: selectConsumerVersion("v4.4.1", "v4.5.0"),
OtherChainVersionPostUpgrade: "v4.5.0",
Expand All @@ -104,7 +109,12 @@ func TestICS4ChainLaunch(t *testing.T) {

func TestICS6ConsumerAllKeysChainLaunch(t *testing.T) {
s := &ConsumerLaunchSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}),
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
ChainSpec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
},
}),
OtherChain: "ics-consumer",
OtherChainVersionPreUpgrade: selectConsumerVersion("v6.0.0", "v6.2.1"),
OtherChainVersionPostUpgrade: "v6.2.1",
Expand All @@ -115,7 +125,12 @@ func TestICS6ConsumerAllKeysChainLaunch(t *testing.T) {

func TestICS6ConsumerSomeKeysChainLaunch(t *testing.T) {
s := &ConsumerLaunchSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}),
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
ChainSpec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
},
}),
OtherChain: "ics-consumer",
OtherChainVersionPreUpgrade: selectConsumerVersion("v6.0.0", "v6.2.1"),
OtherChainVersionPostUpgrade: "v6.2.1",
Expand All @@ -126,7 +141,12 @@ func TestICS6ConsumerSomeKeysChainLaunch(t *testing.T) {

func TestICS6ConsumerNoKeysChainLaunch(t *testing.T) {
s := &ConsumerLaunchSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}),
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
ChainSpec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
},
}),
OtherChain: "ics-consumer",
OtherChainVersionPreUpgrade: selectConsumerVersion("v6.0.0", "v6.2.1"),
OtherChainVersionPostUpgrade: "v6.2.1",
Expand Down Expand Up @@ -174,7 +194,12 @@ func (s *MainnetConsumerChainsSuite) TestMainnetConsumerChainsAfterUpgrade() {

func TestMainnetConsumerChainsAfterUpgrade(t *testing.T) {
s := &MainnetConsumerChainsSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}),
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
ChainSpec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
},
}),
}
suite.Run(t, s)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interchain_test
package consumer_chain_test

import (
"context"
Expand Down Expand Up @@ -402,7 +402,7 @@ func (s *PermissionlessConsumersSuite) TestConsumerCommissionRate() {
s.Require().NoError(err)
s.Require().NoError(s.Chain.CheckCCV(s.GetContext(), consumer2, s.Relayer, 1_000_000, 0, 1))

for i := 1; i < chainsuite.ValidatorCount; i++ {
for i := 1; i < len(consumer1.Validators); i++ {
s.Require().NoError(consumer1.Validators[i].StopContainer(s.GetContext()))
s.Require().NoError(consumer2.Validators[i].StopContainer(s.GetContext()))
}
Expand Down Expand Up @@ -686,6 +686,7 @@ func TestPermissionlessConsumers(t *testing.T) {
CreateRelayer: true,
Scope: chainsuite.ChainScopeTest,
ChainSpec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
ChainConfig: ibc.ChainConfig{
ModifyGenesis: cosmos.ModifyGenesis(genesis),
},
Expand All @@ -700,6 +701,7 @@ func TestPermissionlessConsumers(t *testing.T) {
AllowInactiveVals: true,
MinStake: 1_000_000,
Spec: &interchaintest.ChainSpec{
NumValidators: &chainsuite.SixValidators,
ChainConfig: ibc.ChainConfig{
Images: []ibc.DockerImage{
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interchain_test
package consumer_chain_test

import (
"context"
Expand Down
Loading

0 comments on commit bc935c7

Please sign in to comment.