HomePhabricator

test: Add mockable steady clock, tests for PCP and NATPMP implementations

Description

test: Add mockable steady clock, tests for PCP and NATPMP implementations

Summary:
The first commit was applied to D19759 (*net: Add optional length checking to CService::SetSockAddr*)

util: Add mockable steady_clock

This adds a NodeSteadyClock, which is a steady_clock that can be mocked
with millisecond precision.

net: Use mockable steady clock in PCP implementation

This will be needed for the test harness.

test: Add tests for PCP and NATPMP implementations

Add a mock for a simple scriptable UDP server, and use this to test
various code paths (including successful mappings, timeouts and errors)
in the PCP and NATPMP implementations.

qa: cover PROTOCOL_ERROR variant in PCP unit tests

This concludes backport of core#31022
Depends on D19760

Test Plan: ninja check

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D19761

Details

Provenance
laanwj <126646+laanwj@users.noreply.github.com>Authored on Oct 1 2024, 14:28
PiRKCommitted on Apr 1 2026, 18:35
PiRKPushed on Apr 1 2026, 18:35
Reviewer
Restricted Project
Differential Revision
D19761: test: Add mockable steady clock, tests for PCP and NATPMP implementations
Parents
rABC90911dd747d7: net: Replace libnatpmp with built-in PCP+NATPMP implementation
Branches
Unknown
Tags
Unknown