Review report

bitcoin/bitcoin: PR #36800

1 suggestion

Optional improvements

Link

[suggestion] · 16-bit result-code test can pass without receiving its response

pcp_natpmp_result_code_16bit also passes if its expected request bytes become mismatched, because silent script failure produces the same NETWORK_ERROR as the intended response rejection.

Location: src/test/pcp_tests.cpp:613 (head).

Details and suggested fix

If this test's expected SEND bytes stop matching the generated request, PCPTestSock::Send calls FailScript(), which only moves the cursor to the script's end, and still returns the sent length. Wait then advances the clock without reporting a receive event. PCPRequestPortMap consequently returns NETWORK_ERROR without receiving the 0x0101 packet, satisfying both assertions. The current script does distinguish the old one-byte check, and other tests would catch a shared request-encoding regression; the gap is drift confined to this test's script. Add ASSERT_DEBUG_LOG("pcp: Response too small"); before the PCPRequestPortMap call while retaining the error assertion. The intended path emits that warning when the eight-byte response fails the corrected fallback comparison and reaches the PCP size check. DebugLogHelper also matches warning messages, so this assertion would detect the silent script-failure path. Asserting the timeout log alone would not distinguish them.


Coverage details