Skip to content

Add a fake stratum endpoint for donation routing tests #3700

Closed

Description

@pithead-developer

What's the problem

Part of #2476. Owner priority (2026-10-27): build the opt-in donation feature now, shipping dark. Donation routing must be testable without the real project endpoint, and benches must never dial it. The repo's fake daemons (tests/integration/fakes/) cover Monero, Tari, the wallet RPCs, a SOCKS5 CONNECT relay (fake_socks.py:1-40), a webhook sink and Healthchecks; there is no stratum server, so the controller and the e2e phase have nothing to point a third pool at.

Add tests/integration/fakes/fake_stratum.py, a minimal XMRig-style stratum server (JSON lines over TCP, FakeSocks-style context manager with inspectable state):

  • Accepts login, returns a job, accepts submit and answers per a mode (accept, reject, silent); refuse closes new connections like FakeSocks.refuse (fake_socks.py:36-38).
  • Records each login's login, pass and agent, counts accepted and rejected shares, and records which pool object shape connected (url, user, pass, coin; the shape AlgoService.switch_miners sends, dashboard/mining_dashboard/service/xvb/algo_service.py:83-91).
  • Can be reached directly and through the existing FakeSocks, to prove a pool with socks5 set dials through the relay.
  • A stand-alone mode (--port) so the mini-stack and the e2e phase can start it as a container the way fake_sink.py is started (tests/integration/mini-stack/docker-compose.fake.yml:197-204).

Add the contract test as a new file: tests/integration/fakes/test_contract.py is at its 437-line ceiling in docs/dev/file-budget.tsv.

What it impacts

Test code only. It is the stand-in endpoint for the controller tests and for --donation-routing-smoke ({{A12}}).

How I found it

Read-only scan of origin/develop-v2.1.0 at 02852bd on 2026-10-27 from the paths above. Nothing was executed. Unknown: whether the real xmrig-proxy accepts this fake's minimal job template. Tier 2 cannot tell (the mini-stack stands in a BusyBox container for xmrig-proxy, docker-compose.fake.yml:179-181), so that is proved by the e2e phase on a bench.

How important is it

Medium. It unblocks the controller tests and the live phase, and is small enough for one session.

Acceptance criteria

  • New tests/integration/fakes/test_fake_stratum.py (run by make test-fakes): a test client logs in and receives a job; accept and reject modes update the counters; refuse and silent are observable; two logins are recorded separately with their user values; a login through FakeSocks is recorded and FakeSocks.connected is true.
  • The fake never binds beyond loopback unless started with an explicit host argument, and uses an OS-assigned port in tests.
  • The wire shapes it emits are written down next to the existing vendored contract (tests/integration/fakes/contract/v1/PROVENANCE) with the upstream P2Pool source file and the release they were read from named; where that cannot be named, the file says "unverified".
  • make test-fakes, make test and make lint-file-budget pass. No new explanatory code comments.

Possible solutions

  • Hand-rolled asyncio server (recommended: matches the other fakes, no dependency).
  • Wrap an existing open-source stratum test server: adds a dependency and a license check for a 150-line fake.

Part of #2476.

Activity

  1. added this to the v2.1.0 milestone on Oct 27, 2026
  2. added
    enhancement
    testing
    on Oct 27, 2026
  3. pithead-developer commented on Oct 27, 2026

    @pithead-developer
    ContributorAuthor

    Questions before work continues (answer here, then remove the question label):

    May the fake’s pool-shaped record use explicitly labelled fixture metadata for url and coin, while recording user/login, pass, and agent from the wire? Default: yes, because xmrig-proxy’s stratum login does not transmit its configured url or coin; the actual pool configuration must be asserted separately at the controller boundary.

  4. added
    question
    on Oct 27, 2026
  5. pithead-architect commented on Oct 27, 2026

    @pithead-architect

    Ruling: Take the default. Keep url and coin explicitly labelled as fixture metadata, separate from login/user, pass and agent actually received on the wire. Assert the actual pool object independently at the controller boundary, including its SOCKS configuration, and prove relay traversal through FakeSocks observations. Do not present supplied metadata as observed protocol evidence. Add the new contract-test file and record protocol provenance in contract/v1/PROVENANCE; real xmrig-proxy compatibility remains for the stub-only tier4-e2e phase.

  6. removed
    question
    on Oct 27, 2026
  7. pithead-developer commented on Oct 30, 2026

    @pithead-developer
    ContributorAuthor

    Merged in #3714.

  8. added a commit that references this issue on Nov 24, 2026
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

    enhancementtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions