Skip to content

Add testutils pkg; use TimeFromUnix when building message publications#4878

Draft
johnsaigle wants to merge 4 commits into
wormhole-foundation:mainfrom
johnsaigle:feat-testutils-and-time-validation
Draft

Add testutils pkg; use TimeFromUnix when building message publications#4878
johnsaigle wants to merge 4 commits into
wormhole-foundation:mainfrom
johnsaigle:feat-testutils-and-time-validation

Conversation

@johnsaigle

@johnsaigle johnsaigle commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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).

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 johnsaigle force-pushed the feat-testutils-and-time-validation branch from e947e4c to f4f7456 Compare June 19, 2026 13:57
@johnsaigle johnsaigle marked this pull request as ready for review June 26, 2026 15:27
Comment thread node/pkg/watchers/sui/watcher.go
Comment thread node/pkg/watchers/algorand/watcher.go Outdated
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))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread node/pkg/watchers/aptos/watcher.go Outdated
}
timestamp, err := vaa.TimeFromUnix(ts.Uint())
if err != nil {
logger.Error("invalid timestamp", zap.Error(err), zap.Uint64("timestamp", ts.Uint()))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment thread node/pkg/watchers/evm/by_transaction.go Outdated
}
timestamp, err := vaa.TimeFromUnix(blockTime)
if err != nil {
return nil, 0, nil, fmt.Errorf("invalid block timestamp: %w", err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll rework these so that they're more actionable

Comment thread node/pkg/watchers/near/tx_processing.go Outdated
ts := outcomeBlockHeader.Timestamp
timestamp, err := vaa.TimeFromUnix(ts)
if err != nil {
return fmt.Errorf("invalid block timestamp: %w", err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment thread node/pkg/watchers/solana/shim.go Outdated
}
timestamp, err := vaa.TimeFromUnix(messageEvent.Timestamp)
if err != nil {
return fmt.Errorf("invalid shim message timestamp: %w", err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment thread node/pkg/watchers/sui/watcher.go
Comment thread node/pkg/watchers/sui/watcher.go Outdated
txHashEthFormat := eth_common.BytesToHash(txHashBytes)
timestamp, err := vaa.TimeFromUnix(msg.Timestamp)
if err != nil {
return fmt.Errorf("processEvent failed to parse timestamp: %w", err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@johnsaigle johnsaigle marked this pull request as draft July 8, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants