-
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.
cherry-pick - feat: Add support for parsing deployed 1.0 contracts wh…
…ich have no TypeAndVersion(#1368) (#1369) ## Motivation - 1.0.0 contracts have no TypeAndVersion however tooling validation expects a TypeAndVersion be set ## Solution - Return `Unknown 1.0.0` for contracts with an empty type and version string, implying that they are 1.0.0 deployed contracts ## Motivation ## Solution Co-authored-by: Peter Olds <[email protected]>
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 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
49 changes: 49 additions & 0 deletions
49
core/services/ocr2/plugins/ccip/config/type_and_version_test.go
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseTypeAndVersion(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
expectedType string | ||
expectedVersion string | ||
expectedError string | ||
}{ | ||
{ | ||
name: "Valid input", | ||
input: string(EVM2EVMOnRamp) + " 1.2.0", | ||
expectedType: string(EVM2EVMOnRamp), | ||
expectedVersion: "1.2.0", | ||
}, | ||
{ | ||
name: "Empty input", | ||
input: "", | ||
expectedType: string(Unknown), | ||
expectedVersion: defaultVersion, | ||
}, | ||
{ | ||
name: "Invalid input", | ||
input: "InvalidInput", | ||
expectedError: "invalid type and version InvalidInput", | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
actualType, actualVersion, err := ParseTypeAndVersion(tc.input) | ||
|
||
if tc.expectedError != "" { | ||
assert.EqualError(t, err, tc.expectedError) | ||
} else { | ||
assert.NoError(t, err) | ||
assert.Equal(t, tc.expectedType, actualType) | ||
assert.Equal(t, tc.expectedVersion, actualVersion) | ||
} | ||
}) | ||
} | ||
} |