Skip to content

refactor(testing): inline networking decode-failure dispatch - #1156

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor-networking-codec-decoder-dispatch
Jun 18, 2026
Merged

refactor(testing): inline networking decode-failure dispatch#1156
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor-networking-codec-decoder-dispatch

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Summary

Removes the module-level _DECODERS_BY_NAME lookup table in the networking codec fixture and folds the dispatch into its single consumer.

The table mapped seven decoder names to already-imported callables (decode_varint, RPC.decode, ENR.from_rlp, …) and was only ever read inside DecodeFailure.attempt_decode. With one consumer, the table earns nothing as a standalone symbol, so the dispatch now happens via a match right where it is used — mirroring the same cleanup applied to the API endpoint fixture.

  • Delete the _DECODERS_BY_NAME table and its now-orphaned Callable and Final imports.
  • Dispatch by structural pattern matching on the decoder discriminator.
  • Keep the hex decode inside the try, so malformed-hex input is still caught and reported as the rejection (behavior preserved exactly).

Verification

Pure structural refactor — no change to emitted vectors. Filled tests/consensus/lstar/networking before and after and confirmed the generated JSON is byte-identical (diff -rq), determinism check passing both ways. just check passes (ruff lint + format, ty, codespell, mdformat).

Replace the module-level decoder lookup table with a match in its sole
consumer. The table mapped seven names to already-imported decoder
callables and was only ever read by the decode-failure attempt, so the
dispatch now lives where it is used.

- Delete the _DECODERS_BY_NAME table and its now-orphaned Callable and
  Final imports.
- Dispatch by structural pattern matching on the decoder discriminator.
- Keep the hex decode inside the try, so malformed-hex input is still
  caught and reported as the rejection.

Pure structural refactor: emitted vectors are byte-identical (verified by
filling tests/consensus/lstar/networking before and after).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tcoratger
tcoratger merged commit 1ef93a9 into leanEthereum:main Jun 18, 2026
14 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