Skip to content

Commit

Permalink
specific network pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Sep 8, 2023
1 parent 7e45592 commit 9d190be
Showing 1 changed file with 61 additions and 34 deletions.
95 changes: 61 additions & 34 deletions integration-tests/ccip-tests/testsetups/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,47 +191,35 @@ func (p *CCIPTestConfig) setLoadInputs() {
}
}

func (p *CCIPTestConfig) FormNetworkPairs() {
for i := 0; i < p.NoOfNetworks; i++ {
for j := i + 1; j < p.NoOfNetworks; j++ {
func (p *CCIPTestConfig) SetNetworkPairs(t *testing.T, lggr zerolog.Logger) error {
var allError error
// if network pairs are provided, then use them
// example usage - CCIP_NETWORK_PAIRS="networkA,networkB|networkC,networkD|networkA,networkC"
lanes, _ := utils.GetEnv("CCIP_NETWORK_PAIRS")
if lanes != "" {
p.NetworkPairs = []NetworkPair{}
networkPairs := strings.Split(lanes, "|")
for _, pair := range networkPairs {
networkNames := strings.Split(pair, ",")
if len(networkNames) != 2 {
allError = multierr.Append(allError, fmt.Errorf("invalid network pair"))
}
nets := networks.SetNetworks(networkNames)
p.NetworkPairs = append(p.NetworkPairs, NetworkPair{
NetworkA: p.AllNetworks[i],
NetworkB: p.AllNetworks[j],
NetworkA: nets[0],
NetworkB: nets[1],
})
}
return allError
}
}

// NewCCIPTestConfig collects all test related CCIPTestConfig from environment variables
func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTestConfig {
var allError error
// if network pairs are not provided with CCIP_NETWORK_PAIRS, then form all possible network pair combination from SELECTED_NETWORKS
if len(networks.SelectedNetworks) < 3 {
lggr.Fatal().
Interface("SELECTED_NETWORKS", networks.SelectedNetworks).
Msg("Set source and destination network in index 1 & 2 of env variable SELECTED_NETWORKS")
}
p := &CCIPTestConfig{
Test: t,
MsgType: actions.TokenTransfer,
PhaseTimeout: DefaultPhaseTimeout,
TestDuration: DefaultTestDuration,
NodeFunding: DefaultNodeFunding,
NoOfNetworks: DefaultNoOfNetworks,
AllNetworks: networks.SelectedNetworks[1:],
GethResourceProfile: GethResourceProfile,
}

if tType != Smoke {
p.CLNodeDBResourceProfile = DONDBResourceProfile
}

if tType == Load {
p.EnvTTL = DefaultTTLForLongTests
p.CLNodeResourceProfile = DONResourceProfile
p.NodeFunding = NodeFundingForLoad
p.PhaseTimeout = DefaultPhaseTimeoutForLongTests
}

p.AllNetworks = networks.SelectedNetworks[1:]
p.NoOfNetworks = DefaultNoOfNetworks
inputNoOfNetworks, _ := utils.GetEnv("CCIP_NO_OF_NETWORKS")
if inputNoOfNetworks != "" {
n, err := strconv.Atoi(inputNoOfNetworks)
Expand Down Expand Up @@ -260,7 +248,7 @@ func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTes
// and the provided networks are simulated network, create replicas of the provided networks with
// different chain ids
if len(p.AllNetworks) < p.NoOfNetworks {
if p.AllNetworks[0].Simulated {
if simulated {
actualNoOfNetworks := len(p.AllNetworks)
n := p.AllNetworks[0]
for i := 0; i < p.NoOfNetworks-actualNoOfNetworks; i++ {
Expand All @@ -281,7 +269,7 @@ func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTes
}
lggr.Info().Interface("Networks", p.AllNetworks).Msg("Running tests with networks")
if p.NoOfNetworks > 2 {
p.FormNetworkPairs()
p.FormNetworkPairCombinations()
} else {
p.NetworkPairs = []NetworkPair{
{
Expand All @@ -295,6 +283,45 @@ func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTes
lggr.Info().Str("NetworkA", n.NetworkA.Name).Str("NetworkB", n.NetworkB.Name).Msg("Network Pairs")
}

return allError
}

func (p *CCIPTestConfig) FormNetworkPairCombinations() {
for i := 0; i < p.NoOfNetworks; i++ {
for j := i + 1; j < p.NoOfNetworks; j++ {
p.NetworkPairs = append(p.NetworkPairs, NetworkPair{
NetworkA: p.AllNetworks[i],
NetworkB: p.AllNetworks[j],
})
}
}
}

// NewCCIPTestConfig collects all test related CCIPTestConfig from environment variables
func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTestConfig {
var allError error
p := &CCIPTestConfig{
Test: t,
MsgType: actions.TokenTransfer,
PhaseTimeout: DefaultPhaseTimeout,
TestDuration: DefaultTestDuration,
NodeFunding: DefaultNodeFunding,
GethResourceProfile: GethResourceProfile,
}

if tType != Smoke {
p.CLNodeDBResourceProfile = DONDBResourceProfile
}

if tType == Load {
p.EnvTTL = DefaultTTLForLongTests
p.CLNodeResourceProfile = DONResourceProfile
p.NodeFunding = NodeFundingForLoad
p.PhaseTimeout = DefaultPhaseTimeoutForLongTests
}

allError = multierr.Append(allError, p.SetNetworkPairs(t, lggr))

ttlDuration, _ := utils.GetEnv("CCIP_KEEP_ENV_TTL")
if ttlDuration != "" {
keepEnvFor, err := time.ParseDuration(ttlDuration)
Expand Down

0 comments on commit 9d190be

Please sign in to comment.