Skip to content

fix(cli): wait for deployed programs before running tests#4669

Open
raushan728 wants to merge 9 commits into
otter-sec:masterfrom
raushan728:fix/validator-program-readiness-check
Open

fix(cli): wait for deployed programs before running tests#4669
raushan728 wants to merge 9 commits into
otter-sec:masterfrom
raushan728:fix/validator-program-readiness-check

Conversation

@raushan728

@raushan728 raushan728 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #3624

anchor test was checking validator readiness by polling get_latest_blockhash(). This returns as soon as the RPC server accepts connections well before BPF programs are actually deployed on-chain. Tests would fire immediately after and hit "Program is not deployed".

startup_wait in Anchor.toml also had no real effect since the loop broke early regardless of the configured value.

Changes:

  • Extracted the readiness loop into wait_for_validator_ready()
  • Added a second check: polls get_multiple_accounts() until all deployed programs return an executable account
  • Program pubkeys are extracted from the --bpf-program / --upgradeable-program flags passed to the validator, so [programs.localnet] address overrides in Anchor.toml are respected correctly
  • Both checks share a single Instant-based timeout from startup_wait
  • Increased STARTUP_WAIT default from 5000ms to 30000ms to account for program deployment time on top of RPC liveness
  • ms_wait changed to u64 negative startup_wait values are now rejected with an error at the call site via u64::try_from
  • Updated error message to reflect actual failure reason

@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

@raushan728 is attempting to deploy a commit to the OtterSec Team on Vercel.

A member of the Team first needs to authorize it.

@raushan728 raushan728 marked this pull request as draft June 14, 2026 17:27
@raushan728 raushan728 force-pushed the fix/validator-program-readiness-check branch from fdfec08 to e9b31c9 Compare June 15, 2026 03:32
@raushan728 raushan728 marked this pull request as ready for review June 15, 2026 03:33
Comment thread cli/src/lib.rs Outdated
Comment thread cli/src/lib.rs Outdated

@0x4ka5h 0x4ka5h left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems like negative startup_wait values now turn into an effectively infinite wait in the new readiness helper.

0x4ka5h
0x4ka5h previously approved these changes Jun 16, 2026
@raushan728

This comment was marked as outdated.

@raushan728 raushan728 requested review from 0x4ka5h and jamie-osec June 16, 2026 09:29
Comment thread cli/src/lib.rs Outdated
Comment thread cli/src/lib.rs Outdated
@raushan728

This comment was marked as outdated.

@raushan728 raushan728 requested a review from jamie-osec June 23, 2026 09:21
0x4ka5h
0x4ka5h previously approved these changes Jun 23, 2026
Comment thread cli/src/lib.rs Outdated
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.

anchor test not wait for solana-test-validator

3 participants