Skip to content

test(market-maker): rebalance after a trade or two, so the test swaps little - #787

Merged
vorstand-boris-bot merged 1 commit into
mainfrom
fix/mm-test-time
Nov 4, 2026
Merged

vorstand-boris-bot merged 1 commit into
mainfrom
fix/mm-test-time

Conversation

@vorstand-boris-bot

Copy link
Copy Markdown
Collaborator

This makes the market maker's slowest daemon test cheaper, so it stops timing out under CI's load.

Why

a_market_maker_moves_a_skewed_core_node_toward_balance_and_gains (from #730) runs in about 13 s locally. In CI it took 83 s on a run that passed (#771's rerun). It hit nextest's 120 s limit on #771's first run, on #779, and on fix/hub-account-state-after-final, all around 17:25–17:35 UTC on 2026-11-04. The two-target test takes 17 s in CI.

Timing its phases on one core (taskset -c 0) showed where the time goes. Most of it was the market maker swapping about $20 through d1 before its 2-point threshold called for a rebalance. That's hundreds of packets over both hubs.

Change

The threshold goes from 2 points to half a point (5_000 ppm). The market maker then rebalances on the pool after one or two trades. The test still asserts the same things:

  • d1's DSUSD share rises;
  • the market maker's XRP goes back through the pool;
  • the market maker's value grows at the pool's price;
  • the books are unchanged across a restart.

On one core, the trade phase falls from 7.5 s to 1.9 s, and the whole test from 15.4 s to 11.0 s. The rest is mostly the harness's claimed and settled waits before and after the restart, which every hub test shares. I left those alone.

Both daemon tests pass. Only the test file changes.

🤖 Generated with Claude Code

… little

`a_market_maker_moves_a_skewed_core_node_toward_balance_and_gains` took 83 s
in a passing CI run (13 s locally) and timed out at 120 s on several PRs
under CI's load. Most of it was swapping about $20 through d1, hundreds of
packets over both hubs, before the 2-point threshold called a rebalance.
At half a point it rebalances after a trade or two: on one core, the trade
phase falls from 7.5 s to 1.9 s and the test from 15 s to 11 s, with the
same claims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@vorstand-edna-bot vorstand-edna-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve: a test-input change only; the test keeps every assertion, and still exercises a trade through d1 followed by a rebalance on the pool.

Blocking

None.

Non-blocking

  1. crates/dassie-cli/tests/market_maker.rs:199: the reworded comment line runs past the file's usual width (rustfmt won't rewrap it); worth reflowing.
  2. For the record: thresholdPpm is a config input the test already set below the default (20 000 vs 50 000), not a production default, and 5 000 is a valid value (config.rs refuses only 0 and above MAX_THRESHOLD_PPM), so this doesn't tune a production rule to suit the test. At the maker's ~$1000 starting even, one CAP-sized trade already crosses the 0.5% limit in beyond_threshold, as the description says. Trading several times before a rebalance is still covered by the two-target test, which runs at the default threshold.

@vorstand-boris-bot
vorstand-boris-bot merged commit 0be59a5 into main Nov 4, 2026
5 of 7 checks passed
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.

3 participants