Skip to content

Commit

Permalink
Revert "Revert "Add set_account to solana-program-test (solana-labs#2…
Browse files Browse the repository at this point in the history
…1415)""

This reverts commit 480895c.
  • Loading branch information
Tyera Eulberg committed Dec 16, 2021
1 parent 80a2b06 commit 55be640
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,18 @@ impl ProgramTestContext {
bank.store_account(vote_account_address, &vote_account);
}

/// Create or overwrite an account, subverting normal runtime checks.
///
/// This method exists to make it easier to set up artificial situations
/// that would be difficult to replicate by sending individual transactions.
/// Beware that it can be used to create states that would not be reachable
/// by sending transactions!
pub fn set_account(&mut self, address: &Pubkey, account: &AccountSharedData) {
let bank_forks = self.bank_forks.read().unwrap();
let bank = bank_forks.working_bank();
bank.store_account(address, account);
}

/// Force the working bank ahead to a new slot
pub fn warp_to_slot(&mut self, warp_slot: Slot) -> Result<(), ProgramTestError> {
let mut bank_forks = self.bank_forks.write().unwrap();
Expand Down

0 comments on commit 55be640

Please sign in to comment.