Skip to content

test(networking): add codec test vectors for varint, gossip topics, and message IDs#608

Merged
tcoratger merged 1 commit intoleanEthereum:mainfrom
tcoratger:test/networking-codec-test-vectors
Apr 14, 2026
Merged

test(networking): add codec test vectors for varint, gossip topics, and message IDs#608
tcoratger merged 1 commit intoleanEthereum:mainfrom
tcoratger:test/networking-codec-test-vectors

Conversation

@tcoratger
Copy link
Copy Markdown
Collaborator

Summary

  • New NetworkingCodecTest fixture: extensible fixture class for networking wire-format conformance testing, using a codec_name discriminator to dispatch to codec-specific handlers
  • 15 varint (LEB128) test vectors: boundary values from 0 through 2^64-1, covering every byte-width transition
  • 8 gossip topic string test vectors: block, aggregation, and attestation subnet topics with fork digest edge cases (zero, max, typical)
  • 8 gossip message ID test vectors: valid/invalid snappy domains, empty inputs, and domain differentiation to verify SHA256-based 20-byte ID computation

These are the first networking-layer test vectors. The fixture infrastructure is extensible — adding gossipsub RPC encoding, discovery v5 codecs, or ENR encoding in future PRs only requires a new codec_name handler and test file.

Test plan

  • uvx tox -e all-checks passes (ruff, format, ty, codespell, mdformat)
  • uv run fill --fork=devnet --clean -n auto -- tests/consensus/devnet/networking/ generates all 30 fixtures
  • uv run fill --fork=devnet --clean -n auto generates all 253 fixtures (no regressions)
  • Verified JSON output contains codecName, input, and computed output fields
  • Verified varint 300 encodes to 0xac02 (matches protobuf reference)

🤖 Generated with Claude Code

…nd message IDs

Introduces a NetworkingCodecTest fixture that generates JSON test vectors
for networking wire-format codecs. Client teams can consume these to
validate their implementations against the reference encoding.

Three codecs are covered in this first phase:

- Varint (LEB128): 15 vectors covering single-byte through 10-byte (2^64-1)
  boundary values
- Gossip topic strings: 8 vectors covering block, aggregation, and attestation
  subnet topics with fork digest edge cases
- Gossip message ID: 8 vectors covering valid/invalid snappy domains, empty
  inputs, and domain differentiation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger requested review from unnawut and removed request for unnawut April 14, 2026 18:24
@tcoratger tcoratger merged commit 10177d7 into leanEthereum:main Apr 14, 2026
13 checks passed
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