Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Removes ignored test: test_program_sbf_test_use_latest_executor2().
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Jan 13, 2023
1 parent 5be89ce commit a21378d
Showing 1 changed file with 0 additions and 104 deletions.
104 changes: 0 additions & 104 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1666,110 +1666,6 @@ fn test_program_sbf_test_use_latest_executor() {
.is_ok());
}

#[ignore] // Invoking SBF loaders from CPI not allowed
#[test]
#[cfg(feature = "sbf_rust")]
fn test_program_sbf_test_use_latest_executor2() {
solana_logger::setup();

let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_genesis_config(50);
let mut bank = Bank::new_for_tests(&genesis_config);
let (name, id, entrypoint) = solana_bpf_loader_program!();
bank.add_builtin(&name, &id, entrypoint);
let bank_client = BankClient::new(bank);
let invoke_and_error = create_deprecated_program(
&bank_client,
&bpf_loader::id(),
&mint_keypair,
"solana_sbf_rust_invoke_and_error",
);
let invoke_and_ok = create_deprecated_program(
&bank_client,
&bpf_loader::id(),
&mint_keypair,
"solana_sbf_rust_invoke_and_ok",
);

// Write the panic program into the program account
let (program_keypair, mut instruction) = load_and_finalize_deprecated_program(
&bank_client,
&bpf_loader::id(),
None,
&mint_keypair,
"solana_sbf_rust_panic",
);

// - invoke finalize and return error, swallow error
instruction.accounts.insert(
0,
AccountMeta {
is_signer: false,
is_writable: false,
pubkey: instruction.program_id,
},
);
instruction.program_id = invoke_and_ok;
instruction.accounts.insert(
0,
AccountMeta {
is_signer: false,
is_writable: false,
pubkey: invoke_and_error,
},
);
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
assert!(bank_client
.send_and_confirm_message(&[&mint_keypair, &program_keypair], message)
.is_ok());

// invoke program, verify not found
let message = Message::new(
&[Instruction::new_with_bytes(
program_keypair.pubkey(),
&[0],
vec![],
)],
Some(&mint_keypair.pubkey()),
);
assert_eq!(
bank_client
.send_and_confirm_message(&[&mint_keypair], message)
.unwrap_err()
.unwrap(),
TransactionError::InvalidProgramForExecution
);

// Write the noop program into the same program account
let (program_keypair, instruction) = load_and_finalize_deprecated_program(
&bank_client,
&bpf_loader::id(),
Some(program_keypair),
&mint_keypair,
"solana_sbf_rust_noop",
);
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
bank_client
.send_and_confirm_message(&[&mint_keypair, &program_keypair], message)
.unwrap();

// Call the program, should get noop, not panic
let message = Message::new(
&[Instruction::new_with_bytes(
program_keypair.pubkey(),
&[0],
vec![],
)],
Some(&mint_keypair.pubkey()),
);
assert!(bank_client
.send_and_confirm_message(&[&mint_keypair], message)
.is_ok());
}

#[test]
#[cfg(feature = "sbf_rust")]
fn test_program_sbf_upgrade() {
Expand Down

0 comments on commit a21378d

Please sign in to comment.