2019-12-07 12:54:10 -07:00
|
|
|
use solana_sdk::{
|
2020-01-10 16:57:31 -07:00
|
|
|
account::Account,
|
2020-01-22 17:54:06 -08:00
|
|
|
account_utils::StateMut,
|
2020-03-05 07:40:26 -07:00
|
|
|
fee_calculator::FeeCalculator,
|
2020-01-10 16:57:31 -07:00
|
|
|
hash::Hash,
|
|
|
|
instruction::CompiledInstruction,
|
2020-03-04 09:51:48 -07:00
|
|
|
nonce::{self, state::Versions, State},
|
2020-02-05 12:48:30 -08:00
|
|
|
program_utils::limited_deserialize,
|
2020-01-10 16:57:31 -07:00
|
|
|
pubkey::Pubkey,
|
|
|
|
system_instruction::SystemInstruction,
|
|
|
|
system_program,
|
|
|
|
transaction::{self, Transaction},
|
2019-12-07 12:54:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
pub fn transaction_uses_durable_nonce(tx: &Transaction) -> Option<&CompiledInstruction> {
|
|
|
|
let message = tx.message();
|
|
|
|
message
|
|
|
|
.instructions
|
|
|
|
.get(0)
|
|
|
|
.filter(|maybe_ix| {
|
|
|
|
let prog_id_idx = maybe_ix.program_id_index as usize;
|
|
|
|
match message.account_keys.get(prog_id_idx) {
|
2020-01-03 19:34:58 -05:00
|
|
|
Some(program_id) => system_program::check_id(&program_id),
|
2019-12-07 12:54:10 -07:00
|
|
|
_ => false,
|
|
|
|
}
|
2020-08-01 08:44:32 -07:00
|
|
|
} && matches!(limited_deserialize(&maybe_ix.data), Ok(SystemInstruction::AdvanceNonceAccount))
|
|
|
|
)
|
2019-12-07 12:54:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_nonce_pubkey_from_instruction<'a>(
|
|
|
|
ix: &CompiledInstruction,
|
|
|
|
tx: &'a Transaction,
|
|
|
|
) -> Option<&'a Pubkey> {
|
|
|
|
ix.accounts.get(0).and_then(|idx| {
|
|
|
|
let idx = *idx as usize;
|
|
|
|
tx.message().account_keys.get(idx)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-22 16:31:39 -07:00
|
|
|
pub fn verify_nonce_account(acc: &Account, hash: &Hash) -> bool {
|
2020-03-03 19:39:09 -07:00
|
|
|
match StateMut::<Versions>::state(acc).map(|v| v.convert_to_current()) {
|
2020-03-04 09:51:48 -07:00
|
|
|
Ok(State::Initialized(ref data)) => *hash == data.blockhash,
|
2019-12-07 12:54:10 -07:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-10 16:57:31 -07:00
|
|
|
pub fn prepare_if_nonce_account(
|
|
|
|
account: &mut Account,
|
|
|
|
account_pubkey: &Pubkey,
|
|
|
|
tx_result: &transaction::Result<()>,
|
|
|
|
maybe_nonce: Option<(&Pubkey, &Account)>,
|
2020-07-09 14:22:21 -06:00
|
|
|
last_blockhash_with_fee_calculator: &(Hash, FeeCalculator),
|
2020-07-15 15:45:30 -06:00
|
|
|
fix_recent_blockhashes_sysvar_delay: bool,
|
2020-01-10 16:57:31 -07:00
|
|
|
) {
|
|
|
|
if let Some((nonce_key, nonce_acc)) = maybe_nonce {
|
|
|
|
if account_pubkey == nonce_key {
|
2020-07-15 15:45:30 -06:00
|
|
|
let overwrite = if tx_result.is_err() {
|
|
|
|
// Nonce TX failed with an InstructionError. Roll back
|
|
|
|
// its account state
|
2020-07-09 14:22:21 -06:00
|
|
|
*account = nonce_acc.clone();
|
2020-07-15 15:45:30 -06:00
|
|
|
true
|
|
|
|
} else {
|
|
|
|
// Retain overwrite on successful transactions until
|
|
|
|
// recent_blockhashes_sysvar_delay fix is activated
|
|
|
|
!fix_recent_blockhashes_sysvar_delay
|
|
|
|
};
|
|
|
|
if overwrite {
|
2020-07-09 14:22:21 -06:00
|
|
|
// Since hash_age_kind is DurableNonce, unwrap is safe here
|
|
|
|
let state = StateMut::<Versions>::state(nonce_acc)
|
|
|
|
.unwrap()
|
|
|
|
.convert_to_current();
|
|
|
|
if let State::Initialized(ref data) = state {
|
|
|
|
let new_data = Versions::new_current(State::Initialized(nonce::state::Data {
|
|
|
|
blockhash: last_blockhash_with_fee_calculator.0,
|
|
|
|
fee_calculator: last_blockhash_with_fee_calculator.1.clone(),
|
|
|
|
..data.clone()
|
|
|
|
}));
|
|
|
|
account.set_state(&new_data).unwrap();
|
|
|
|
}
|
2020-01-10 16:57:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-05 07:40:26 -07:00
|
|
|
pub fn fee_calculator_of(account: &Account) -> Option<FeeCalculator> {
|
|
|
|
let state = StateMut::<Versions>::state(account)
|
|
|
|
.ok()?
|
|
|
|
.convert_to_current();
|
|
|
|
match state {
|
|
|
|
State::Initialized(data) => Some(data.fee_calculator),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-07 12:54:10 -07:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
use solana_sdk::{
|
2020-01-10 16:57:31 -07:00
|
|
|
account::Account,
|
2020-03-03 18:00:39 -07:00
|
|
|
account_utils::State as AccountUtilsState,
|
2019-12-07 12:54:10 -07:00
|
|
|
hash::Hash,
|
2020-01-10 16:57:31 -07:00
|
|
|
instruction::InstructionError,
|
2020-06-24 14:52:38 -06:00
|
|
|
message::Message,
|
2020-03-04 09:51:48 -07:00
|
|
|
nonce::{self, account::with_test_keyed_account, Account as NonceAccount, State},
|
2019-12-07 12:54:10 -07:00
|
|
|
pubkey::Pubkey,
|
2020-02-20 14:28:55 -07:00
|
|
|
signature::{Keypair, Signer},
|
2019-12-07 12:54:10 -07:00
|
|
|
system_instruction,
|
|
|
|
sysvar::{recent_blockhashes::create_test_recent_blockhashes, rent::Rent},
|
|
|
|
};
|
|
|
|
use std::collections::HashSet;
|
|
|
|
|
|
|
|
fn nonced_transfer_tx() -> (Pubkey, Pubkey, Transaction) {
|
|
|
|
let from_keypair = Keypair::new();
|
|
|
|
let from_pubkey = from_keypair.pubkey();
|
|
|
|
let nonce_keypair = Keypair::new();
|
|
|
|
let nonce_pubkey = nonce_keypair.pubkey();
|
2020-06-24 14:52:38 -06:00
|
|
|
let instructions = [
|
|
|
|
system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
|
|
|
|
system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42),
|
|
|
|
];
|
|
|
|
let message = Message::new(&instructions, Some(&nonce_pubkey));
|
|
|
|
let tx = Transaction::new(&[&from_keypair, &nonce_keypair], message, Hash::default());
|
2019-12-07 12:54:10 -07:00
|
|
|
(from_pubkey, nonce_pubkey, tx)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn tx_uses_nonce_ok() {
|
|
|
|
let (_, _, tx) = nonced_transfer_tx();
|
|
|
|
assert!(transaction_uses_durable_nonce(&tx).is_some());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn tx_uses_nonce_empty_ix_fail() {
|
2020-05-15 13:23:09 -06:00
|
|
|
assert!(transaction_uses_durable_nonce(&Transaction::default()).is_none());
|
2019-12-07 12:54:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn tx_uses_nonce_bad_prog_id_idx_fail() {
|
|
|
|
let (_, _, mut tx) = nonced_transfer_tx();
|
|
|
|
tx.message.instructions.get_mut(0).unwrap().program_id_index = 255u8;
|
|
|
|
assert!(transaction_uses_durable_nonce(&tx).is_none());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn tx_uses_nonce_first_prog_id_not_nonce_fail() {
|
|
|
|
let from_keypair = Keypair::new();
|
|
|
|
let from_pubkey = from_keypair.pubkey();
|
|
|
|
let nonce_keypair = Keypair::new();
|
|
|
|
let nonce_pubkey = nonce_keypair.pubkey();
|
2020-06-24 14:52:38 -06:00
|
|
|
let instructions = [
|
|
|
|
system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42),
|
|
|
|
system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
|
|
|
|
];
|
|
|
|
let message = Message::new(&instructions, Some(&from_pubkey));
|
|
|
|
let tx = Transaction::new(&[&from_keypair, &nonce_keypair], message, Hash::default());
|
2019-12-07 12:54:10 -07:00
|
|
|
assert!(transaction_uses_durable_nonce(&tx).is_none());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn tx_uses_nonce_wrong_first_nonce_ix_fail() {
|
|
|
|
let from_keypair = Keypair::new();
|
|
|
|
let from_pubkey = from_keypair.pubkey();
|
|
|
|
let nonce_keypair = Keypair::new();
|
|
|
|
let nonce_pubkey = nonce_keypair.pubkey();
|
2020-06-24 14:52:38 -06:00
|
|
|
let instructions = [
|
|
|
|
system_instruction::withdraw_nonce_account(
|
|
|
|
&nonce_pubkey,
|
|
|
|
&nonce_pubkey,
|
|
|
|
&from_pubkey,
|
|
|
|
42,
|
|
|
|
),
|
|
|
|
system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42),
|
|
|
|
];
|
|
|
|
let message = Message::new(&instructions, Some(&nonce_pubkey));
|
|
|
|
let tx = Transaction::new(&[&from_keypair, &nonce_keypair], message, Hash::default());
|
2019-12-07 12:54:10 -07:00
|
|
|
assert!(transaction_uses_durable_nonce(&tx).is_none());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_nonce_pub_from_ix_ok() {
|
|
|
|
let (_, nonce_pubkey, tx) = nonced_transfer_tx();
|
|
|
|
let nonce_ix = transaction_uses_durable_nonce(&tx).unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
get_nonce_pubkey_from_instruction(&nonce_ix, &tx),
|
|
|
|
Some(&nonce_pubkey),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_nonce_pub_from_ix_no_accounts_fail() {
|
|
|
|
let (_, _, tx) = nonced_transfer_tx();
|
|
|
|
let nonce_ix = transaction_uses_durable_nonce(&tx).unwrap();
|
|
|
|
let mut nonce_ix = nonce_ix.clone();
|
|
|
|
nonce_ix.accounts.clear();
|
|
|
|
assert_eq!(get_nonce_pubkey_from_instruction(&nonce_ix, &tx), None,);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_nonce_pub_from_ix_bad_acc_idx_fail() {
|
|
|
|
let (_, _, tx) = nonced_transfer_tx();
|
|
|
|
let nonce_ix = transaction_uses_durable_nonce(&tx).unwrap();
|
|
|
|
let mut nonce_ix = nonce_ix.clone();
|
|
|
|
nonce_ix.accounts[0] = 255u8;
|
|
|
|
assert_eq!(get_nonce_pubkey_from_instruction(&nonce_ix, &tx), None,);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn verify_nonce_ok() {
|
|
|
|
with_test_keyed_account(42, true, |nonce_account| {
|
|
|
|
let mut signers = HashSet::new();
|
2020-06-09 01:38:14 +01:00
|
|
|
signers.insert(nonce_account.signer_key().unwrap());
|
2020-03-03 18:00:39 -07:00
|
|
|
let state: State = nonce_account.state().unwrap();
|
2019-12-07 12:54:10 -07:00
|
|
|
// New is in Uninitialzed state
|
2020-03-03 18:00:39 -07:00
|
|
|
assert_eq!(state, State::Uninitialized);
|
2019-12-07 12:54:10 -07:00
|
|
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
2020-05-15 17:35:43 +01:00
|
|
|
let authorized = nonce_account.unsigned_key();
|
2019-12-07 12:54:10 -07:00
|
|
|
nonce_account
|
2020-01-22 16:31:39 -07:00
|
|
|
.initialize_nonce_account(&authorized, &recent_blockhashes, &Rent::free())
|
2019-12-07 12:54:10 -07:00
|
|
|
.unwrap();
|
2020-01-22 16:31:39 -07:00
|
|
|
assert!(verify_nonce_account(
|
2020-01-22 09:11:56 -08:00
|
|
|
&nonce_account.account.borrow(),
|
2020-03-04 12:01:32 -07:00
|
|
|
&recent_blockhashes[0].blockhash,
|
2020-01-22 09:11:56 -08:00
|
|
|
));
|
2019-12-07 12:54:10 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn verify_nonce_bad_acc_state_fail() {
|
|
|
|
with_test_keyed_account(42, true, |nonce_account| {
|
2020-01-22 16:31:39 -07:00
|
|
|
assert!(!verify_nonce_account(
|
2020-01-22 09:11:56 -08:00
|
|
|
&nonce_account.account.borrow(),
|
|
|
|
&Hash::default()
|
|
|
|
));
|
2019-12-07 12:54:10 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn verify_nonce_bad_query_hash_fail() {
|
|
|
|
with_test_keyed_account(42, true, |nonce_account| {
|
|
|
|
let mut signers = HashSet::new();
|
2020-06-09 01:38:14 +01:00
|
|
|
signers.insert(nonce_account.signer_key().unwrap());
|
2020-03-03 18:00:39 -07:00
|
|
|
let state: State = nonce_account.state().unwrap();
|
2019-12-07 12:54:10 -07:00
|
|
|
// New is in Uninitialzed state
|
2020-03-03 18:00:39 -07:00
|
|
|
assert_eq!(state, State::Uninitialized);
|
2019-12-07 12:54:10 -07:00
|
|
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
2020-05-15 17:35:43 +01:00
|
|
|
let authorized = nonce_account.unsigned_key();
|
2019-12-07 12:54:10 -07:00
|
|
|
nonce_account
|
2020-01-22 16:31:39 -07:00
|
|
|
.initialize_nonce_account(&authorized, &recent_blockhashes, &Rent::free())
|
2019-12-07 12:54:10 -07:00
|
|
|
.unwrap();
|
2020-01-22 16:31:39 -07:00
|
|
|
assert!(!verify_nonce_account(
|
2020-01-22 09:11:56 -08:00
|
|
|
&nonce_account.account.borrow(),
|
2020-03-04 12:01:32 -07:00
|
|
|
&recent_blockhashes[1].blockhash,
|
2019-12-07 12:54:10 -07:00
|
|
|
));
|
|
|
|
});
|
|
|
|
}
|
2020-01-10 16:57:31 -07:00
|
|
|
|
2020-07-09 14:22:21 -06:00
|
|
|
fn create_accounts_prepare_if_nonce_account() -> (Pubkey, Account, Account, Hash, FeeCalculator)
|
|
|
|
{
|
2020-03-05 07:40:26 -07:00
|
|
|
let data = Versions::new_current(State::Initialized(nonce::state::Data::default()));
|
2020-03-03 19:39:09 -07:00
|
|
|
let account = Account::new_data(42, &data, &system_program::id()).unwrap();
|
2020-01-10 16:57:31 -07:00
|
|
|
let pre_account = Account {
|
|
|
|
lamports: 43,
|
|
|
|
..account.clone()
|
|
|
|
};
|
|
|
|
(
|
|
|
|
Pubkey::default(),
|
|
|
|
pre_account,
|
|
|
|
account,
|
|
|
|
Hash::new(&[1u8; 32]),
|
2020-07-09 14:22:21 -06:00
|
|
|
FeeCalculator {
|
|
|
|
lamports_per_signature: 1234,
|
|
|
|
},
|
2020-01-10 16:57:31 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_prepare_if_nonce_account_test(
|
|
|
|
account: &mut Account,
|
|
|
|
account_pubkey: &Pubkey,
|
|
|
|
tx_result: &transaction::Result<()>,
|
|
|
|
maybe_nonce: Option<(&Pubkey, &Account)>,
|
2020-07-09 14:22:21 -06:00
|
|
|
last_blockhash_with_fee_calculator: &(Hash, FeeCalculator),
|
2020-01-10 16:57:31 -07:00
|
|
|
expect_account: &Account,
|
|
|
|
) -> bool {
|
|
|
|
// Verify expect_account's relationship
|
|
|
|
match maybe_nonce {
|
|
|
|
Some((nonce_pubkey, _nonce_account))
|
|
|
|
if nonce_pubkey == account_pubkey && tx_result.is_ok() =>
|
|
|
|
{
|
2020-07-09 14:22:21 -06:00
|
|
|
assert_eq!(expect_account, account) // Account update occurs in system_instruction_processor
|
2020-01-10 16:57:31 -07:00
|
|
|
}
|
|
|
|
Some((nonce_pubkey, nonce_account)) if nonce_pubkey == account_pubkey => {
|
|
|
|
assert_ne!(expect_account, nonce_account)
|
|
|
|
}
|
|
|
|
_ => assert_eq!(expect_account, account),
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_if_nonce_account(
|
|
|
|
account,
|
|
|
|
account_pubkey,
|
|
|
|
tx_result,
|
|
|
|
maybe_nonce,
|
2020-07-09 14:22:21 -06:00
|
|
|
last_blockhash_with_fee_calculator,
|
2020-07-15 15:45:30 -06:00
|
|
|
true,
|
2020-01-10 16:57:31 -07:00
|
|
|
);
|
|
|
|
expect_account == account
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_prepare_if_nonce_account_expected() {
|
2020-07-09 14:22:21 -06:00
|
|
|
let (
|
|
|
|
pre_account_pubkey,
|
|
|
|
pre_account,
|
|
|
|
mut post_account,
|
|
|
|
last_blockhash,
|
|
|
|
last_fee_calculator,
|
|
|
|
) = create_accounts_prepare_if_nonce_account();
|
2020-01-10 16:57:31 -07:00
|
|
|
let post_account_pubkey = pre_account_pubkey;
|
|
|
|
|
|
|
|
let mut expect_account = post_account.clone();
|
2020-07-09 14:22:21 -06:00
|
|
|
let data = Versions::new_current(State::Initialized(nonce::state::Data::default()));
|
2020-03-03 19:39:09 -07:00
|
|
|
expect_account.set_state(&data).unwrap();
|
2020-01-10 16:57:31 -07:00
|
|
|
|
|
|
|
assert!(run_prepare_if_nonce_account_test(
|
|
|
|
&mut post_account,
|
|
|
|
&post_account_pubkey,
|
|
|
|
&Ok(()),
|
|
|
|
Some((&pre_account_pubkey, &pre_account)),
|
2020-07-09 14:22:21 -06:00
|
|
|
&(last_blockhash, last_fee_calculator),
|
2020-01-10 16:57:31 -07:00
|
|
|
&expect_account,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_prepare_if_nonce_account_not_nonce_tx() {
|
2020-07-09 14:22:21 -06:00
|
|
|
let (pre_account_pubkey, _pre_account, _post_account, last_blockhash, last_fee_calculator) =
|
2020-01-10 16:57:31 -07:00
|
|
|
create_accounts_prepare_if_nonce_account();
|
|
|
|
let post_account_pubkey = pre_account_pubkey;
|
|
|
|
|
|
|
|
let mut post_account = Account::default();
|
|
|
|
let expect_account = post_account.clone();
|
|
|
|
assert!(run_prepare_if_nonce_account_test(
|
|
|
|
&mut post_account,
|
|
|
|
&post_account_pubkey,
|
|
|
|
&Ok(()),
|
|
|
|
None,
|
2020-07-09 14:22:21 -06:00
|
|
|
&(last_blockhash, last_fee_calculator),
|
2020-01-10 16:57:31 -07:00
|
|
|
&expect_account,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-07-09 14:22:21 -06:00
|
|
|
fn test_prepare_if_nonce_account_not_nonce_pubkey() {
|
|
|
|
let (
|
|
|
|
pre_account_pubkey,
|
|
|
|
pre_account,
|
|
|
|
mut post_account,
|
|
|
|
last_blockhash,
|
|
|
|
last_fee_calculator,
|
|
|
|
) = create_accounts_prepare_if_nonce_account();
|
2020-01-10 16:57:31 -07:00
|
|
|
|
|
|
|
let expect_account = post_account.clone();
|
|
|
|
// Wrong key
|
|
|
|
assert!(run_prepare_if_nonce_account_test(
|
|
|
|
&mut post_account,
|
|
|
|
&Pubkey::new(&[1u8; 32]),
|
|
|
|
&Ok(()),
|
|
|
|
Some((&pre_account_pubkey, &pre_account)),
|
2020-07-09 14:22:21 -06:00
|
|
|
&(last_blockhash, last_fee_calculator),
|
2020-01-10 16:57:31 -07:00
|
|
|
&expect_account,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_prepare_if_nonce_account_tx_error() {
|
2020-07-09 14:22:21 -06:00
|
|
|
let (
|
|
|
|
pre_account_pubkey,
|
|
|
|
pre_account,
|
|
|
|
mut post_account,
|
|
|
|
last_blockhash,
|
|
|
|
last_fee_calculator,
|
|
|
|
) = create_accounts_prepare_if_nonce_account();
|
2020-01-10 16:57:31 -07:00
|
|
|
let post_account_pubkey = pre_account_pubkey;
|
|
|
|
|
|
|
|
let mut expect_account = pre_account.clone();
|
|
|
|
expect_account
|
2020-03-03 19:39:09 -07:00
|
|
|
.set_state(&Versions::new_current(State::Initialized(
|
2020-03-04 09:51:48 -07:00
|
|
|
nonce::state::Data {
|
|
|
|
blockhash: last_blockhash,
|
2020-07-09 14:22:21 -06:00
|
|
|
fee_calculator: last_fee_calculator.clone(),
|
2020-03-05 07:40:26 -07:00
|
|
|
..nonce::state::Data::default()
|
2020-03-04 09:51:48 -07:00
|
|
|
},
|
2020-03-03 19:39:09 -07:00
|
|
|
)))
|
2020-01-10 16:57:31 -07:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(run_prepare_if_nonce_account_test(
|
|
|
|
&mut post_account,
|
|
|
|
&post_account_pubkey,
|
|
|
|
&Err(transaction::TransactionError::InstructionError(
|
|
|
|
0,
|
2020-05-15 17:35:43 +01:00
|
|
|
InstructionError::InvalidArgument,
|
2020-01-10 16:57:31 -07:00
|
|
|
)),
|
|
|
|
Some((&pre_account_pubkey, &pre_account)),
|
2020-07-09 14:22:21 -06:00
|
|
|
&(last_blockhash, last_fee_calculator),
|
2020-01-10 16:57:31 -07:00
|
|
|
&expect_account,
|
|
|
|
));
|
|
|
|
}
|
2019-12-07 12:54:10 -07:00
|
|
|
}
|