From 0de0a6a27ffcd52f082ec12fd8c335ca22fa666a Mon Sep 17 00:00:00 2001 From: Joel Smith Date: Wed, 21 Aug 2024 14:39:58 -0500 Subject: [PATCH 1/2] feat: add env variable to force SDK version --- chain/cosmos/chain_node.go | 23 +++++++++++++++++++++++ docs/envOptions.md | 7 ++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/chain/cosmos/chain_node.go b/chain/cosmos/chain_node.go index 54085596a..17ddc8c0d 100644 --- a/chain/cosmos/chain_node.go +++ b/chain/cosmos/chain_node.go @@ -722,6 +722,29 @@ func (tn *ChainNode) RecoverKey(ctx context.Context, keyName, mnemonic string) e } func (tn *ChainNode) IsAboveSDK47(ctx context.Context) bool { + // Check container environment variables for the SDK version. + if tn.Chain.Config().Env != nil { + for _, str := range tn.Chain.Config().Env { + if strings.Contains(str, "ICT_ABOVE_SDK_47") { + if strings.Contains(str, "true") { + return true + } else { + return false + } + } + } + } + + // Check OS environment variables for the SDK version. + env := os.Getenv("ICT_ABOVE_SDK_47") + if env != "" { + if env == "true" { + return true + } else { + return false + } + } + // In SDK v47, a new genesis core command was added. This spec has many state breaking features // so we use this to switch between new and legacy SDK logic. // https://github.com/cosmos/cosmos-sdk/pull/14149 diff --git a/docs/envOptions.md b/docs/envOptions.md index 7790eaf7e..cb248644e 100644 --- a/docs/envOptions.md +++ b/docs/envOptions.md @@ -12,4 +12,9 @@ - `CONTAINER_LOG_TAIL`: Specifies the number of lines to display from container logs. Defaults to 50 lines. -- `ICS_SPAWN_TIME_WAIT`: A go duration (e.g. 2m) that specifies how long to wait for ICS chains to spawn \ No newline at end of file +- `ICS_SPAWN_TIME_WAIT`: A go duration (e.g. 2m) that specifies how long to wait for ICS chains to spawn + +- `ICT_ABOVE_SDK_47`: (Set via `os.Setenv` or within the IBC Chain Config) + + - Set to `"true"` to run tests that require SDK version 0.47.0 or higher. + - Set to `"false"` to run tests that require SDK version 0.46.0 or lower. \ No newline at end of file From aa920e7612f92caa92afcbc18680cf8ac8df84f8 Mon Sep 17 00:00:00 2001 From: Joel Smith Date: Wed, 21 Aug 2024 14:48:03 -0500 Subject: [PATCH 2/2] Make better --- chain/cosmos/chain_node.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/chain/cosmos/chain_node.go b/chain/cosmos/chain_node.go index 17ddc8c0d..09de1e3c3 100644 --- a/chain/cosmos/chain_node.go +++ b/chain/cosmos/chain_node.go @@ -726,11 +726,7 @@ func (tn *ChainNode) IsAboveSDK47(ctx context.Context) bool { if tn.Chain.Config().Env != nil { for _, str := range tn.Chain.Config().Env { if strings.Contains(str, "ICT_ABOVE_SDK_47") { - if strings.Contains(str, "true") { - return true - } else { - return false - } + return strings.Contains(str, "true") } } } @@ -738,11 +734,7 @@ func (tn *ChainNode) IsAboveSDK47(ctx context.Context) bool { // Check OS environment variables for the SDK version. env := os.Getenv("ICT_ABOVE_SDK_47") if env != "" { - if env == "true" { - return true - } else { - return false - } + return env == "true" } // In SDK v47, a new genesis core command was added. This spec has many state breaking features