Skip to content

Commit

Permalink
logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Nov 1, 2022
1 parent 60cb751 commit dc10c57
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ fn test_program_sbf_invoke_sanity() {
}
for program in programs.iter() {
println!("Test program: {:?}", program);
error!("Test program: {:?}", program);

let GenesisConfigInfo {
genesis_config,
Expand All @@ -1047,6 +1048,7 @@ fn test_program_sbf_invoke_sanity() {
bank.add_builtin(&name, &id, entrypoint);
let bank = Arc::new(bank);
let bank_client = BankClient::new_shared(&bank);
error!("{}", line!());

let invoke_program_id =
load_sbf_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.1);
Expand Down Expand Up @@ -1090,6 +1092,7 @@ fn test_program_sbf_invoke_sanity() {
AccountMeta::new_readonly(solana_sdk::ed25519_program::id(), false),
AccountMeta::new_readonly(invoke_program_id, false),
];
error!("{}", line!());

// success cases

Expand All @@ -1112,14 +1115,17 @@ fn test_program_sbf_invoke_sanity() {
);
let (result, inner_instructions, _log_messages) =
process_transaction_and_record_inner(&bank, tx);
assert_eq!(result, Ok(()));
error!("{}", line!());
assert_eq!(result, Ok(()));
error!("{}", line!());

let invoked_programs: Vec<Pubkey> = inner_instructions[0]
.iter()
.map(|ix| &message.account_keys[ix.instruction.program_id_index as usize])
.cloned()
.collect();
let expected_invoked_programs = match program.0 {
error!("{}", line!());
let expected_invoked_programs = match program.0 {
Languages::C => vec![
system_program::id(),
system_program::id(),
Expand Down Expand Up @@ -1168,6 +1174,7 @@ fn test_program_sbf_invoke_sanity() {
invoked_program_id.clone(),
],
};
error!("{}", line!());
assert_eq!(invoked_programs.len(), expected_invoked_programs.len());
assert_eq!(invoked_programs, expected_invoked_programs);
let no_invoked_programs: Vec<Pubkey> = inner_instructions[1]
Expand All @@ -1178,6 +1185,7 @@ fn test_program_sbf_invoke_sanity() {
assert_eq!(no_invoked_programs.len(), 0);

// failure cases
error!("{}", line!());

let do_invoke_failure_test_local =
|test: u8,
Expand Down Expand Up @@ -1231,34 +1239,39 @@ fn test_program_sbf_invoke_sanity() {
&[invoked_program_id.clone()],
None,
);
error!("{}", line!());

do_invoke_failure_test_local(
TEST_PRIVILEGE_ESCALATION_WRITABLE,
TransactionError::InstructionError(0, InstructionError::PrivilegeEscalation),
&[invoked_program_id.clone()],
None,
);
error!("{}", line!());

do_invoke_failure_test_local(
TEST_PPROGRAM_NOT_EXECUTABLE,
TransactionError::InstructionError(0, InstructionError::AccountNotExecutable),
&[],
None,
);
error!("{}", line!());

do_invoke_failure_test_local(
TEST_EMPTY_ACCOUNTS_SLICE,
TransactionError::InstructionError(0, InstructionError::MissingAccount),
&[],
None,
);
); error!("{}", line!());


do_invoke_failure_test_local(
TEST_CAP_SEEDS,
TransactionError::InstructionError(0, InstructionError::MaxSeedLengthExceeded),
&[],
None,
);
error!("{}", line!());

do_invoke_failure_test_local(
TEST_CAP_SIGNERS,
Expand Down

0 comments on commit dc10c57

Please sign in to comment.