Skip to content

Commit

Permalink
Added cli option to enable genesis-transformation: disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Nov 30, 2023
1 parent dd6b830 commit d23e039
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
7 changes: 3 additions & 4 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,9 @@ func (tr *TestRun) startConsumerChain(
log.Fatal(err, "\n", string(bz))
}

// Hack to deal with deprecated consumer genesis exports
// TODO: needs better case identification
if tr.consumerVersion != "" {
log.Printf("Transforming consumer genesis for a newer version: %s\n", tr.consumerVersion)
// only needed when consumer is running v3.2.x and later
if tr.transformGenesis {
log.Printf("@@@@ Transforming consumer genesis for a newer version: %s\n", tr.consumerVersion)
log.Printf("Original ccv genesis: %s\n", string(bz))

file, err := os.Create("consumer_genesis.json")
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ type TestRun struct {
timeOffset time.Duration

// consumer version the provider should be tested against
consumerVersion string
providerVersion string
name string
consumerVersion string
providerVersion string
transformGenesis bool
name string
}

// Initialize initializes the TestRun instance by setting the runningChains field to an empty map.
Expand Down
14 changes: 9 additions & 5 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (
var (
useConsumerVersion = flag.String("consumer-version", "", "ICS tag to specify the consumer version to test the provider against")
useProviderVersion = flag.String("provider-version", "", "ICS tag to specify the provider version to test the consumer against")
transformGenesis = flag.Bool("transform-genesis", false, "do consumer genesis transformation for newer clients. Needed when provider chain is on an older version")
)

// runs E2E tests
Expand All @@ -51,14 +52,14 @@ func main() {
if shortHappyPathOnly != nil && *shortHappyPathOnly {
fmt.Println("=============== running short happy path only ===============")
tr := DefaultTestRun()
tr.Run(shortHappyPathSteps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion)
tr.Run(shortHappyPathSteps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion, *transformGenesis)
return
}

if happyPathOnly != nil && *happyPathOnly {
fmt.Println("=============== running happy path only ===============")
tr := DefaultTestRun()
tr.Run(happyPathSteps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion)
tr.Run(happyPathSteps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion, *transformGenesis)
return
}

Expand Down Expand Up @@ -86,7 +87,7 @@ func main() {
go func(run testRunWithSteps) {
defer wg.Done()
tr := run.testRun
tr.Run(run.steps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion)
tr.Run(run.steps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion, *transformGenesis)
}(run)
}
wg.Wait()
Expand All @@ -96,18 +97,21 @@ func main() {

for _, run := range testRuns {
tr := run.testRun
tr.Run(run.steps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion)
tr.Run(run.steps, *localSdkPath, *useGaia, *gaiaTag, *useConsumerVersion, *useProviderVersion, *transformGenesis)
}
fmt.Printf("TOTAL TIME ELAPSED: %v\n", time.Since(start))
}

// Run sets up docker container and executes the steps in the test run.
// Docker containers are torn down after the test run is complete.
func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag string, consumerVersion string, providerVersion string) {
func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag string, consumerVersion string, providerVersion string, transformGenesis bool) {
tr.SetDockerConfig(localSdkPath, useGaia, gaiaTag, consumerVersion, providerVersion)
tr.SetCometMockConfig(*useCometmock)
tr.SetRelayerConfig(*useGorelayer)

// Hack to disable genesis transformation... do it smarter
tr.transformGenesis = transformGenesis

tr.validateStringLiterals()
tr.startDocker()
tr.executeSteps(steps)
Expand Down

0 comments on commit d23e039

Please sign in to comment.