Skip to content

Commit

Permalink
CCIP-3008 CCIP versioning which is semver compatible (#14177)
Browse files Browse the repository at this point in the history
* CCIP versioning which is semver compatible

* Drop suffixes to avoid misleading people

* Update core/services/versioning/orm_test.go

Co-authored-by: Ryan Stout <rstout610@gmail.com>

---------

Co-authored-by: Ryan Stout <rstout610@gmail.com>
  • Loading branch information
mateusz-sekara and rstout authored Aug 21, 2024
1 parent d204c46 commit d7645dd
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions core/services/versioning/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,87 @@ func Test_Version_CheckVersion(t *testing.T) {
assert.Equal(t, "9.9.8", dbv.String())
}

func TestORM_CheckVersion_CCIP(t *testing.T) {
ctx := testutils.Context(t)
db := pgtest.NewSqlxDB(t)

lggr := logger.TestLogger(t)

orm := NewORM(db, lggr)

tests := []struct {
name string
currentVersion string
newVersion string
expectedError bool
}{
{
name: "ccip patch version bump from 0 -> 2",
currentVersion: "2.5.0-ccip1.4.0",
newVersion: "2.5.0-ccip1.4.2",
expectedError: false,
},
{
name: "ccip patch downgrade errors",
currentVersion: "2.5.0-ccip1.4.2",
newVersion: "2.5.0-ccip1.4.1",
expectedError: true,
},
{
name: "ccip patch version bump from 2 -> 10",
currentVersion: "2.5.0-ccip1.4.2",
newVersion: "2.5.0-ccip1.4.10",
expectedError: false,
},
{
name: "ccip patch version bump from 9 -> 101",
currentVersion: "2.5.0-ccip1.4.9",
newVersion: "2.5.0-ccip1.4.101",
expectedError: false,
},
{
name: "upgrading only core version",
currentVersion: "2.5.0-ccip1.4.10",
newVersion: "2.6.0-ccip1.4.10",
expectedError: false,
},
{
name: "downgrading only core version errors",
currentVersion: "2.6.0-ccip1.4.10",
newVersion: "2.5.0-ccip1.4.10",
expectedError: true,
},
{
name: "upgrading both core and ccip version",
currentVersion: "2.5.0-ccip1.4.10",
newVersion: "2.6.0-ccip1.4.11",
expectedError: false,
},
{
name: "upgrading both core and ccip version but minor version",
currentVersion: "2.5.0-ccip1.4.10",
newVersion: "2.6.0-ccip1.5.0",
expectedError: false,
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
_, err := db.ExecContext(ctx, `TRUNCATE node_versions;`)
require.NoError(t, err)

require.NoError(t, orm.UpsertNodeVersion(ctx, NewNodeVersion(test.currentVersion)))
_, _, err = CheckVersion(ctx, db, lggr, test.newVersion)
if test.expectedError {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})

}
}

func TestORM_NodeVersion_FindLatestNodeVersion(t *testing.T) {
ctx := testutils.Context(t)
db := pgtest.NewSqlxDB(t)
Expand Down

0 comments on commit d7645dd

Please sign in to comment.