Skip to content

[v0.2.0] Audit and replace any remaining time.Sleep in tests #68

Description

@neverDefined

Problem

time.Sleep in tests is a flake source. The shared-anvil pattern already avoids it for the main flow, but there may be stragglers (especially around concurrency and mempool waits).

Proposal

  1. git grep 'time\.Sleep' -- '*_test.go' and audit each hit.
  2. Replace each with one of:
    • WaitForBlock / WaitForMemPoolEmpty (poll loops with a deadline)
    • A t.Context()-aware select on a channel
    • require.Eventually (testify) for "X is true within Y"
  3. Where a small delay is actually needed (e.g. between two impersonate calls), document why with a comment.

Acceptance criteria

  • git grep 'time\.Sleep' -- '*_test.go' is empty, or every remaining hit has a // reason: comment.
  • go test -race -count=10 ./... passes (10× catches flakes).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:testsTest coverage, benchmarks, error pathstype:choreHousekeeping, no user-visible change

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions