Skip to content

Commit

Permalink
chore: use GetUpgradeConfig function
Browse files Browse the repository at this point in the history
  • Loading branch information
chatton committed Nov 29, 2024
1 parent 789a9f4 commit 223e5ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 44 deletions.
24 changes: 12 additions & 12 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
func TestUpgradeTestSuite(t *testing.T) {
testCfg := testsuite.LoadConfig()
if testCfg.UpgradePlanName == "" {
t.Fatalf("%s and %s must be set when running an upgrade test", testsuite.ChainUpgradeTagEnv, testsuite.ChainUpgradePlanEnv)
t.Fatalf("%s must be set when running an upgrade test", testsuite.ChainUpgradePlanEnv)
}

testifysuite.Run(t, new(UpgradeTestSuite))
Expand Down Expand Up @@ -185,7 +185,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() {
s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB), "failed to wait for blocks")

t.Run("upgrade chainA", func(t *testing.T) {
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("restart relayer", func(t *testing.T) {
Expand Down Expand Up @@ -268,7 +268,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {
testCfg := testsuite.LoadConfig()
proposerWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), proposerWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), proposerWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("send funds to test wallet", func(t *testing.T) {
Expand Down Expand Up @@ -408,7 +408,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() {
chainAUpgradeProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

t.Run("upgrade chainA", func(t *testing.T) {
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

// see this issue https://github.com/informalsystems/hermes/issues/3579
Expand Down Expand Up @@ -505,7 +505,7 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() {

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) {
Expand Down Expand Up @@ -599,7 +599,7 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() {

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("update params", func(t *testing.T) {
Expand Down Expand Up @@ -706,7 +706,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() {
t.Run("upgrade chain", func(t *testing.T) {
testCfg := testsuite.LoadConfig()
proposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), proposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), proposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("29-fee migration partially refunds escrowed tokens", func(t *testing.T) {
Expand Down Expand Up @@ -837,7 +837,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade(

t.Run("chain A", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})
}()

Expand All @@ -847,7 +847,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade(

t.Run("chain B", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[1].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[1].Tag, testCfg.GetUpgradeConfig().Tag)
})
}()

Expand Down Expand Up @@ -1099,7 +1099,7 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade() {

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -1229,7 +1229,7 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade_Localhost() {

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("localhost does not exist in state after upgrade", func(t *testing.T) {
Expand Down Expand Up @@ -1335,7 +1335,7 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade_ICS20v2ChannelUpgrade() {

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("upgrade channel to ics20-2", func(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions e2e/tests/wasm/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"os"
"strings"
"testing"
"time"

Expand All @@ -35,8 +36,8 @@ const (

func TestIBCWasmUpgradeTestSuite(t *testing.T) {
testCfg := testsuite.LoadConfig()
if testCfg.UpgradeConfig.Tag == "" || testCfg.UpgradeConfig.PlanName == "" {
t.Fatalf("%s and %s must be set when running an upgrade test", testsuite.ChainUpgradeTagEnv, testsuite.ChainUpgradePlanEnv)
if strings.TrimSpace(testCfg.UpgradePlanName) == "" {
t.Fatalf("%s must be set when running an upgrade test", testsuite.ChainUpgradePlanEnv)
}

// wasm tests require a longer voting period to account for the time it takes to upload a contract.
Expand Down Expand Up @@ -70,7 +71,7 @@ func (s *IBCWasmUpgradeTestSuite) TestIBCWasmChainUpgrade() {

t.Run("upgrade chain", func(t *testing.T) {
testCfg := testsuite.LoadConfig()
s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), userWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), userWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag)
})

t.Run("query wasm checksums", func(t *testing.T) {
Expand Down
29 changes: 0 additions & 29 deletions e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ const (
RelayerIDEnv = "RELAYER_ID"
// ChainBinaryEnv binary is the binary that will be used for both chains.
ChainBinaryEnv = "CHAIN_BINARY"
// ChainUpgradeTagEnv specifies the upgrade version tag
ChainUpgradeTagEnv = "CHAIN_UPGRADE_TAG"
// ChainUpgradePlanEnv specifies the upgrade plan name
ChainUpgradePlanEnv = "CHAIN_UPGRADE_PLAN"
// E2EConfigFilePathEnv allows you to specify a custom path for the config file to be used. It can be relative
Expand Down Expand Up @@ -98,8 +96,6 @@ type TestConfig struct {
RelayerConfigs []relayer.Config `yaml:"relayers"`
// ActiveRelayer specifies the relayer that will be used. It must match the ID of one of the entries in RelayerConfigs.
ActiveRelayer string `yaml:"activeRelayer"`
// UpgradeConfig holds values used only for the upgrade tests.
UpgradeConfig UpgradeConfig `yaml:"upgrade"`
// CometBFTConfig holds values for configuring CometBFT.
CometBFTConfig CometBFTConfig `yaml:"cometbft"`
// DebugConfig holds configuration for miscellaneous options.
Expand Down Expand Up @@ -468,14 +464,6 @@ func applyEnvironmentVariableOverrides(fromFile TestConfig) TestConfig {
fromFile.ActiveRelayer = envTc.ActiveRelayer
}

if os.Getenv(ChainUpgradePlanEnv) != "" {
fromFile.UpgradePlanName = envTc.UpgradeConfig.PlanName
}

if os.Getenv(ChainUpgradeTagEnv) != "" {
fromFile.UpgradeConfig.Tag = envTc.UpgradeConfig.Tag
}

if isEnvTrue(KeepContainersEnv) {
fromFile.DebugConfig.KeepContainers = true
}
Expand Down Expand Up @@ -598,23 +586,6 @@ func getDefaultHyperspaceRelayerConfig() relayer.Config {
}
}

// getUpgradePlanConfigFromEnv returns the upgrade config from environment variables.
func getUpgradePlanConfigFromEnv() UpgradeConfig {
upgradeTag, ok := os.LookupEnv(ChainUpgradeTagEnv)
if !ok {
upgradeTag = ""
}

upgradePlan, ok := os.LookupEnv(ChainUpgradePlanEnv)
if !ok {
upgradePlan = ""
}
return UpgradeConfig{
PlanName: upgradePlan,
Tag: upgradeTag,
}
}

func GetChainATag() string {
return LoadConfig().ChainConfigs[0].Tag
}
Expand Down

0 comments on commit 223e5ad

Please sign in to comment.