AccountSharedData construction (#15790)
This commit is contained in:
committed by
GitHub
parent
3419a5446e
commit
952c3bcbb7
@@ -251,7 +251,10 @@ pub fn deserialize_parameters_aligned(
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{
|
||||
account::AccountSharedData, account_info::AccountInfo, bpf_loader, entrypoint::deserialize,
|
||||
account::{Account, AccountSharedData},
|
||||
account_info::AccountInfo,
|
||||
bpf_loader,
|
||||
entrypoint::deserialize,
|
||||
};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
@@ -271,35 +274,35 @@ mod tests {
|
||||
solana_sdk::pubkey::new_rand(),
|
||||
];
|
||||
let accounts = [
|
||||
RefCell::new(AccountSharedData {
|
||||
RefCell::new(AccountSharedData::from(Account {
|
||||
lamports: 1,
|
||||
data: vec![1u8, 2, 3, 4, 5],
|
||||
owner: bpf_loader::id(),
|
||||
executable: false,
|
||||
rent_epoch: 100,
|
||||
}),
|
||||
})),
|
||||
// dup of first
|
||||
RefCell::new(AccountSharedData {
|
||||
RefCell::new(AccountSharedData::from(Account {
|
||||
lamports: 1,
|
||||
data: vec![1u8, 2, 3, 4, 5],
|
||||
owner: bpf_loader::id(),
|
||||
executable: false,
|
||||
rent_epoch: 100,
|
||||
}),
|
||||
RefCell::new(AccountSharedData {
|
||||
})),
|
||||
RefCell::new(AccountSharedData::from(Account {
|
||||
lamports: 2,
|
||||
data: vec![11u8, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||
owner: bpf_loader::id(),
|
||||
executable: true,
|
||||
rent_epoch: 200,
|
||||
}),
|
||||
RefCell::new(AccountSharedData {
|
||||
})),
|
||||
RefCell::new(AccountSharedData::from(Account {
|
||||
lamports: 3,
|
||||
data: vec![],
|
||||
owner: bpf_loader::id(),
|
||||
executable: false,
|
||||
rent_epoch: 3100,
|
||||
}),
|
||||
})),
|
||||
];
|
||||
|
||||
let keyed_accounts: Vec<_> = keys
|
||||
|
@@ -10,7 +10,7 @@ use solana_rbpf::{
|
||||
};
|
||||
use solana_runtime::message_processor::MessageProcessor;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
account::{Account, AccountSharedData, ReadableAccount},
|
||||
account_info::AccountInfo,
|
||||
account_utils::StateMut,
|
||||
bpf_loader, bpf_loader_deprecated,
|
||||
@@ -1009,13 +1009,13 @@ impl<'a> SyscallInvokeSigned<'a> for SyscallInvokeSignedRust<'a> {
|
||||
};
|
||||
|
||||
Ok((
|
||||
Rc::new(RefCell::new(AccountSharedData {
|
||||
Rc::new(RefCell::new(AccountSharedData::from(Account {
|
||||
lamports: *lamports,
|
||||
data: data.to_vec(),
|
||||
executable: account_info.executable,
|
||||
owner: *owner,
|
||||
rent_epoch: account_info.rent_epoch,
|
||||
})),
|
||||
}))),
|
||||
Some(AccountReferences {
|
||||
lamports,
|
||||
owner,
|
||||
@@ -1294,13 +1294,13 @@ impl<'a> SyscallInvokeSigned<'a> for SyscallInvokeSignedC<'a> {
|
||||
)?;
|
||||
|
||||
Ok((
|
||||
Rc::new(RefCell::new(AccountSharedData {
|
||||
Rc::new(RefCell::new(AccountSharedData::from(Account {
|
||||
lamports: *lamports,
|
||||
data: data.to_vec(),
|
||||
executable: account_info.executable,
|
||||
owner: *owner,
|
||||
rent_epoch: account_info.rent_epoch,
|
||||
})),
|
||||
}))),
|
||||
Some(AccountReferences {
|
||||
lamports,
|
||||
owner,
|
||||
|
@@ -247,7 +247,7 @@ mod tests {
|
||||
use crate::id;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_runtime::bank_client::BankClient;
|
||||
use solana_sdk::account::AccountSharedData;
|
||||
use solana_sdk::account::{Account, AccountSharedData};
|
||||
use solana_sdk::client::SyncClient;
|
||||
use solana_sdk::genesis_config::create_genesis_config;
|
||||
use solana_sdk::hash::hash;
|
||||
@@ -540,11 +540,11 @@ mod tests {
|
||||
fn test_pay_when_account_data() {
|
||||
let (bank, alice_keypair) = create_bank(42);
|
||||
let game_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let game_account = AccountSharedData {
|
||||
let game_account = AccountSharedData::from(Account {
|
||||
lamports: 1,
|
||||
data: vec![1, 2, 3],
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
bank.store_account(&game_pubkey, &game_account);
|
||||
assert_eq!(
|
||||
bank.get_account(&game_pubkey).unwrap().data(),
|
||||
|
@@ -134,7 +134,7 @@ mod tests {
|
||||
use bincode::serialized_size;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_sdk::{
|
||||
account::AccountSharedData,
|
||||
account::{Account, AccountSharedData},
|
||||
keyed_account::create_keyed_is_signer_accounts,
|
||||
process_instruction::MockInvokeContext,
|
||||
signature::{Keypair, Signer},
|
||||
@@ -183,11 +183,11 @@ mod tests {
|
||||
} => space,
|
||||
_ => panic!("Not a CreateAccount system instruction"),
|
||||
};
|
||||
let config_account = RefCell::new(AccountSharedData {
|
||||
let config_account = RefCell::new(AccountSharedData::from(Account {
|
||||
data: vec![0; space as usize],
|
||||
owner: id(),
|
||||
..AccountSharedData::default()
|
||||
});
|
||||
..Account::default()
|
||||
}));
|
||||
let accounts = vec![(&config_pubkey, true, &config_account)];
|
||||
let keyed_accounts = create_keyed_is_signer_accounts(&accounts);
|
||||
assert_eq!(
|
||||
@@ -338,10 +338,10 @@ mod tests {
|
||||
let my_config = MyConfig::new(42);
|
||||
|
||||
let instruction = config_instruction::store(&config_pubkey, false, keys, &my_config);
|
||||
let signer0_account = RefCell::new(AccountSharedData {
|
||||
let signer0_account = RefCell::new(AccountSharedData::from(Account {
|
||||
owner: id(),
|
||||
..AccountSharedData::default()
|
||||
});
|
||||
..Account::default()
|
||||
}));
|
||||
let accounts = vec![(&signer0_pubkey, true, &signer0_account)];
|
||||
let keyed_accounts = create_keyed_is_signer_accounts(&accounts);
|
||||
assert_eq!(
|
||||
|
@@ -5,7 +5,11 @@ pub mod date_instruction;
|
||||
|
||||
use bincode::{deserialize, serialize, serialized_size};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_sdk::{account::AccountSharedData, pubkey::Pubkey, short_vec};
|
||||
use solana_sdk::{
|
||||
account::{Account, AccountSharedData},
|
||||
pubkey::Pubkey,
|
||||
short_vec,
|
||||
};
|
||||
|
||||
solana_sdk::declare_id!("Config1111111111111111111111111111111111111");
|
||||
|
||||
@@ -43,10 +47,10 @@ pub fn create_config_account<T: ConfigState>(
|
||||
) -> AccountSharedData {
|
||||
let mut data = serialize(&ConfigKeys { keys }).unwrap();
|
||||
data.extend_from_slice(&serialize(config_data).unwrap());
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
lamports,
|
||||
data,
|
||||
owner: id(),
|
||||
..AccountSharedData::default()
|
||||
}
|
||||
..Account::default()
|
||||
})
|
||||
}
|
||||
|
@@ -622,7 +622,7 @@ mod tests {
|
||||
use super::*;
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
account::{self, AccountSharedData},
|
||||
account::{self, Account, AccountSharedData},
|
||||
process_instruction::MockInvokeContext,
|
||||
rent::Rent,
|
||||
sysvar::stake_history::StakeHistory,
|
||||
@@ -635,10 +635,10 @@ mod tests {
|
||||
}
|
||||
|
||||
fn create_default_stake_account() -> RefCell<AccountSharedData> {
|
||||
RefCell::new(AccountSharedData {
|
||||
RefCell::new(AccountSharedData::from(Account {
|
||||
owner: id(),
|
||||
..AccountSharedData::default()
|
||||
})
|
||||
..Account::default()
|
||||
}))
|
||||
}
|
||||
|
||||
fn invalid_stake_state_pubkey() -> Pubkey {
|
||||
@@ -673,25 +673,25 @@ mod tests {
|
||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||
account::create_account_shared_data(&Rent::default(), 1)
|
||||
} else if meta.pubkey == invalid_stake_state_pubkey() {
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
owner: id(),
|
||||
..AccountSharedData::default()
|
||||
}
|
||||
..Account::default()
|
||||
})
|
||||
} else if meta.pubkey == invalid_vote_state_pubkey() {
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
owner: solana_vote_program::id(),
|
||||
..AccountSharedData::default()
|
||||
}
|
||||
..Account::default()
|
||||
})
|
||||
} else if meta.pubkey == spoofed_stake_state_pubkey() {
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
owner: spoofed_stake_program_id(),
|
||||
..AccountSharedData::default()
|
||||
}
|
||||
..Account::default()
|
||||
})
|
||||
} else {
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
owner: id(),
|
||||
..AccountSharedData::default()
|
||||
}
|
||||
..Account::default()
|
||||
})
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
@@ -342,7 +342,7 @@ pub fn process_instruction(
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{
|
||||
account::{self, AccountSharedData},
|
||||
account::{self, Account, AccountSharedData},
|
||||
process_instruction::MockInvokeContext,
|
||||
rent::Rent,
|
||||
};
|
||||
@@ -376,15 +376,15 @@ mod tests {
|
||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||
account::create_account_shared_data(&Rent::free(), 1)
|
||||
} else if meta.pubkey == invalid_vote_state_pubkey() {
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
owner: invalid_vote_state_pubkey(),
|
||||
..AccountSharedData::default()
|
||||
}
|
||||
..Account::default()
|
||||
})
|
||||
} else {
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
owner: id(),
|
||||
..AccountSharedData::default()
|
||||
}
|
||||
..Account::default()
|
||||
})
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
Reference in New Issue
Block a user