Fix account tests (#8615) (#8729)

automerge
This commit is contained in:
mergify[bot]
2020-03-09 11:19:14 -07:00
committed by GitHub
parent c19eb717b4
commit f511296ee8

View File

@ -1107,12 +1107,11 @@ mod tests {
let key0 = keypair.pubkey();
let key1 = Pubkey::new(&[5u8; 32]);
let account = Account::new(1, 1, &Pubkey::default());
let account = Account::new(1, 0, &Pubkey::default());
accounts.push((key0, account));
let mut account = Account::new(40, 0, &Pubkey::default());
let mut account = Account::new(40, 1, &native_loader::id());
account.executable = true;
account.owner = Pubkey::default();
accounts.push((key1, account));
let instructions = vec![CompiledInstruction::new(0, &(), vec![0])];
@ -1126,6 +1125,44 @@ mod tests {
let loaded_accounts = load_accounts(tx, &accounts, &mut error_counters);
assert_eq!(error_counters.invalid_account_for_fee, 1);
assert_eq!(loaded_accounts.len(), 1);
assert_eq!(
loaded_accounts[0],
(
Err(TransactionError::InvalidAccountForFee),
Some(HashAgeKind::Extant)
)
);
}
#[test]
fn test_load_accounts_bad_owner() {
let mut accounts: Vec<(Pubkey, Account)> = Vec::new();
let mut error_counters = ErrorCounters::default();
let keypair = Keypair::new();
let key0 = keypair.pubkey();
let key1 = Pubkey::new(&[5u8; 32]);
let account = Account::new(1, 0, &Pubkey::default());
accounts.push((key0, account));
let mut account = Account::new(40, 1, &Pubkey::default());
account.executable = true;
accounts.push((key1, account));
let instructions = vec![CompiledInstruction::new(1, &(), vec![0])];
let tx = Transaction::new_with_compiled_instructions(
&[&keypair],
&[],
Hash::default(),
vec![key1],
instructions,
);
let loaded_accounts = load_accounts(tx, &accounts, &mut error_counters);
assert_eq!(error_counters.account_not_found, 1);
assert_eq!(loaded_accounts.len(), 1);
assert_eq!(
@ -1149,8 +1186,7 @@ mod tests {
let account = Account::new(1, 0, &Pubkey::default());
accounts.push((key0, account));
let mut account = Account::new(40, 1, &Pubkey::default());
account.owner = native_loader::id();
let account = Account::new(40, 1, &native_loader::id());
accounts.push((key1, account));
let instructions = vec![CompiledInstruction::new(1, &(), vec![0])];