Skip to content

test(twap-monitor): cover a removal arriving before its create - #672

Open
lgahdl wants to merge 1 commit into
nullislabs:mainfrom
bleu:test/twap-monitor-remove-before-create-self-heal
Open

test(twap-monitor): cover a removal arriving before its create#672
lgahdl wants to merge 1 commit into
nullislabs:mainfrom
bleu:test/twap-monitor-remove-before-create-self-heal

Conversation

@lgahdl

@lgahdl lgahdl commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

module.toml already documents the risk: the ConditionalOrderCreated and ConditionalOrderRemoved subscriptions "merge in arrival order, not chain order." The existing suite covers each half of that race separately:

  • removal_of_an_unindexed_watch_is_a_no_op proves a removal with no known create is silently dropped.
  • poll_invalid_drops_watch_and_gates proves the poll-drop self-heal path — but only for OrderNotValid, one of the five recognised legacy IConditionalOrder revert reasons.

Neither test chains the two together, and neither exercises the unrecognised-selector fallback path that SingleOrderNotAuthed() — the actual, parameterless custom error the deployed ComposableCow.sol reverts with for a removed order (require(singleOrders[owner][ctx], SingleOrderNotAuthed()); in _auth) — would take through LegacyRevertAdapter::classify.

What this adds

One test, removal_before_its_create_self_heals_via_the_first_poll, running the full sequence for real:

  1. A ConditionalOrderRemoved log for an unindexed watch → confirmed no-op (empty store).
  2. Its ConditionalOrderCreated log arrives after → confirmed the watch persists, with no memory of the earlier removal.
  3. An on_block dispatch where the mocked eth_call returns keccak256("SingleOrderNotAuthed()")[..4] as the revert data (the real selector, not a synthetic recognised one) → confirmed the watch is gone afterward and nothing was submitted to the venue.

No production code changes — this only adds coverage for a gap the module's own documentation already flags but the test suite didn't close.

Testing

cargo test --manifest-path modules/twap-monitor/Cargo.toml: 26/26 pass (25 pre-existing + the new one), no regressions.

AI Assistance: Claude Code was used for the investigation and this test, as part of a follow-up TWAP-flow red-team pass.

module.toml already documents the risk: the ConditionalOrderCreated and
ConditionalOrderRemoved subscriptions merge in arrival order, not chain
order. removal_of_an_unindexed_watch_is_a_no_op already proves a
removal with no known create is silently dropped, and
poll_invalid_drops_watch_and_gates already proves the poll-drop
self-heal path - but only for one of the five recognised legacy
IConditionalOrder revert reasons (OrderNotValid). Neither test chains
the two together, and neither exercises the unrecognised-selector
fallback path that SingleOrderNotAuthed() - the actual, parameterless
custom error the deployed ComposableCow.sol reverts with for a removed
order - would take through LegacyRevertAdapter::classify.

This test runs the full sequence for real: a removed log for an
unindexed watch (no-op), its create arriving after (watch persists with
no memory of the earlier removal), then an on_block dispatch where the
mocked eth_call returns keccak256("SingleOrderNotAuthed()")[..4] as the
revert data. Confirms the watch is gone afterward and nothing was
submitted to the venue.
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