Skip to content

Commit 3d324e3

Browse files
committed
get_pda_with_bump helper
1 parent 10577b0 commit 3d324e3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

crates/testsvm-core/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,21 @@ impl TestSVM {
156156
seeds: &[&[u8]],
157157
program_id: Pubkey,
158158
) -> Result<AccountRef<T>> {
159-
let (pubkey, _bump) = self
159+
let (pda, _) = self.get_pda_with_bump(label, seeds, program_id)?;
160+
Ok(pda)
161+
}
162+
163+
/// Finds a program derived address and return an [AccountRef] with proper type information and bump seed.
164+
pub fn get_pda_with_bump<T: anchor_lang::AccountDeserialize>(
165+
&mut self,
166+
label: &str,
167+
seeds: &[&[u8]],
168+
program_id: Pubkey,
169+
) -> Result<(AccountRef<T>, u8)> {
170+
let (pubkey, bump) = self
160171
.address_book
161172
.find_pda_with_bump(label, seeds, program_id)?;
162-
Ok(AccountRef::new(pubkey))
173+
Ok((AccountRef::new(pubkey), bump))
163174
}
164175

165176
/// Advance the time by the specified number of seconds

0 commit comments

Comments
 (0)