1 suggestion
Optional improvements
[suggestion] · Split-read fixes lack deterministic regression coverage
The functional tests do not force the receive boundaries and empty-garbage state needed to distinguish these fixes, so detecting regressions depends on incidental socket chunking.
Location: test/functional/test_framework/v2_p2p.py:141 (head).
Details and suggested fix
The existing split-send case, EARLY_KEY_RESPONSE, exercises bitcoind's responder, not the Python responder. Successful negotiation and expected-disconnection checks do not guarantee that the Python parser receives an incomplete key or header. Add deterministic parser-level cases that assert:
- A magic-matching prefix split across
BytesIOcalls makesrespond_v2_handshake()report only each call's consumed bytes. - A responder with forced empty garbage sends its key only once when the peer key arrives in pieces.
- A non-magic v1 header is retained through byte 23 and rejected at byte 24.
WrongGarbageTerminatorState.complete_handshake()returns(0, b"")for an incomplete key, rather than attempting the bit flip.
Use direct data_received() calls with initialized connection state and captured sends for the connection-level cases. Splitting socket writes alone cannot guarantee receive boundaries because TCP may coalesce them. Register new unit tests in TEST_FRAMEWORK_MODULES; v2_p2p currently has no entry.