tests: .lamports -> .lamports() (#16976)
This commit is contained in:
parent
3f982fcf65
commit
ac87bc40ca
|
@ -2290,12 +2290,12 @@ mod tests {
|
||||||
&mut MockInvokeContext::new(keyed_accounts)
|
&mut MockInvokeContext::new(keyed_accounts)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert_eq!(0, buffer_account.borrow().lamports);
|
assert_eq!(0, buffer_account.borrow().lamports());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
min_programdata_balance,
|
min_programdata_balance,
|
||||||
programdata_account.borrow().lamports
|
programdata_account.borrow().lamports()
|
||||||
);
|
);
|
||||||
assert_eq!(1, spill_account.borrow().lamports);
|
assert_eq!(1, spill_account.borrow().lamports());
|
||||||
let state: UpgradeableLoaderState = programdata_account.borrow().state().unwrap();
|
let state: UpgradeableLoaderState = programdata_account.borrow().state().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
state,
|
state,
|
||||||
|
|
|
@ -421,7 +421,7 @@ mod tests {
|
||||||
for ((account, account_info), key) in accounts.iter().zip(de_accounts).zip(keys.clone()) {
|
for ((account, account_info), key) in accounts.iter().zip(de_accounts).zip(keys.clone()) {
|
||||||
assert_eq!(key, *account_info.key);
|
assert_eq!(key, *account_info.key);
|
||||||
let account = account.borrow();
|
let account = account.borrow();
|
||||||
assert_eq!(account.lamports, account_info.lamports());
|
assert_eq!(account.lamports(), account_info.lamports());
|
||||||
assert_eq!(account.data(), &account_info.data.borrow()[..]);
|
assert_eq!(account.data(), &account_info.data.borrow()[..]);
|
||||||
assert_eq!(account.owner(), account_info.owner);
|
assert_eq!(account.owner(), account_info.owner);
|
||||||
assert_eq!(account.executable(), account_info.executable);
|
assert_eq!(account.executable(), account_info.executable);
|
||||||
|
@ -466,7 +466,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
assert_eq!(key, *de_keyed_account.unsigned_key());
|
assert_eq!(key, *de_keyed_account.unsigned_key());
|
||||||
let account = account.borrow();
|
let account = account.borrow();
|
||||||
assert_eq!(account.lamports, de_keyed_account.lamports().unwrap());
|
assert_eq!(account.lamports(), de_keyed_account.lamports().unwrap());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
account.data(),
|
account.data(),
|
||||||
de_keyed_account.try_account_ref().unwrap().data()
|
de_keyed_account.try_account_ref().unwrap().data()
|
||||||
|
@ -493,7 +493,7 @@ mod tests {
|
||||||
for ((account, account_info), key) in accounts.iter().zip(de_accounts).zip(keys.clone()) {
|
for ((account, account_info), key) in accounts.iter().zip(de_accounts).zip(keys.clone()) {
|
||||||
assert_eq!(key, *account_info.key);
|
assert_eq!(key, *account_info.key);
|
||||||
let account = account.borrow();
|
let account = account.borrow();
|
||||||
assert_eq!(account.lamports, account_info.lamports());
|
assert_eq!(account.lamports(), account_info.lamports());
|
||||||
assert_eq!(account.data(), &account_info.data.borrow()[..]);
|
assert_eq!(account.data(), &account_info.data.borrow()[..]);
|
||||||
assert_eq!(account.owner(), account_info.owner);
|
assert_eq!(account.owner(), account_info.owner);
|
||||||
assert_eq!(account.executable(), account_info.executable);
|
assert_eq!(account.executable(), account_info.executable);
|
||||||
|
@ -525,7 +525,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
assert_eq!(key, *de_keyed_account.unsigned_key());
|
assert_eq!(key, *de_keyed_account.unsigned_key());
|
||||||
let account = account.borrow();
|
let account = account.borrow();
|
||||||
assert_eq!(account.lamports, de_keyed_account.lamports().unwrap());
|
assert_eq!(account.lamports(), de_keyed_account.lamports().unwrap());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
account.data(),
|
account.data(),
|
||||||
de_keyed_account.try_account_ref().unwrap().data()
|
de_keyed_account.try_account_ref().unwrap().data()
|
||||||
|
|
|
@ -360,10 +360,10 @@ mod test {
|
||||||
assert_eq!(state, State::Initialized(data));
|
assert_eq!(state, State::Initialized(data));
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = keyed_account.account.borrow().lamports;
|
let withdraw_lamports = keyed_account.account.borrow().lamports();
|
||||||
let expect_nonce_lamports =
|
let expect_nonce_lamports =
|
||||||
keyed_account.account.borrow().lamports - withdraw_lamports;
|
keyed_account.account.borrow().lamports() - withdraw_lamports;
|
||||||
let expect_to_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
|
let expect_to_lamports = to_keyed.account.borrow().lamports() + withdraw_lamports;
|
||||||
keyed_account
|
keyed_account
|
||||||
.withdraw_nonce_account(
|
.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
|
@ -376,11 +376,11 @@ mod test {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// Empties Account balance
|
// Empties Account balance
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
keyed_account.account.borrow().lamports,
|
keyed_account.account.borrow().lamports(),
|
||||||
expect_nonce_lamports
|
expect_nonce_lamports
|
||||||
);
|
);
|
||||||
// Account balance goes to `to`
|
// Account balance goes to `to`
|
||||||
assert_eq!(to_keyed.account.borrow().lamports, expect_to_lamports);
|
assert_eq!(to_keyed.account.borrow().lamports(), expect_to_lamports);
|
||||||
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
|
@ -590,10 +590,10 @@ mod test {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let expect_nonce_lamports =
|
let expect_nonce_lamports =
|
||||||
nonce_keyed.account.borrow().lamports - withdraw_lamports;
|
nonce_keyed.account.borrow().lamports() - withdraw_lamports;
|
||||||
let expect_to_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
|
let expect_to_lamports = to_keyed.account.borrow().lamports() + withdraw_lamports;
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
.withdraw_nonce_account(
|
.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
|
@ -636,7 +636,7 @@ mod test {
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let signers = HashSet::new();
|
let signers = HashSet::new();
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let lamports = nonce_keyed.account.borrow().lamports;
|
let lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let result = nonce_keyed.withdraw_nonce_account(
|
let result = nonce_keyed.withdraw_nonce_account(
|
||||||
lamports,
|
lamports,
|
||||||
&to_keyed,
|
&to_keyed,
|
||||||
|
@ -666,7 +666,7 @@ mod test {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let lamports = nonce_keyed.account.borrow().lamports + 1;
|
let lamports = nonce_keyed.account.borrow().lamports() + 1;
|
||||||
let result = nonce_keyed.withdraw_nonce_account(
|
let result = nonce_keyed.withdraw_nonce_account(
|
||||||
lamports,
|
lamports,
|
||||||
&to_keyed,
|
&to_keyed,
|
||||||
|
@ -692,10 +692,10 @@ mod test {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports / 2;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports() / 2;
|
||||||
let nonce_expect_lamports =
|
let nonce_expect_lamports =
|
||||||
nonce_keyed.account.borrow().lamports - withdraw_lamports;
|
nonce_keyed.account.borrow().lamports() - withdraw_lamports;
|
||||||
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
|
let to_expect_lamports = to_keyed.account.borrow().lamports() + withdraw_lamports;
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
.withdraw_nonce_account(
|
.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
|
@ -710,12 +710,15 @@ mod test {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
assert_eq!(nonce_keyed.account.borrow().lamports, nonce_expect_lamports);
|
assert_eq!(
|
||||||
assert_eq!(to_keyed.account.borrow().lamports, to_expect_lamports);
|
nonce_keyed.account.borrow().lamports(),
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports;
|
nonce_expect_lamports
|
||||||
|
);
|
||||||
|
assert_eq!(to_keyed.account.borrow().lamports(), to_expect_lamports);
|
||||||
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let nonce_expect_lamports =
|
let nonce_expect_lamports =
|
||||||
nonce_keyed.account.borrow().lamports - withdraw_lamports;
|
nonce_keyed.account.borrow().lamports() - withdraw_lamports;
|
||||||
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
|
let to_expect_lamports = to_keyed.account.borrow().lamports() + withdraw_lamports;
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
.withdraw_nonce_account(
|
.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
|
@ -730,8 +733,11 @@ mod test {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
assert_eq!(nonce_keyed.account.borrow().lamports, nonce_expect_lamports);
|
assert_eq!(
|
||||||
assert_eq!(to_keyed.account.borrow().lamports, to_expect_lamports);
|
nonce_keyed.account.borrow().lamports(),
|
||||||
|
nonce_expect_lamports
|
||||||
|
);
|
||||||
|
assert_eq!(to_keyed.account.borrow().lamports(), to_expect_lamports);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -766,10 +772,10 @@ mod test {
|
||||||
};
|
};
|
||||||
assert_eq!(state, State::Initialized(data.clone()));
|
assert_eq!(state, State::Initialized(data.clone()));
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports - min_lamports;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports() - min_lamports;
|
||||||
let nonce_expect_lamports =
|
let nonce_expect_lamports =
|
||||||
nonce_keyed.account.borrow().lamports - withdraw_lamports;
|
nonce_keyed.account.borrow().lamports() - withdraw_lamports;
|
||||||
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
|
let to_expect_lamports = to_keyed.account.borrow().lamports() + withdraw_lamports;
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
.withdraw_nonce_account(
|
.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
|
@ -789,13 +795,16 @@ mod test {
|
||||||
..data.clone()
|
..data.clone()
|
||||||
};
|
};
|
||||||
assert_eq!(state, State::Initialized(data));
|
assert_eq!(state, State::Initialized(data));
|
||||||
assert_eq!(nonce_keyed.account.borrow().lamports, nonce_expect_lamports);
|
assert_eq!(
|
||||||
assert_eq!(to_keyed.account.borrow().lamports, to_expect_lamports);
|
nonce_keyed.account.borrow().lamports(),
|
||||||
|
nonce_expect_lamports
|
||||||
|
);
|
||||||
|
assert_eq!(to_keyed.account.borrow().lamports(), to_expect_lamports);
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let nonce_expect_lamports =
|
let nonce_expect_lamports =
|
||||||
nonce_keyed.account.borrow().lamports - withdraw_lamports;
|
nonce_keyed.account.borrow().lamports() - withdraw_lamports;
|
||||||
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
|
let to_expect_lamports = to_keyed.account.borrow().lamports() + withdraw_lamports;
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
.withdraw_nonce_account(
|
.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
|
@ -810,8 +819,11 @@ mod test {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
assert_eq!(nonce_keyed.account.borrow().lamports, nonce_expect_lamports);
|
assert_eq!(
|
||||||
assert_eq!(to_keyed.account.borrow().lamports, to_expect_lamports);
|
nonce_keyed.account.borrow().lamports(),
|
||||||
|
nonce_expect_lamports
|
||||||
|
);
|
||||||
|
assert_eq!(to_keyed.account.borrow().lamports(), to_expect_lamports);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -837,7 +849,7 @@ mod test {
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let result = nonce_keyed.withdraw_nonce_account(
|
let result = nonce_keyed.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
&to_keyed,
|
&to_keyed,
|
||||||
|
@ -873,7 +885,7 @@ mod test {
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports + 1;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports() + 1;
|
||||||
let result = nonce_keyed.withdraw_nonce_account(
|
let result = nonce_keyed.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
&to_keyed,
|
&to_keyed,
|
||||||
|
@ -909,7 +921,7 @@ mod test {
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports - min_lamports + 1;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports() - min_lamports + 1;
|
||||||
let result = nonce_keyed.withdraw_nonce_account(
|
let result = nonce_keyed.withdraw_nonce_account(
|
||||||
withdraw_lamports,
|
withdraw_lamports,
|
||||||
&to_keyed,
|
&to_keyed,
|
||||||
|
|
Loading…
Reference in New Issue