Repository navigation
node(near): Add unit tests for processWormholeLog validation - #5107
Draft
johnsaigle wants to merge 1 commit into
Draft
johnsaigle wants to merge 1 commit into
johnsaigle wants to merge 1 commit into
Conversation
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
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.
Summary
Add
TestProcessWormholeLog, a table test for the checks inprocessWormholeLog. Each case starts from a valid Wormhole publish event and changes one field. For each case, the test checks the error result andjob.hasWormholeMsg. For a rejected or skipped log, it also checks that noMessagePublicationgoes tomsgC.The valid case checks all fields of the published message.
Why
This PR mainly fixes the
node-coverage-checkfailure on #5106. That PR sets the baseline fornode/pkg/watchers/nearto 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.tx_processing.go. The related test cases failed. Then I restored the file.Notes
len(pl)*2 != len(pubEvent.Data)check is not reachable, becausehex.DecodeStringrejects data with an odd length first. The "odd length" case tests the decode error.processOutcomehas similar checks with no direct tests. A follow-up PR can add them.