Skip to content

node(near): Add unit tests for processWormholeLog validation - #5107

Draft
johnsaigle wants to merge 1 commit into
wormhole-foundation:mainfrom
johnsaigle:node/near-processwormholelog-tests
Draft

johnsaigle wants to merge 1 commit into
wormhole-foundation:mainfrom
johnsaigle:node/near-processwormholelog-tests

Conversation

@johnsaigle

@johnsaigle johnsaigle commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add TestProcessWormholeLog, a table test for the checks in processWormholeLog. Each case starts from a valid Wormhole publish event and changes one field. For each case, the test checks the error result and job.hasWormholeMsg. For a rejected or skipped log, it also checks that no MessagePublication goes to msgC.

The valid case checks all fields of the published message.

Why

This PR mainly fixes the node-coverage-check failure on #5106. That PR sets the baseline for node/pkg/watchers/near to 76.9%, but the package coverage is 75.1% in CI and locally. The difference is more than the 1.0% tolerance, so the check fails each time it runs. With this test, the package coverage is 79.9%, which is above the new baseline.

As a secondary benefit, the test increases overall coverage. It also tests security checks that had no direct test. The existing watcher tests reach these checks only through mock RPC fixtures. Before this PR, if a change removed one of the checks, no test failed.

Testing

  • go test -race -cover ./pkg/watchers/near/ passes.
  • I disabled the block height check and the emitter length check in tx_processing.go. The related test cases failed. Then I restored the file.

Notes

  • The len(pl)*2 != len(pubEvent.Data) check is not reachable, because hex.DecodeString rejects data with an odd length first. The "odd length" case tests the decode error.
  • processOutcome has similar checks with no direct tests. A follow-up PR can add them.

Add a table test for the checks in processWormholeLog. Each case changes
one field of a valid publish event. The test checks the error result and
that no MessagePublication goes to msgC.

The existing watcher tests reach these checks only through mock RPC
fixtures. Thus, a removed check does not cause a test failure.

Package coverage increases from 75.1% to 79.9%.

This branch has not been deployed

No deployments
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.

1 participant