Skip to content

Commit

Permalink
Fix return data too large test
Browse files Browse the repository at this point in the history
  • Loading branch information
seanyoung committed Sep 30, 2021
1 parent 3854cfa commit d09687c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions programs/bpf/rust/invoke/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub const TEST_NESTED_INVOKE_TOO_DEEP: u8 = 15;
pub const TEST_EXECUTABLE_LAMPORTS: u8 = 16;
pub const TEST_CALL_PRECOMPILE: u8 = 17;
pub const ADD_LAMPORTS: u8 = 18;
pub const TEST_RETURN_DATA_TOO_LARGE: u8 = 19;

pub const MINT_INDEX: usize = 0;
pub const ARGUMENT_INDEX: usize = 1;
Expand Down
3 changes: 3 additions & 0 deletions programs/bpf/rust/invoke/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ fn process_instruction(
// make sure the total balance is fine
**accounts[0].lamports.borrow_mut() += 1;
}
TEST_RETURN_DATA_TOO_LARGE => {
set_return_data(&[1u8; 1028]);
}
_ => panic!(),
}

Expand Down
6 changes: 6 additions & 0 deletions programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,12 @@ fn test_program_bpf_invoke_sanity() {
&[],
);

do_invoke_failure_test_local(
TEST_RETURN_DATA_TOO_LARGE,
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete),
&[],
);

// Check resulting state

assert_eq!(43, bank.get_balance(&derived_key1));
Expand Down

0 comments on commit d09687c

Please sign in to comment.