Skip to content

Commit

Permalink
fuzz: hack entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
skrrb committed Jan 24, 2024
1 parent 9fbff36 commit 2e83992
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion programs/openbook-v2/fuzz/src/accounts_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl AccountsState {
infos
}

pub fn update(&mut self, infos: Vec<AccountInfo>) {
pub fn update(&mut self, infos: &[AccountInfo]) {
infos.iter().for_each(|info| {
let account = self.0.get_mut(info.key).unwrap();
let new_data = info.data.borrow();
Expand Down
19 changes: 13 additions & 6 deletions programs/openbook-v2/fuzz/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,18 @@ impl program_stubs::SyscallStubs for TestSyscallStubs {
&new_account_infos,
&instruction.data,
),
id if id == openbook_v2::ID => openbook_v2::entry(
&instruction.program_id,
&new_account_infos,
&instruction.data,
),
id if id == openbook_v2::ID => {
let extended_lifetime_accs = unsafe {
core::mem::transmute::<&[AccountInfo], &[AccountInfo<'_>]>(
new_account_infos.as_ref(),
)
};
openbook_v2::entry(
&instruction.program_id,
&extended_lifetime_accs,
&instruction.data,
)
}
_ => Err(ProgramError::IncorrectProgramId),
}
}
Expand Down Expand Up @@ -99,7 +106,7 @@ pub fn process_instruction(
);

if res.is_ok() {
state.update(account_infos);
state.update(&account_infos);
}

res
Expand Down

0 comments on commit 2e83992

Please sign in to comment.