Skip to content

fix: deflake //rs/dogecoin/ckdoge/minter:integration_tests#10346

Draft
gregorydemay wants to merge 4 commits into
masterfrom
ai/deflake-should-resubmit-transaction-2026-05-29
Draft

fix: deflake //rs/dogecoin/ckdoge/minter:integration_tests#10346
gregorydemay wants to merge 4 commits into
masterfrom
ai/deflake-should-resubmit-transaction-2026-05-29

Conversation

@gregorydemay
Copy link
Copy Markdown
Contributor

Purpose

The ckDOGE withdrawal integration tests (should_resubmit_transaction and should_resubmit_transaction_when_many_utxos) are flaky: they intermittently fail with a withdrawal-fee mismatch between the estimate_withdrawal_fee query and the fee in the SentDogeTransaction event (e.g. dogecoin_fee: 1 vs 376000000).

Root cause

estimate_withdrawal_fee reflects the minter's last refreshed median fee percentiles. That value starts at the initialization default and is only updated once the minter's periodic refresh task runs successfully after the dogecoin canister is synced. The withdrawal flow captures the estimate before the withdrawal's own submission refreshes the median, so on the first withdrawal of a setup the estimate races the refresh — passing when a refresh already landed, failing otherwise.

Fix

Add a mandatory minter_await_fee_refresh step at the start of the withdrawal flow that drives the fee-percentile refresh and waits until the estimate stabilizes, before the withdrawal request is submitted (kept before submission so it cannot trigger an early transaction). The flow's type-state makes the step impossible to skip for any caller reaching expect_withdrawal_request_accepted.

This PR was created following the steps in .claude/skills/fix-flaky-tests/SKILL.md.

The ckDOGE withdrawal flow asserts that the fee returned by the
`estimate_withdrawal_fee` query equals the fee used in the transaction
that the minter actually submits. The query reflects the last refreshed
median fee percentiles, which the minter only updates once its periodic
refresh task runs after the dogecoin canister is synced. The estimate
was therefore captured while the median was still the initialization
default, racing the refresh and producing a fee mismatch only on the
first withdrawal of a setup.

Introduce a mandatory `minter_await_fee_refresh` step at the start of
the withdrawal flow that drives the refresh and waits until the fee
estimate stabilizes before the withdrawal request is submitted. The
type-state makes the step impossible to skip for any caller reaching
`expect_withdrawal_request_accepted`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to deflake ckDOGE withdrawal integration tests by ensuring the minter’s fee-percentile refresh runs (and the fee estimate stabilizes) before submitting the first withdrawal request, avoiding a race between estimate_withdrawal_fee and the minter’s periodic refresh.

Changes:

  • Introduces a mandatory minter_await_fee_refresh step in the withdrawal flow type-state.
  • Adds a shared refresh interval constant to drive the periodic fee-percentiles refresh in PocketIC time.
  • Updates ckDOGE minter integration tests to use the new mandatory flow step.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
rs/dogecoin/ckdoge/test_utils/src/lib.rs Adds a constant used to advance PocketIC time past the minter’s refresh cadence.
rs/dogecoin/ckdoge/test_utils/src/flow/withdrawal.rs Adds a new withdrawal-flow step that advances time/ticks until fee estimates stabilize.
rs/dogecoin/ckdoge/minter/tests/tests.rs Updates integration tests to call the new mandatory fee-refresh step before approval/retrieval.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rs/dogecoin/ckdoge/test_utils/src/flow/withdrawal.rs Outdated
gregorydemay and others added 3 commits May 29, 2026 11:49
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The standalone fee-estimation test does not go through the withdrawal
flow and was hitting the same stale median fee percentiles. Move the
refresh helper onto MinterCanister so both the withdrawal flow and the
estimation test can warm up the fee state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses review feedback: comparing fee estimates cannot distinguish an
already-fresh estimate from one whose refresh has not yet succeeded, so a
stale estimate could slip through. Wait until the minter logs a successful
`estimate_fee_per_vbyte` refresh, and fail loudly if none occurs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants