Repository navigation
Description
Part 7 of 9 · #184 · Size L · Base 1.x.x · Needs part 2 (#186), part 5 (#206), part 6 (#209) · Unblocks part 9 (#222)
Consolidates work items G1 (#212), G2 (#213) and G3 (#214), each formerly its own sub-issue. Their full text is below as sections; the closed issues point here.
Goal
Whole-node tests: an opt-in hybrid Python v2 peer with end-to-end negotiation tests, misbehaving-peer and fallback tests, and the entire functional suite run with hybrid transport on in CI.
Work items
In suggested commit order. Each item is a section below.
- G1 · test: add an opt-in hybrid Python v2 peer and end-to-end functional tests
- G2 · test: functional tests for malformed negotiation, key confirmation and fallback
- G3 · test: run the whole functional suite with hybrid transport on
Starting early
- G1's Python hybrid peer can be built once part 4's recipe exists; the tests that assert RPC fields need part 6.
G1 · test: add an opt-in hybrid Python v2 peer and end-to-end functional tests
Needs F6 (#209).
Goal
A hybrid-capable Python v2 peer in the test framework, built on the independent references from B2 (#186) and E1 (#199), plus the end-to-end functional tests that need it.
Context
test/functional/test_framework/p2p.py:252: the v2 handshake driver can't send bytes produced while authenticating, becauseauthenticate_handshakereturns only the bytes consumed and success.test/functional/test_framework/v2_p2p.py:221asserts that the node's version contents are empty.
Scope
v2_p2p.py. Hybrid support in both roles, opt-in per peer throughsupports_v2_pq(named aftersupports_v2_p2p), usingcrypto/mlkem.py(B2) and the recipe incrypto/bip324_cipher.py(E1). Replace the unconditional empty-contents assertion with an explicit expectation:- ordinary legacy Python peers accept a non-empty offer and answer with empty contents;
- tests of switch-off behavior still assert empty contents.
p2p.py. Extend the driver's return contract with pending outbound bytes. Mark the handshake complete only after confirmation, and let a test peer withhold its confirmation.- New
test/functional/p2p_v2_pq.py:
| Test | Setup | Expect |
|---|---|---|
test_node_roles |
Two upgraded nodes, both connection directions | Both hybrid; matching session ids; more than 224 pings each way after the switch |
test_python_roles |
Python hybrid peer as initiator and as responder | Python and C++ agree; the node uses production entropy |
test_legacy_and_switches |
Legacy Python peers, v1 peers, each on/off combination | hybrid, legacy_peer, off and v1 as expected per role and setting |
test_pending_confirmation |
A Python peer withholds its confirmation | pending with an empty session id; hybrid only after it sends the confirmation |
Acceptance criteria
- The tests pass, and the rest of the functional suite is unchanged.
Suggested commit: test: add an opt-in hybrid v2 Python peer.
G2 · test: functional tests for malformed negotiation, key confirmation and fallback
Needs G1, F3 (#206).
Goal
Whole-node tests of every way a negotiation can go wrong, and of the fallback that follows repeated failures.
Scope
test/functional/p2p_v2_pq_misbehaving.py:
| Test | Setup | Expect |
|---|---|---|
test_records |
Each grammar and semantic case: EK and CT ±1 byte; bad-modulus EK; a duplicate own record (the first wins); unparseable contents; an own record followed by junk; len = 0; non-canonical and oversized CompactSize; an unknown header; contents near MAX_CONTENTS_LEN; truncated packets |
Connection kept or dropped as specified; exact reason in the log; exact per-direction counter delta |
test_confirmation |
Nonzero length, bad tag, non-decoy, corrupted CT | Immediate disconnect; the test never waits for -peertimeout |
test_decoys_and_partial_writes |
Decoys before the version; confirmation then decoys; coalesced and fragmented writes | Right key epoch and AAD use; connection kept |
test_unsolicited_accept |
Own-header bytes sent to a responder that made no offer | No decapsulation and no switch |
test/functional/p2p_v2_pq_fallback.py:
| Test | Setup | Expect |
|---|---|---|
test_three_failures |
Node A with -test=pq_fail_first_packet; three explicit outbound attempts to B |
Three counted failures; outbound fallback = 1; the fourth connection is plain v2 with status fallback; one warning line |
test_malformed_offer_fallback |
A Python responder that always sends a malformed own record | The fourth connection succeeds, because fallback neither parses nor validates the offer |
test_inbound_and_success_exclusion |
Repeated inbound failures; separately, an earlier outbound success | Neither enables fallback |
test_expiry_and_restart |
Advance mock time past expiry; reconnect; restart | PQ is tried again after expiry; restart clears the state and changes instance_id |
test_endpoint_separation |
A SOCKS test server with two names; one IP with two ports | Separate history and fallback entries |
addconnection can't open MANUAL connections (src/rpc/net.cpp:528), so use addnode … onetry for explicit outbound attempts. Check exact log text with assert_debug_log.
Acceptance criteria
- The tests pass, and none depends on a timeout firing.
Suggested commit: test: cover malformed negotiation, confirmation and fallback end to end.
G3 · test: run the whole functional suite with hybrid transport on
Needs F6 (#209), C1 (#186), B1 (#186).
Goal
Every existing functional test also runs with hybrid transport on, in CI, so the feature can't quietly break unrelated behavior.
Context
- The framework flag
--v2transport(test_framework.py:267) runs every test over v2. One job uses it (ci/test/00_setup_env_i686_no_ipc.sh:20). Without it, every node starts with-v2transport=0(test_node.py:189-194). test/functional/p2p_v2_misbehaving.py:92-95sends 5 random bytes of version contents and expects the connection to survive.test/functional/rpc_net.py:148comparesgetpeerinfoas an exact dict.
Scope
- Framework flag
--v2pqtransport, which implies--v2transport: every node gets-v2pqtransport=1, but only nodes whose version knows the option (B1).--v1transportclears both flags. Plain--v2transportpasses-v2pqtransport=0explicitly, so after R1 (release: hybrid v2 transport release gate and default-on (#184 part 9) #222) flips the default, the i686 job still covers plain v2. - Framework Python peers stay legacy in this mode, so the suite pays no pure-Python ML-KEM cost. Links between nodes do go hybrid.
- Adapt existing tests (their expectations, never node behavior):
rpc_net.pytakestransport_pqandtransport_pq_statusfrom the run mode;p2p_v2_misbehaving.pyredraws random contents only when they fully parse as an own record, and gains a deterministic04 f0 00 00 00disconnect case under PQ-on;- any other test that assumed empty contents from a node.
- CI. A
pq-functionaljob inci-pq.ymlruns the whole suite with--v2pqtransport, nightly through C4 (test, ci: foundations: qbit release tooling, Python ML-KEM-1024, v1.0.0 interop, PQ CI workflow, canary tools (#184 part 2) #186) and by named dispatch on PR branches. The i686 env passes PQ=0 explicitly.
Acceptance criteria
- The whole suite passes in
pq-functionalwith--v2pqtransport, and still passes without it. - The i686 job still passes and covers plain v2.
Suggested commit: test: exercise hybrid transport across the functional suite.
One pull request against 1.x.x closes this issue. The shared contract is the Design section of #184; change it there first if needed.
Activity
[-]test: add an opt-in hybrid Python v2 peer and end-to-end functional tests (#184 G1)[/-][+]test: end-to-end hybrid transport tests: Python hybrid peer, misbehaving peers, fallback, whole suite with PQ on (#184 part 7)[/+]test: add an opt-in hybrid v2 Python peer
test: cover malformed negotiation, confirmation and fallback end to end
test: add an opt-in hybrid v2 Python peer
9 remaining items
test: add an opt-in hybrid v2 Python peer
test: add test options for deterministic load shedding
test: cover malformed negotiation, confirmation and fallback end to end
test: exercise hybrid transport across the functional suite
test: damage the key confirmation itself in the v2 peer's unit test
test: add an opt-in hybrid v2 Python peer
test: add test options for deterministic load shedding
test: cover malformed negotiation, confirmation and fallback end to end
test: exercise hybrid transport across the functional suite
test: damage the key confirmation itself in the v2 peer's unit test
net: turn hybrid v2 transport on by default
net: turn hybrid v2 transport on by default
net: turn hybrid v2 transport on by default (#241)
djh58 commentedon Oct 23, 2026
Done in #239, merged into
feature/pq-transportas 8586855. It reaches1.1.0with #233 and ships in 1.1.0.