Skip to content

Commit

Permalink
Attempt at test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tstirrat15 committed Sep 12, 2024
1 parent 54cba16 commit b1fc26d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/datastore/postgres/postgres_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,10 @@ func StrictReadModeTest(t *testing.T, ds datastore.Datastore) {
// Perform a read at a manually constructed revision beyond head, which should fail.
badRev := postgresRevision{
snapshot: pgSnapshot{
xmax: 9999999999999999999,
// NOTE: the struct defines this value as uint64, but the underlying
// revision is defined as an int64, so we run into an overflow issue
// if we try and use a big uint64.
xmax: math.MaxInt64,

Check failure on line 1471 in internal/datastore/postgres/postgres_shared_test.go

View workflow job for this annotation

GitHub Actions / Datastore Tests (postgres)

undefined: math

Check failure on line 1471 in internal/datastore/postgres/postgres_shared_test.go

View workflow job for this annotation

GitHub Actions / Datastore Tests (pgbouncer)

undefined: math
},
}

Expand Down
9 changes: 7 additions & 2 deletions internal/datastore/postgres/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,19 @@ func parseRevisionProto(revisionStr string) (datastore.Revision, error) {

xminInt, err := safecast.ToInt64(decoded.Xmin)
if err != nil {
return datastore.NoRevision, spiceerrors.MustBugf("Could not cast xmin to int64")
return datastore.NoRevision, spiceerrors.MustBugf("could not cast xmin to int64")
}

var xips []uint64
if len(decoded.RelativeXips) > 0 {
xips = make([]uint64, len(decoded.RelativeXips))
for i, relativeXip := range decoded.RelativeXips {
xips[i] = uint64(xminInt + relativeXip)
xip := xminInt + relativeXip
uintXip, err := safecast.ToUint64(xip)
if err != nil {
return datastore.NoRevision, spiceerrors.MustBugf("could not cast xip to int64")
}
xips[i] = uintXip
}
}

Expand Down

0 comments on commit b1fc26d

Please sign in to comment.