Skip to content

test(rewards): add soak and concurrency stress test for double-spend detection - #102

Open
Ranjeet2063 wants to merge 1 commit into
ecotask-network:mainfrom
Ranjeet2063:test/reward-concurrency-soak-82
Open

Ranjeet2063 wants to merge 1 commit into
ecotask-network:mainfrom
Ranjeet2063:test/reward-concurrency-soak-82

Conversation

@Ranjeet2063

@Ranjeet2063 Ranjeet2063 commented Oct 28, 2026 •

Copy link
Copy Markdown

Problem

Without a comprehensive load/soak stress test, the proof approval and reward payout pipeline cannot be systematically verified against race conditions, process crashes, or network dropouts that could risk duplicate on-chain Stellar transactions or duplicate RewardPayout records (#82).

Solution

This PR adds a dedicated soak and concurrency stress testing suite to tests/integration/proof-to-reward.test.ts with controllable failure injections and automated invariant query verification:

  1. High-Throughput Concurrency Simulation:

    • Hammers the payout pipeline with 50+ concurrent proof approvals across competing parallel worker claims.
    • Verifies atomic claim semantics where exactly one worker proceeds and racing claims no-op cleanly.
  2. Controllable Failure Injections:

    • Worker Crash Mid-Payout: Simulates unhandled worker death while rows are in PROCESSING state, verifying that the sweeper recovers stale rows without duplicating transactions upon retry.
    • Transient Network Timeout: Simulates Stellar RPC dropouts triggering exponential backoff retries with idempotency preserved.
  3. Automated Invariant Queries:

    • Query 1: Exactly zero duplicate on-chain transactions per proofId across all injected failures (duplicateOnChainPayments.length === 0).
    • Query 2: Exactly zero duplicate PAID status rows in RewardPayout table (duplicatePaidRows.length === 0).
    • Query 3: Zero orphaned PROCESSING rows remaining after sweep and drainage.
    • Query 4: Total token amount conservation (sum(paid amounts) === sum(approved proof reward amounts)).

Verification

  • npx jest tests/integration/proof-to-reward.test.ts: 5/5 tests passed 100% green.
  • npx eslint tests/integration/proof-to-reward.test.ts: 0 errors, 0 warnings.
  • npx prettier --check tests/integration/proof-to-reward.test.ts: 100% compliant.

Closes #82

…detection

Implements comprehensive soak and concurrency stress testing for proof approval
and reward payout pipeline under concurrent worker races and failure injections.

- Simulates 50+ concurrent proof approvals with competing workers claiming outbox rows.
- Injects controllable failures: worker termination/crashes mid-payout and transient network drops.
- Asserts global invariants via automated query verification:
  1. Zero duplicate on-chain Stellar transactions per proofId.
  2. Zero duplicate PAID rows in RewardPayout table.
  3. Zero orphaned PROCESSING rows after sweeper drain.
  4. Exact token amount conservation (sum of payouts == sum of approved rewards).

Closes ecotask-network#82
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a soak/concurrency test for the reward-payout + verification pipeline (double-spend detection)

2 participants