AccountSharedData construction (#15790)
This commit is contained in:
committed by
GitHub
parent
3419a5446e
commit
952c3bcbb7
@ -1253,7 +1253,7 @@ pub mod test {
|
||||
},
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, WritableAccount},
|
||||
account::{Account, AccountSharedData, WritableAccount},
|
||||
clock::Slot,
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
@ -2255,10 +2255,10 @@ pub mod test {
|
||||
#[test]
|
||||
fn test_stake_is_updated_for_entire_branch() {
|
||||
let mut voted_stakes = HashMap::new();
|
||||
let account = AccountSharedData {
|
||||
let account = AccountSharedData::from(Account {
|
||||
lamports: 1,
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
let set: HashSet<u64> = vec![0u64, 1u64].into_iter().collect();
|
||||
let ancestors: HashMap<u64, HashSet<u64>> = [(2u64, set)].iter().cloned().collect();
|
||||
Tower::update_ancestor_voted_stakes(&mut voted_stakes, 2, account.lamports, &ancestors);
|
||||
|
@ -3100,6 +3100,7 @@ pub mod tests {
|
||||
accounts_background_service::AbsRequestSender, commitment::BlockCommitment,
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
clock::MAX_RECENT_BLOCKHASHES,
|
||||
fee_calculator::DEFAULT_BURN_PERCENT,
|
||||
hash::{hash, Hash},
|
||||
@ -5614,12 +5615,12 @@ pub mod tests {
|
||||
close_authority: COption::Some(owner),
|
||||
};
|
||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||
let token_account = AccountSharedData {
|
||||
let token_account = AccountSharedData::from(Account {
|
||||
lamports: 111,
|
||||
data: account_data.to_vec(),
|
||||
owner: spl_token_id_v2_0(),
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank.store_account(&token_account_pubkey, &token_account);
|
||||
|
||||
@ -5633,12 +5634,12 @@ pub mod tests {
|
||||
freeze_authority: COption::Some(owner),
|
||||
};
|
||||
Mint::pack(mint_state, &mut mint_data).unwrap();
|
||||
let mint_account = AccountSharedData {
|
||||
let mint_account = AccountSharedData::from(Account {
|
||||
lamports: 111,
|
||||
data: mint_data.to_vec(),
|
||||
owner: spl_token_id_v2_0(),
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
||||
|
||||
let req = format!(
|
||||
@ -5710,12 +5711,12 @@ pub mod tests {
|
||||
close_authority: COption::Some(owner),
|
||||
};
|
||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||
let token_account = AccountSharedData {
|
||||
let token_account = AccountSharedData::from(Account {
|
||||
lamports: 111,
|
||||
data: account_data.to_vec(),
|
||||
owner: spl_token_id_v2_0(),
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
let token_with_different_mint_pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank.store_account(&token_with_different_mint_pubkey, &token_account);
|
||||
|
||||
@ -5929,12 +5930,12 @@ pub mod tests {
|
||||
freeze_authority: COption::Some(owner),
|
||||
};
|
||||
Mint::pack(mint_state, &mut mint_data).unwrap();
|
||||
let mint_account = AccountSharedData {
|
||||
let mint_account = AccountSharedData::from(Account {
|
||||
lamports: 111,
|
||||
data: mint_data.to_vec(),
|
||||
owner: spl_token_id_v2_0(),
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
bank.store_account(
|
||||
&Pubkey::from_str(&new_mint.to_string()).unwrap(),
|
||||
&mint_account,
|
||||
@ -5951,12 +5952,12 @@ pub mod tests {
|
||||
close_authority: COption::Some(owner),
|
||||
};
|
||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||
let token_account = AccountSharedData {
|
||||
let token_account = AccountSharedData::from(Account {
|
||||
lamports: 111,
|
||||
data: account_data.to_vec(),
|
||||
owner: spl_token_id_v2_0(),
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
let token_with_smaller_balance = solana_sdk::pubkey::new_rand();
|
||||
bank.store_account(&token_with_smaller_balance, &token_account);
|
||||
|
||||
@ -6015,12 +6016,12 @@ pub mod tests {
|
||||
close_authority: COption::Some(owner),
|
||||
};
|
||||
TokenAccount::pack(token_account, &mut account_data).unwrap();
|
||||
let token_account = AccountSharedData {
|
||||
let token_account = AccountSharedData::from(Account {
|
||||
lamports: 111,
|
||||
data: account_data.to_vec(),
|
||||
owner: spl_token_id_v2_0(),
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||
bank.store_account(&token_account_pubkey, &token_account);
|
||||
|
||||
@ -6034,12 +6035,12 @@ pub mod tests {
|
||||
freeze_authority: COption::Some(owner),
|
||||
};
|
||||
Mint::pack(mint_state, &mut mint_data).unwrap();
|
||||
let mint_account = AccountSharedData {
|
||||
let mint_account = AccountSharedData::from(Account {
|
||||
lamports: 111,
|
||||
data: mint_data.to_vec(),
|
||||
owner: spl_token_id_v2_0(),
|
||||
..AccountSharedData::default()
|
||||
};
|
||||
..Account::default()
|
||||
});
|
||||
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
||||
|
||||
let req = format!(
|
||||
|
@ -13,7 +13,7 @@ use {
|
||||
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||
},
|
||||
solana_sdk::{
|
||||
account::AccountSharedData,
|
||||
account::{Account, AccountSharedData},
|
||||
clock::{Slot, DEFAULT_MS_PER_SLOT},
|
||||
commitment_config::CommitmentConfig,
|
||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||
@ -133,7 +133,7 @@ impl TestValidatorGenesis {
|
||||
) -> &mut Self {
|
||||
self.add_account(
|
||||
address,
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
lamports,
|
||||
data: solana_program_test::read_file(
|
||||
solana_program_test::find_file(filename).unwrap_or_else(|| {
|
||||
@ -143,7 +143,7 @@ impl TestValidatorGenesis {
|
||||
owner,
|
||||
executable: false,
|
||||
rent_epoch: 0,
|
||||
},
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@ -158,14 +158,14 @@ impl TestValidatorGenesis {
|
||||
) -> &mut Self {
|
||||
self.add_account(
|
||||
address,
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
lamports,
|
||||
data: base64::decode(data_base64)
|
||||
.unwrap_or_else(|err| panic!("Failed to base64 decode: {}", err)),
|
||||
owner,
|
||||
executable: false,
|
||||
rent_epoch: 0,
|
||||
},
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@ -285,13 +285,13 @@ impl TestValidator {
|
||||
let data = solana_program_test::read_file(&program.program_path);
|
||||
accounts.insert(
|
||||
program.program_id,
|
||||
AccountSharedData {
|
||||
AccountSharedData::from(Account {
|
||||
lamports: Rent::default().minimum_balance(data.len()).min(1),
|
||||
data,
|
||||
owner: program.loader,
|
||||
executable: true,
|
||||
rent_epoch: 0,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user