cli: Don't skip preflight when interacting with programs (#33426)
* cli: Don't skip preflight when closing a program * Don't skip preflight anywhere for program deploys, fix test
This commit is contained in:
parent
0b2beba357
commit
fa968da32e
|
@ -1175,7 +1175,6 @@ fn process_set_authority(
|
|||
&tx,
|
||||
config.commitment,
|
||||
RpcSendTransactionConfig {
|
||||
skip_preflight: true,
|
||||
preflight_commitment: Some(config.commitment.commitment),
|
||||
..RpcSendTransactionConfig::default()
|
||||
},
|
||||
|
@ -1226,7 +1225,6 @@ fn process_set_authority_checked(
|
|||
&tx,
|
||||
config.commitment,
|
||||
RpcSendTransactionConfig {
|
||||
skip_preflight: false,
|
||||
preflight_commitment: Some(config.commitment.commitment),
|
||||
..RpcSendTransactionConfig::default()
|
||||
},
|
||||
|
@ -1562,7 +1560,6 @@ fn close(
|
|||
&tx,
|
||||
config.commitment,
|
||||
RpcSendTransactionConfig {
|
||||
skip_preflight: true,
|
||||
preflight_commitment: Some(config.commitment.commitment),
|
||||
..RpcSendTransactionConfig::default()
|
||||
},
|
||||
|
@ -2232,7 +2229,6 @@ fn send_deploy_messages(
|
|||
&final_tx,
|
||||
config.commitment,
|
||||
RpcSendTransactionConfig {
|
||||
skip_preflight: true,
|
||||
preflight_commitment: Some(config.commitment.commitment),
|
||||
..RpcSendTransactionConfig::default()
|
||||
},
|
||||
|
|
|
@ -39,6 +39,17 @@ pub fn check_ready(rpc_client: &RpcClient) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn wait_n_slots(rpc_client: &RpcClient, n: u64) -> u64 {
|
||||
let slot = rpc_client.get_slot().unwrap();
|
||||
loop {
|
||||
sleep(Duration::from_millis(DEFAULT_MS_PER_SLOT));
|
||||
let new_slot = rpc_client.get_slot().unwrap();
|
||||
if new_slot - slot > n {
|
||||
return new_slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wait_for_next_epoch_plus_n_slots(rpc_client: &RpcClient, n: u64) -> (Epoch, u64) {
|
||||
let current_epoch = rpc_client.get_epoch_info().unwrap().epoch;
|
||||
let next_epoch = current_epoch + 1;
|
||||
|
@ -48,14 +59,8 @@ pub fn wait_for_next_epoch_plus_n_slots(rpc_client: &RpcClient, n: u64) -> (Epoc
|
|||
|
||||
let next_epoch = rpc_client.get_epoch_info().unwrap().epoch;
|
||||
if next_epoch > current_epoch {
|
||||
let slot = rpc_client.get_slot().unwrap();
|
||||
loop {
|
||||
sleep(Duration::from_millis(DEFAULT_MS_PER_SLOT));
|
||||
let new_slot = rpc_client.get_slot().unwrap();
|
||||
if new_slot - slot > n {
|
||||
let new_slot = wait_n_slots(rpc_client, n);
|
||||
return (next_epoch, new_slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use {
|
|||
solana_cli::{
|
||||
cli::{process_command, CliCommand, CliConfig},
|
||||
program::{ProgramCliCommand, CLOSE_PROGRAM_WARNING},
|
||||
test_utils::wait_n_slots,
|
||||
},
|
||||
solana_cli_output::OutputFormat,
|
||||
solana_faucet::faucet::run_local_faucet,
|
||||
|
@ -688,6 +689,9 @@ fn test_cli_program_close_program() {
|
|||
&bpf_loader_upgradeable::id(),
|
||||
);
|
||||
|
||||
// Wait one slot to avoid "Program was deployed in this block already" error
|
||||
wait_n_slots(&rpc_client, 1);
|
||||
|
||||
// Close program
|
||||
let close_account = rpc_client.get_account(&programdata_pubkey).unwrap();
|
||||
let programdata_lamports = close_account.lamports;
|
||||
|
|
Loading…
Reference in New Issue