Skip to content

test(entry): cover signature-share validation and message type#4196

Open
piotr-roslaniec wants to merge 1 commit into
mainfrom
test/beacon-entry-validation
Open

test(entry): cover signature-share validation and message type#4196
piotr-roslaniec wants to merge 1 commit into
mainfrom
test/beacon-entry-validation

Conversation

@piotr-roslaniec

@piotr-roslaniec piotr-roslaniec commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

What

pkg/beacon/entry previously had only marshaling round-trip tests (~14% coverage). This adds unit tests for the logic that can be exercised without a live broadcast channel or relay chain, raising coverage to ~27%.

Covered:

  • extractAndValidateShare — the gatekeeper that accepts or rejects a signature share received from another group member. A member that accepted a bad share would contribute to a corrupt relay entry, so all three rejection paths (unparseable share bytes, unknown sender, share that does not verify) are tested alongside the accept path, built on real bls sign/verify.
  • SignatureShareMessage value object (NewSignatureShareMessage, SenderID) and its wire Type identifier, which must stay stable for cross-client network compatibility.
  • Unmarshal rejecting a member index that overflows the uint8 range (the documented uint8/uint32 wire invariant).

Not covered (by design)

SignAndSubmit (the signing orchestration loop), broadcastShare, completeSignature, and relay entry submission drive a broadcast channel and the beacon chain. Those are exercised by the beacon integration tests, not unit tests; forcing unit-level mocks there would be brittle and low-value.

Verification

go test ./pkg/beacon/entry/ passes; gofmt -l, go vet, and staticcheck -SA1019 clean.

Summary by CodeRabbit

  • Tests
    • Added coverage for validating signature shares, including malformed, missing, and invalid signatures.
    • Added coverage for signature share message creation, type identification, and rejection of overflowing sender identifiers.

pkg/beacon/entry had only marshaling round-trip tests (~14% coverage).
Add unit tests for the logic that can be exercised without a live
broadcast channel or relay chain:

- extractAndValidateShare, the gatekeeper that accepts or rejects a
  signature share received from another group member - all three
  rejection paths (unparseable share, unknown sender, share that does
  not verify) plus the accept path, built on real BLS sign/verify.
- The SignatureShareMessage value object (constructor, SenderID) and
  its wire Type identifier, which must stay stable for cross-client
  network compatibility.
- Unmarshal rejecting a member index that overflows the uint8 range.

Raises package coverage from ~14% to ~27%. The remaining uncovered code
(SignAndSubmit orchestration, relay entry submission) drives a broadcast
channel and the beacon chain and is exercised by integration tests.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4788bb93-c914-41eb-9d26-08e5608e2fb4

📥 Commits

Reviewing files that changed from the base of the PR and between 5245f66 and c5bb3c5.

📒 Files selected for processing (2)
  • pkg/beacon/entry/entry_test.go
  • pkg/beacon/entry/message_test.go

📝 Walkthrough

Walkthrough

Added unit tests covering signature share validation and SignatureShareMessage construction, type identification, and overflow handling.

Changes

Beacon entry tests

Layer / File(s) Summary
Signature share validation tests
pkg/beacon/entry/entry_test.go
Tests valid, malformed, missing-key, and cryptographically invalid signature shares.
Signature share message tests
pkg/beacon/entry/message_test.go
Tests message construction, the wire type identifier, and rejection of overflowing sender IDs.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: new tests for signature-share validation and message type.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/beacon-entry-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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