Skip to content

test: end-to-end hybrid transport tests: Python hybrid peer, misbehaving peers, fallback, whole suite with PQ on (#184 part 7) #212

Closed

Description

@djh58

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, because authenticate_handshake returns only the bytes consumed and success.
  • test/functional/test_framework/v2_p2p.py:221 asserts that the node's version contents are empty.

Scope

  • v2_p2p.py. Hybrid support in both roles, opt-in per peer through supports_v2_pq (named after supports_v2_p2p), using crypto/mlkem.py (B2) and the recipe in crypto/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-95 sends 5 random bytes of version contents and expects the connection to survive.
  • test/functional/rpc_net.py:148 compares getpeerinfo as an exact dict.

Scope

  • Framework flag --v2pqtransport, which implies --v2transport: every node gets -v2pqtransport=1, but only nodes whose version knows the option (B1). --v1transport clears both flags. Plain --v2transport passes -v2pqtransport=0 explicitly, 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.py takes transport_pq and transport_pq_status from the run mode;
    • p2p_v2_misbehaving.py redraws random contents only when they fully parse as an own record, and gains a deterministic 04 f0 00 00 00 disconnect case under PQ-on;
    • any other test that assumed empty contents from a node.
  • CI. A pq-functional job in ci-pq.yml runs 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-functional with --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

  1. added
    enhancement
    pq-transport
    on Oct 5, 2026
  2. changed the title [-]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)[/+] on Oct 5, 2026
  3. 9 remaining items

  4. djh58 commented on Oct 23, 2026

    @djh58
    MemberAuthor

    Done in #239, merged into feature/pq-transport as 8586855. It reaches 1.1.0 with #233 and ships in 1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpq-transport

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions