Skip to content

Add e2e tests for withdrawal cancellation#461

Open
Bridgerz wants to merge 2 commits intomainfrom
e2e-cancel-withdrawal
Open

Add e2e tests for withdrawal cancellation#461
Bridgerz wants to merge 2 commits intomainfrom
e2e-cancel-withdrawal

Conversation

@Bridgerz
Copy link
Copy Markdown
Contributor

Summary

Adds e2e coverage for the withdrawal cancellation flow, including the race boundary between cancel and the leader's commit phase.

Commits

  1. Add e2e tests for withdrawal cancellation. Two scenarios:

    • test_cancel_withdrawal_before_approval: shuts down 2 of 4 nodes to starve quorum, so the request stays in Requested. Cancels and verifies hBTC is restored.
    • test_cancel_approved_withdrawal: uses a 1-hour batching delay to keep the approved request from being committed to a WithdrawalTransaction. Cancels from the approved state and verifies hBTC is restored.
  2. Add localnet withdrawal-processing flag and cancel-race e2e tests. Adds a hidden --disable-withdrawal-processing flag on hashi-localnet start that gates the leader's approval/commit phases. Plus two tests covering the cancel-vs-commit race:

    • test_cancel_race_cancel_wins: cancel lands first; the leader's commit tx must fail and hBTC must be restored.
    • test_cancel_race_commit_wins: commit lands first; cancel must abort with ECannotCancelProcessingWithdrawal and hBTC stays burned.

    These reuse the 1-hour withdrawal_batching_delay_ms trick to freeze Phase 2, then drive the commit PTB directly via a new Hashi::build_and_sign_withdrawal_commitment helper that factors out the quorum fan-out shared with the leader loop.

Test plan

  • cargo test -p e2e-tests -- test_cancel_withdrawal_before_approval --ignored
  • cargo test -p e2e-tests -- test_cancel_approved_withdrawal --ignored
  • cargo test -p e2e-tests -- test_cancel_race_cancel_wins --ignored
  • cargo test -p e2e-tests -- test_cancel_race_commit_wins --ignored

Two test scenarios:

1. test_cancel_withdrawal_before_approval: Shuts down 2 of 4 nodes to
   prevent quorum, creates a withdrawal request that stays in Requested
   state, cancels it, and verifies hBTC balance is restored.

2. test_cancel_approved_withdrawal: Uses a 1-hour batching delay so
   approved requests are not committed to a WithdrawalTransaction.
   Creates a request, waits for committee approval, cancels the
   approved request, and verifies hBTC balance is restored.
Adds a hidden `--disable-withdrawal-processing` flag to `hashi-localnet
start` that gates the leader's approval and commit phases, so withdrawal
requests stay in Requested/Approved state for manual cancellation
testing. The flag is hidden from --help so validators don't enable it
curiously; it's test/debug only.

Also adds two e2e tests covering the cancel-vs-commit race boundary:
- test_cancel_race_cancel_wins: cancel lands before commit; commit tx
  must fail and hBTC must be restored.
- test_cancel_race_commit_wins: commit lands before cancel; cancel must
  abort with ECannotCancelProcessingWithdrawal and hBTC stays burned.

The tests reuse the existing 1-hour `withdrawal_batching_delay_ms` trick
to freeze the leader's Phase 2 and drive the commit PTB directly via a
new `Hashi::build_and_sign_withdrawal_commitment` helper that factors
out the quorum fan-out shared with the leader loop.
@Bridgerz Bridgerz requested a review from bmwill as a code owner April 16, 2026 21:08
@bmwill
Copy link
Copy Markdown
Contributor

bmwill commented Apr 18, 2026

How necessary is this full e2e test over writing a move unit test for these semantics?

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.

2 participants