Add testutils pkg; use TimeFromUnix when building message publications#4878
Open
johnsaigle wants to merge 4 commits into
Open
Add testutils pkg; use TimeFromUnix when building message publications#4878johnsaigle wants to merge 4 commits into
johnsaigle wants to merge 4 commits into
Conversation
johnsaigle
force-pushed
the
feat-testutils-and-time-validation
branch
from
June 19, 2026 13:57
e947e4c to
f4f7456
Compare
johnsaigle
marked this pull request as ready for review
June 26, 2026 15:27
johnsaigle
requested review from
SEJeff,
bemic,
djb15,
evan-gray,
kcsongor,
mdulin2,
panoel and
pleasew8t
as code owners
June 26, 2026 15:27
djb15
reviewed
Jul 2, 2026
djb15
reviewed
Jul 3, 2026
| for _, obs := range observations { | ||
| timestamp, err := vaa.TimeFromUnix(b.TimeStamp) | ||
| if err != nil { | ||
| logger.Error("invalid block timestamp", zap.Error(err), zap.Int64("timestamp", b.TimeStamp)) |
Collaborator
There was a problem hiding this comment.
I know not all of the existing error messages are great, but it would be nice if we could add more information about a transaction here to aid in debugging if this ever occured
| } | ||
| timestamp, err := vaa.TimeFromUnix(ts.Uint()) | ||
| if err != nil { | ||
| logger.Error("invalid timestamp", zap.Error(err), zap.Uint64("timestamp", ts.Uint())) |
| } | ||
| timestamp, err := vaa.TimeFromUnix(blockTime) | ||
| if err != nil { | ||
| return nil, 0, nil, fmt.Errorf("invalid block timestamp: %w", err) |
Contributor
Author
There was a problem hiding this comment.
Sounds good, I'll rework these so that they're more actionable
| ts := outcomeBlockHeader.Timestamp | ||
| timestamp, err := vaa.TimeFromUnix(ts) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid block timestamp: %w", err) |
| } | ||
| timestamp, err := vaa.TimeFromUnix(messageEvent.Timestamp) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid shim message timestamp: %w", err) |
| txHashEthFormat := eth_common.BytesToHash(txHashBytes) | ||
| timestamp, err := vaa.TimeFromUnix(msg.Timestamp) | ||
| if err != nil { | ||
| return fmt.Errorf("processEvent failed to parse timestamp: %w", err) |
johnsaigle
marked this pull request as draft
July 8, 2026 14:17
Use the SDK's new timestamp validation function at all call sites, including in test code. In order to make tests a big more ergonomic, a helper test function was added in a new testutils/ package. Going forward, we can move shared test helpers into this package rather than re-implementing functions that are needed by many tests (e.g. building and validating Message Publications).
johnsaigle
force-pushed
the
feat-testutils-and-time-validation
branch
from
July 22, 2026 12:42
3b0f537 to
b977b42
Compare
johnsaigle
marked this pull request as ready for review
July 22, 2026 15:01
Contributor
Author
|
@djb15 could you re-review? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the SDK's new TimeFromUnix timestamp validation function at all call sites, including in test code.
This normalizes timestamp validation to avoid niche overflow scenarios as well as divergences between various types used to represent timestamps in the Go code. It adds an error-handling step but it also makes it so that authors don't need to know the implementation details of how a timestamp is represented. It also allows us to avoid linter warnings by resolving them correctly instead of muting them at every site where a Message Publication is built.
In order to make tests a bit more ergonomic, a
helper test function was added in a new testutils/ package. Going
forward, we can move shared test helpers into this package rather than
re-implementing functions that are needed by many tests (e.g. building
and validating Message Publications).