-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCIP-2422] Streamlines Contract Version Checks (#1079)
## Motivation Version checks can get messy with lots of if statements or switch cases when gating a test or other function that should only be able to work with certain versions. Example: ```go if offRampVersion, exists := TestCfg.VersionInput[contracts.OffRampContract]; exists { require.NotEqual(t, offRampVersion, contracts.V1_2_0, "Provided OffRamp contract version '%s' is not supported for this test", offRampVersion) } else { require.FailNow(t, "OffRamp contract version not found in test config") } if onRampVersion, exists := TestCfg.VersionInput[contracts.OnRampContract]; exists { require.NotEqual(t, onRampVersion, contracts.V1_2_0, "Provided OnRamp contract version '%s' is not supported for this test", onRampVersion) } else { require.FailNow(t, "OnRamp contract version not found in test config") } // And on and on for all versions ``` ## Solution Utilize a general contract version checking function. The new checks look like this: ```go err := contracts.HaveRequiredContractVersions(map[contracts.Name]contracts.Version{ contracts.OffRampContract: contracts.V1_5_0_dev, contracts.OnRampContract: contracts.V1_5_0_dev, }) require.NoError(t, err, "Required contract versions not met") ``` This helps clean up [this PR ](#1030) immensely
- Loading branch information
Showing
6 changed files
with
152 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.