Skip to content

test(execution): Allow for the server-time read's own delay in the Binance balance-stamp tests - #814

Merged
Niqnil merged 3 commits into
developfrom
fix/811-clock-stamp-test-bounds
Nov 1, 2026
Merged

Niqnil merged 3 commits into
developfrom
fix/811-clock-stamp-test-bounds

Conversation

@Niqnil

@Niqnil Niqnil commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Closes #811.

What

Three tests check that a Binance balance read is stamped on Binance's clock when this host's clock leads it by 60 s:

  • spot::tests::a_balance_read_is_stamped_on_binances_clock_when_the_host_clock_leads
  • margin::tests::a_cross_balance_read_is_stamped_on_binances_clock_when_the_host_clock_leads
  • margin::tests::an_isolated_balance_read_is_stamped_on_binances_clock_when_the_host_clock_leads

Their lower bound allowed only the 1 ms truncation of the server time. The estimate dates that server time to when its answer is received, so the delay between the read and that moment also puts the stamp behind. Under load it went about 5 µs past the bound and failed once.

Change

  • ServerTime::TRAILING_HOST_BEHIND (test-only, next to trailing_host): 1 ms + 50 ms, with the reasons in its rustdoc.
  • Both tests use it for the lower bound. The upper bound, which is what shows the stamp is not on this host's leading clock (it would be 60 s late), is unchanged.

Test-only; the stamping code and the CHANGELOG are untouched.

Checks

  • cargo test -p rustrade-execution --all-features --lib --tests: 1903 passed, 0 failed.
  • Pre-commit clippy clean.

…nance balance-stamp tests

The tests that check a balance read is stamped on Binance's clock bounded the stamp from below by
one millisecond, for the server time's truncation. The estimate also dates that server time to the
moment its answer is received, so any delay before then puts the stamp further behind; under load
it exceeded the millisecond. A shared test constant now allows 1 ms plus 50 ms, explained where it
is defined. The upper bound, which shows the stamp is not on this host's leading clock, is
unchanged.

Closes #811
…cond, and correct the allowance's rustdoc

- The margin balance-stamp test widens its lower bound only for a request signed on a server time
  read; on this host's clock it keeps the 1 ms bound it had.
- TRAILING_HOST_BEHIND's rustdoc names the delay as task scheduling and polling (not the read's
  timeout, which adds none), and mentions the clock's drift allowance.
@Niqnil
Niqnil merged commit 58bea79 into develop Nov 1, 2026
14 checks passed
@Niqnil
Niqnil deleted the fix/811-clock-stamp-test-bounds branch November 1, 2026 01:45
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.

1 participant