Skip to content

test: Add large-scale network tests (50 and 200 peers) for topology, subscriptions, and seeding #2176

@sanity

Description

@sanity

Problem

Current test coverage focuses on small networks (2-3 peers). The recent #2164 refactor series (PRs #2167-2172) changes core routing and connection handling, but we lack tests that verify behavior at scale.

What Needs Testing

  1. Network Topology Formation

    • Peers should form a mesh topology, not a star (all connected to gateway only)
    • Each peer should have multiple connections (min_connections target)
    • Connection acquisition should complete in reasonable time
  2. Subscription Tree Formation

    • When multiple peers subscribe to a contract, proper tree structure should form
    • Updates should propagate through the tree efficiently
    • Unsubscribe should prune branches correctly
  3. Seeding Mechanism

    • Contract state should be retrievable from any peer in the network
    • Put operations should seed to appropriate locations
    • Get operations should find seeded state
  4. NAT Traversal at Scale

    • Multiple NAT peers should successfully join
    • Peers behind NAT should be reachable for subscriptions
    • Connection handoff between peers should work

Current Best Test

The 6-peer River message flow test with Docker NAT simulation (docker-nat-sim work) is our most comprehensive test. We should expand on this pattern.

Proposed Tests

Phase 1: 50-Peer Network

  1. Topology Health Test

    • Start 50-peer network, wait for stabilization
    • Verify each peer has >= min_connections
    • Verify no star topology (peers connected to more than just gateway)
    • Measure time to reach stable state
  2. Subscription Propagation Test

    • Put contract at one peer
    • Subscribe from ~20 peers at different network locations
    • Update contract and verify all subscribers receive update
    • Measure propagation latency
  3. Seeding Distribution Test

    • Put contracts targeting different ring locations
    • Verify state is retrievable from peers that didn't originate the put
    • Test get from peers far from contract location

Phase 2: 200-Peer Network

  1. Scale Topology Test

    • Verify topology formation at 200 peers
    • Measure connection acquisition time distribution
    • Identify bottlenecks
  2. Subscription Tree Depth Test

    • With 200 peers, subscription trees should have meaningful depth
    • Verify update propagation through deep trees
    • Test branch pruning behavior
  3. Mixed NAT Network Test (100 public, 100 NAT peers)

    • Verify NAT peers can subscribe and receive updates
    • Verify operations route correctly through NAT peers

Implementation Notes

  • Use freenet_test macro framework or standalone harness
  • May need Docker/container orchestration for 200 peers
  • Should run as separate CI job (not blocking normal CI)
  • Consider metrics collection for performance analysis

Related

[AI-assisted - Claude]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-developer-xpArea: developer experienceA-networkingArea: Networking, ring protocol, peer discoveryE-hardExperience needed to fix/implement: Hard / a lotP-highHigh priorityT-featureType: New functionality request

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions