refactor(testing): inline networking decode-failure dispatch - #1156
Merged
tcoratger merged 1 commit intoJun 18, 2026
Merged
Conversation
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>
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
Removes the module-level
_DECODERS_BY_NAMElookup 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 insideDecodeFailure.attempt_decode. With one consumer, the table earns nothing as a standalone symbol, so the dispatch now happens via amatchright where it is used — mirroring the same cleanup applied to the API endpoint fixture._DECODERS_BY_NAMEtable and its now-orphanedCallableandFinalimports.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/networkingbefore and after and confirmed the generated JSON is byte-identical (diff -rq), determinism check passing both ways.just checkpasses (ruff lint + format, ty, codespell, mdformat).