Skip to content

Commit

Permalink
test: add unit test for versioned upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes committed Oct 24, 2024
1 parent fd4b108 commit c9b257e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkg/appconsts/versioned_consts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,50 @@ func TestVersionedConsts(t *testing.T) {
})
}
}

func TestUpgradeHeightDelay(t *testing.T) {
tests := []struct {
name string
chainID string
version uint64
expectedUpgradeHeightDelay int64
}{
{
name: "v1 upgrade delay",
chainID: "test-chain",
version: v1.Version,
expectedUpgradeHeightDelay: v1.UpgradeHeightDelay,
},
{
name: "v1 arabica upgrade delay",
chainID: "arabica-11",
version: v1.Version,
expectedUpgradeHeightDelay: v1.UpgradeHeightDelay,
},
{
name: "v2 upgrade delay on non-arabica chain",
chainID: "celestia",
version: v2.Version,
expectedUpgradeHeightDelay: v2.UpgradeHeightDelay,
},
{
name: "v2 upgrade delay on arabica",
chainID: "arabica-11",
version: v2.Version,
expectedUpgradeHeightDelay: v3.UpgradeHeightDelay, // falls back to v3 because of arabica bug
},
{
name: "v3 upgrade delay",
chainID: "mocha-4",
version: 3,
expectedUpgradeHeightDelay: v3.UpgradeHeightDelay,
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
actual := appconsts.UpgradeHeightDelay(tc.chainID, tc.version)
require.Equal(t, tc.expectedUpgradeHeightDelay, actual)
})
}
}

0 comments on commit c9b257e

Please sign in to comment.