From e84af23403a457f7d877b25e3632ea959d72028f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 27 Nov 2024 15:35:47 -0500 Subject: [PATCH] feat: override upgrade height delay for test chains --- app/test/upgrade_test.go | 2 +- pkg/appconsts/versioned_consts.go | 4 +++- pkg/appconsts/versioned_consts_test.go | 12 ++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/test/upgrade_test.go b/app/test/upgrade_test.go index e42449d747..e5ac7569ae 100644 --- a/app/test/upgrade_test.go +++ b/app/test/upgrade_test.go @@ -104,7 +104,6 @@ func TestAppUpgradeV3(t *testing.T) { require.NoError(t, err) require.Equal(t, v3.Version, getUpgradeResp.Upgrade.AppVersion) - // brace yourselfs, this part may take a while initialHeight := int64(4) for height := initialHeight; height < initialHeight+appconsts.UpgradeHeightDelay(testApp.GetChainID(), v2.Version); height++ { appVersion := v2.Version @@ -123,6 +122,7 @@ func TestAppUpgradeV3(t *testing.T) { require.Equal(t, appconsts.GetTimeoutPropose(appVersion), endBlockResp.Timeouts.TimeoutPropose) _ = testApp.Commit() + fmt.Printf("block height for v3 %v\n", height) } require.Equal(t, v3.Version, endBlockResp.ConsensusParamUpdates.Version.AppVersion) diff --git a/pkg/appconsts/versioned_consts.go b/pkg/appconsts/versioned_consts.go index 6034453598..73d635d010 100644 --- a/pkg/appconsts/versioned_consts.go +++ b/pkg/appconsts/versioned_consts.go @@ -87,6 +87,9 @@ func UpgradeHeightDelay(chainID string, v uint64) int64 { } return parsedValue } + if chainID == "test" { + return 3 + } switch v { case v1.Version: return v1.UpgradeHeightDelay @@ -100,6 +103,5 @@ func UpgradeHeightDelay(chainID string, v uint64) int64 { return v2.UpgradeHeightDelay default: return v3.UpgradeHeightDelay - } } diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go index 249dd99805..f85d05b163 100644 --- a/pkg/appconsts/versioned_consts_test.go +++ b/pkg/appconsts/versioned_consts_test.go @@ -118,6 +118,18 @@ func TestUpgradeHeightDelay(t *testing.T) { version: 3, expectedUpgradeHeightDelay: v3.UpgradeHeightDelay, }, + { + name: "the upgrade delay for chainID 'test' should be 3 regardless of the version", + chainID: "test", + version: 3, + expectedUpgradeHeightDelay: 3, + }, + { + name: "the upgrade delay for chainID 'test' should be 3 regardless of the version", + chainID: "test", + version: 4, + expectedUpgradeHeightDelay: 3, + }, } for _, tc := range tests {