Skip to content

Commit

Permalink
Adds test_max_instruction_trace_length().
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Sep 25, 2022
1 parent a5037d0 commit ddff44a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,21 @@ mod tests {
assert!(depth_reached < MAX_DEPTH);
}

#[test]
fn test_max_instruction_trace_length() {
const MAX_INSTRUCTIONS: usize = 8;
let mut transaction_context =
TransactionContext::new(Vec::new(), Some(Rent::default()), 1, MAX_INSTRUCTIONS);
for _ in 0..MAX_INSTRUCTIONS {
transaction_context.push().unwrap();
transaction_context.pop().unwrap();
}
assert_eq!(
transaction_context.push(),
Err(InstructionError::MaxInstructionTraceLengthExceeded)
);
}

#[test]
fn test_process_instruction() {
let callee_program_id = solana_sdk::pubkey::new_rand();
Expand Down

0 comments on commit ddff44a

Please sign in to comment.