Skip to content

[pipeline] No automated tests cover pipeline logic — live soak with zero borrowers exercises no code paths #177

@obchain

Description

@obchain

Refs #42

PR: feat(cli): wire scanner → router → builder → simulator pipeline (feat/17-cli-e2e-pipeline)
Commit: latest on feat/17-cli-e2e-pipeline
File: crates/charon-cli/src/ (no test module), crates/charon-executor/src/ (no test module)

PRD clause: CLAUDE.md: 'Before any commit: run the gates locally — cargo test --workspace.' Live soak is not a substitute for automated tests.

Problem:

The PR's test evidence is: 'Live soak: 21 pipeline ticks in 25s, zero borrowers, zero panics.' With zero borrowers, the pipeline runs:

  • fetch_positions(&[]) — returns empty vec
  • scanner.upsert([]) — no-op
  • No liquidatable positions — inner loop body never executes

These code paths have zero test coverage:

  1. No-signer branch (BOT_SIGNER_KEY absent): is opportunity enqueued or dropped?
  2. Simulation failure branch: does Err from simulate() drop the opportunity or enqueue it?
  3. Profit threshold gate: is the filter applied before or after enqueue?
  4. min_amount_out arithmetic: is the repay+fee formula correct for all token decimals?
  5. get_liquidation_params failure: does it skip the position or abort the tick?

The three p0-blocker scenarios (broken profit calc, empty params, unsimulated enqueue) are not caught by any test.

Impact: Pipeline branching logic is entirely untested. Logic errors in the drop-vs-enqueue decision surface only at mainnet.

Fix: Add unit tests using mock adapter, mock router, and mock simulator (trait objects). Required test cases:

  • Happy path: profitable opportunity, sim passes, enqueued.
  • Sim failure: opportunity, sim returns Err, not enqueued.
  • No-signer: BOT_SIGNER_KEY absent, not enqueued.
  • Below threshold: profit < min_profit, not enqueued.
  • Adapter failure: fetch_positions returns Err, tick logged as warn, pipeline continues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scopestatus:readyScoped and ready to pick uptype:testTests, fuzz, fork, integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions