Skip to content

Commit

Permalink
Switch to Account type to set an account (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aursen authored Feb 18, 2024
1 parent b32c021 commit fb1329f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions benches/banks_client_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async fn do_program_test(program_id: Pubkey, counter_address: Pubkey) {
let mut pt = solana_program_test::ProgramTest::default();
add_program(COUNTER_PROGRAM_BYTES, program_id, &mut pt);
let mut ctx = pt.start_with_context().await;
ctx.set_account(&counter_address, &counter_acc(program_id));
ctx.set_account(&counter_address, &counter_acc(program_id).into());

for deduper in 0..NUM_GREETINGS {
let tx = make_tx(
Expand Down Expand Up @@ -117,14 +117,13 @@ fn criterion_benchmark(c: &mut Criterion) {
});
}

fn counter_acc(program_id: Pubkey) -> solana_sdk::account::AccountSharedData {
fn counter_acc(program_id: Pubkey) -> solana_sdk::account::Account {
Account {
lamports: 5,
data: vec![0_u8; std::mem::size_of::<u32>()],
owner: program_id,
..Default::default()
}
.into()
}

criterion_group!(benches, criterion_benchmark);
Expand Down
4 changes: 2 additions & 2 deletions src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ impl LiteSVM {
self.accounts.get_account(pubkey).into()
}

pub fn set_account(&mut self, pubkey: Pubkey, data: AccountSharedData) {
self.accounts.add_account(pubkey, data)
pub fn set_account(&mut self, pubkey: Pubkey, data: Account) {
self.accounts.add_account(pubkey, data.into())
}

pub fn get_balance(&self, pubkey: &Pubkey) -> u64 {
Expand Down
3 changes: 1 addition & 2 deletions tests/programs/counter/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ fn add_program(bytes: &[u8], program_id: Pubkey, pt: &mut solana_program_test::P
);
}

fn counter_acc(program_id: Pubkey) -> solana_sdk::account::AccountSharedData {
fn counter_acc(program_id: Pubkey) -> solana_sdk::account::Account {
Account {
lamports: 5,
data: vec![0_u8; std::mem::size_of::<u32>()],
owner: program_id,
..Default::default()
}
.into()
}

async fn do_program_test(program_id: Pubkey, counter_address: Pubkey) {
Expand Down

0 comments on commit fb1329f

Please sign in to comment.