Nonce accounts must be writeable (#21260)
* Nonce accounts must be writeable * feedback * feedback
This commit is contained in:
@@ -1484,10 +1484,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_process_nonce_ix_no_acc_data_fail() {
|
||||
let none_address = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
process_nonce_instruction(&system_instruction::advance_nonce_account(
|
||||
&Pubkey::default(),
|
||||
&Pubkey::default()
|
||||
&none_address,
|
||||
&none_address
|
||||
)),
|
||||
Err(InstructionError::InvalidAccountData),
|
||||
);
|
||||
@@ -1509,7 +1510,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::AdvanceNonceAccount).unwrap(),
|
||||
&[(true, false, Pubkey::default(), create_default_account())],
|
||||
&[(true, true, Pubkey::new_unique(), create_default_account())],
|
||||
),
|
||||
Err(InstructionError::NotEnoughAccountKeys),
|
||||
);
|
||||
@@ -1521,7 +1522,7 @@ mod tests {
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::AdvanceNonceAccount).unwrap(),
|
||||
&[
|
||||
(true, false, Pubkey::default(), create_default_account()),
|
||||
(true, true, Pubkey::new_unique(), create_default_account()),
|
||||
(
|
||||
false,
|
||||
false,
|
||||
@@ -1537,11 +1538,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_process_nonce_ix_ok() {
|
||||
let nonce_address = Pubkey::new_unique();
|
||||
let nonce_account = Rc::new(nonce_account::create_account(1_000_000));
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(Pubkey::default())).unwrap(),
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(nonce_address)).unwrap(),
|
||||
&[
|
||||
(true, false, Pubkey::default(), nonce_account.clone()),
|
||||
(true, true, nonce_address, nonce_account.clone()),
|
||||
(
|
||||
false,
|
||||
false,
|
||||
@@ -1569,7 +1571,7 @@ mod tests {
|
||||
#[allow(deprecated)]
|
||||
let blockhash_id = sysvar::recent_blockhashes::id();
|
||||
let keyed_accounts = [
|
||||
(true, false, Pubkey::default(), nonce_account),
|
||||
(true, true, nonce_address, nonce_account),
|
||||
(false, false, blockhash_id, new_recent_blockhashes_account),
|
||||
];
|
||||
assert_eq!(
|
||||
@@ -1595,11 +1597,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_process_withdraw_ix_no_acc_data_fail() {
|
||||
let nonce_address = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
process_nonce_instruction(&system_instruction::withdraw_nonce_account(
|
||||
&Pubkey::default(),
|
||||
&Pubkey::default(),
|
||||
&Pubkey::default(),
|
||||
&nonce_address,
|
||||
&Pubkey::new_unique(),
|
||||
&nonce_address,
|
||||
1,
|
||||
)),
|
||||
Err(InstructionError::InvalidAccountData),
|
||||
@@ -1684,8 +1687,8 @@ mod tests {
|
||||
&[
|
||||
(
|
||||
true,
|
||||
false,
|
||||
Pubkey::default(),
|
||||
true,
|
||||
Pubkey::new_unique(),
|
||||
Rc::new(nonce_account::create_account(1_000_000)),
|
||||
),
|
||||
(true, false, Pubkey::default(), create_default_account()),
|
||||
@@ -1788,14 +1791,15 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_process_initialize_ix_ok() {
|
||||
let nonce_address = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(Pubkey::default())).unwrap(),
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(nonce_address)).unwrap(),
|
||||
&[
|
||||
(
|
||||
true,
|
||||
false,
|
||||
Pubkey::default(),
|
||||
true,
|
||||
nonce_address,
|
||||
Rc::new(nonce_account::create_account(1_000_000)),
|
||||
),
|
||||
(
|
||||
@@ -1819,11 +1823,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_process_authorize_ix_ok() {
|
||||
let nonce_address = Pubkey::new_unique();
|
||||
let nonce_account = Rc::new(nonce_account::create_account(1_000_000));
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(Pubkey::default())).unwrap(),
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(nonce_address)).unwrap(),
|
||||
&[
|
||||
(true, false, Pubkey::default(), nonce_account.clone()),
|
||||
(true, true, nonce_address, nonce_account.clone()),
|
||||
(
|
||||
false,
|
||||
false,
|
||||
@@ -1842,8 +1847,8 @@ mod tests {
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::AuthorizeNonceAccount(Pubkey::default())).unwrap(),
|
||||
&[(true, false, Pubkey::default(), nonce_account)],
|
||||
&serialize(&SystemInstruction::AuthorizeNonceAccount(nonce_address)).unwrap(),
|
||||
&[(true, true, nonce_address, nonce_account)],
|
||||
),
|
||||
Ok(()),
|
||||
);
|
||||
@@ -1851,11 +1856,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_process_authorize_bad_account_data_fail() {
|
||||
let nonce_address = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
process_nonce_instruction(&system_instruction::authorize_nonce_account(
|
||||
&Pubkey::default(),
|
||||
&Pubkey::default(),
|
||||
&Pubkey::default(),
|
||||
&nonce_address,
|
||||
&Pubkey::new_unique(),
|
||||
&nonce_address,
|
||||
)),
|
||||
Err(InstructionError::InvalidAccountData),
|
||||
);
|
||||
@@ -1916,6 +1922,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_nonce_initialize_with_empty_recent_blockhashes_fail() {
|
||||
let nonce_address = Pubkey::new_unique();
|
||||
let nonce_account = Rc::new(nonce_account::create_account(1_000_000));
|
||||
#[allow(deprecated)]
|
||||
let new_recent_blockhashes_account = Rc::new(RefCell::new(
|
||||
@@ -1925,9 +1932,9 @@ mod tests {
|
||||
));
|
||||
assert_eq!(
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(Pubkey::default())).unwrap(),
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(nonce_address)).unwrap(),
|
||||
&[
|
||||
(true, false, Pubkey::default(), nonce_account),
|
||||
(true, true, nonce_address, nonce_account),
|
||||
(
|
||||
false,
|
||||
false,
|
||||
@@ -1949,11 +1956,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_nonce_advance_with_empty_recent_blockhashes_fail() {
|
||||
let nonce_address = Pubkey::new_unique();
|
||||
let nonce_account = Rc::new(nonce_account::create_account(1_000_000));
|
||||
process_instruction(
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(Pubkey::default())).unwrap(),
|
||||
&serialize(&SystemInstruction::InitializeNonceAccount(nonce_address)).unwrap(),
|
||||
&[
|
||||
(true, false, Pubkey::default(), nonce_account.clone()),
|
||||
(true, true, nonce_address, nonce_account.clone()),
|
||||
(
|
||||
false,
|
||||
false,
|
||||
@@ -1979,7 +1987,7 @@ mod tests {
|
||||
#[allow(deprecated)]
|
||||
let blockhash_id = sysvar::recent_blockhashes::id();
|
||||
let keyed_accounts = [
|
||||
(true, false, Pubkey::default(), nonce_account),
|
||||
(true, false, nonce_address, nonce_account),
|
||||
(false, false, blockhash_id, new_recent_blockhashes_account),
|
||||
];
|
||||
assert_eq!(
|
||||
|
Reference in New Issue
Block a user