Update & improve coverage: add mapport tests#232
Draft
tevio wants to merge 3 commits intobitcoinknots:29.x-knotsfrom
Draft
Update & improve coverage: add mapport tests#232tevio wants to merge 3 commits intobitcoinknots:29.x-knotsfrom
tevio wants to merge 3 commits intobitcoinknots:29.x-knotsfrom
Conversation
1dd7ebd to
0ebd401
Compare
Ari4ka
approved these changes
Feb 15, 2026
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.
Improved Mapport Coverage
mapport: add hook-based seam for PCP/UPnP, expand unit tests, improve coverage; exclude seam header from coverage
Motivation / Context
mapportthread manages NAT traversal (PCP/NAT-PMP/UPnP) and historically had limited, flaky coverage because tests could trigger real network I/O and OS firewalls.mapportlifecycle and PCP control-flow without opening sockets, and a clean coverage report without noise from glue code.What’s changed
mapport_hookswith function-pointer variables that default to real implementations.mapport_hooks::QueryDefaultGatewayFnmapport_hooks::PCPRequestPortMapFnmapport_hooks::NATPMPRequestPortMapFnmapport_hooks::GetLocalAddressesFnsrc/mapport.cppnow invokes these hooks instead of calling the functions directly insideProcessPCP()and related logic. No behavior change in production: the hooks point to the real functions by default.mapport:StartMapPort,InterruptMapPort,StopMapPort), dispatch toggling, idempotent starts, and key branches inProcessPCP().BasicTestingSetupfixture for required global initialization.src/mapport_hooks.hfiltered incmake/script/CoverageInclude.cmake.in.--output-on-failureand explicitly ensuresmapport_testsexecute during coverage, so unit-test hits always contribute to the HTML reports.Before
After