Skip to content

TestValidator checks usability of programs added to genesis during startup#6587

Merged
tao-stones merged 3 commits intoanza-xyz:masterfrom
tao-stones:test-validator-harden-genesis-program-deployment
Jun 17, 2025
Merged

TestValidator checks usability of programs added to genesis during startup#6587
tao-stones merged 3 commits intoanza-xyz:masterfrom
tao-stones:test-validator-harden-genesis-program-deployment

Conversation

@tao-stones
Copy link
Copy Markdown

Problem

  • programs added to TestValidator's genesis isn't immediately usable. Runtime needs time to mark the program as "deployed";
  • TestValidator has a hack during startup to wait for fee stabilizes.
  • During this wait period, programs in TestValidator genesis usually will become ready for use; But this isn't always reliable, sometime cause test to fail due to "Program is not deployed":
Waiting for fees to stabilize 1...

thread 'main' panicked at clients/cli/tests/command.rs:278:14:
called `Result::unwrap()` on an `Err` value: Error { request: Some(SendTransaction), kind: RpcError(RpcResponseError { code: -32002, message: "Transaction simulation failed: Error processing Instruction 0: Unsupported program id", data: SendTransactionPreflightFailure(RpcSimulateTransactionResult { err: Some(InstructionError(0, UnsupportedProgramId)), logs: Some(["Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb invoke [1]", "Program is not deployed", "Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb failed: Unsupported program id"]), accounts: None, units_consumed: Some(0), return_data: None, inner_instructions: None, replacement_blockhash: None }) }) }

Summary of Changes

Actively check for "Program is not deployed", wait till program becomes usable.

Fixes #

@tao-stones tao-stones force-pushed the test-validator-harden-genesis-program-deployment branch from 446b7f0 to 81c2dbb Compare June 13, 2025 23:16
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 14, 2025

Codecov Report

Attention: Patch coverage is 90.43478% with 11 lines in your changes missing coverage. Please review.

Project coverage is 82.8%. Comparing base (ccdcdbe) to head (9ea07b5).
Report is 14 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #6587    +/-   ##
========================================
  Coverage    82.8%    82.8%            
========================================
  Files         849      849            
  Lines      379032   379147   +115     
========================================
+ Hits       313911   314116   +205     
+ Misses      65121    65031    -90     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread test-validator/src/lib.rs
rpc_client.get_health().await.expect("health");
}

#[test]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Add tests to assert program added to genesis is available for use after TestValidator started.

To illustrate issue, if short circuit wait_for_nonzero_fee() by returning immediately (to simulate removing the hack) and disable wait_for_upgradeable_programs_deployed() (to simulate no change), these two tests will fail.

Comment thread test-validator/src/lib.rs Outdated
blockhash,
);
match rpc_client.send_transaction(&transaction).await {
Ok(_) => println!("{:?} - OK", program_id),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

better to use the normal log functions.

Comment thread test-validator/src/lib.rs Outdated
loop {
let blockhash = rpc_client.get_latest_blockhash().await.unwrap();
let mut all_deployed = true;
for program_id in upgradeable_programs {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the program_id has been successful in previous iterations, we don't have to resend

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

9ea07b5 has it

Copy link
Copy Markdown

@lijunwangs lijunwangs left a comment

Choose a reason for hiding this comment

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

LGTM

@tao-stones tao-stones merged commit 236cca0 into anza-xyz:master Jun 17, 2025
39 checks passed
@tao-stones tao-stones deleted the test-validator-harden-genesis-program-deployment branch June 17, 2025 14:40
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.

3 participants