Skip to content

Commit

Permalink
feat: override upgrade height delay for test chains
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Nov 27, 2024
1 parent 593fc86 commit e84af23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion pkg/appconsts/versioned_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,6 +103,5 @@ func UpgradeHeightDelay(chainID string, v uint64) int64 {
return v2.UpgradeHeightDelay
default:
return v3.UpgradeHeightDelay

}
}
12 changes: 12 additions & 0 deletions pkg/appconsts/versioned_consts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e84af23

Please sign in to comment.