require to
account signature (#6658)
* require to signature * fixing invocation to create_account * fix create_account references * address review comment * whacking bugs in tests * fixing stake program tests
This commit is contained in:
@ -534,6 +534,7 @@ pub mod tests {
|
||||
};
|
||||
use matches::assert_matches;
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::account::Account;
|
||||
use solana_sdk::{
|
||||
epoch_schedule::EpochSchedule,
|
||||
hash::Hash,
|
||||
@ -1576,6 +1577,10 @@ pub mod tests {
|
||||
}
|
||||
let mut hash = bank.last_blockhash();
|
||||
|
||||
let present_account_key = Keypair::new();
|
||||
let present_account = Account::new(1, 10, &Pubkey::default());
|
||||
bank.store_account(&present_account_key.pubkey(), &present_account);
|
||||
|
||||
let entries: Vec<_> = (0..NUM_TRANSFERS)
|
||||
.step_by(NUM_TRANSFERS_PER_ENTRY)
|
||||
.map(|i| {
|
||||
@ -1592,7 +1597,7 @@ pub mod tests {
|
||||
|
||||
transactions.push(system_transaction::create_account(
|
||||
&mint_keypair,
|
||||
&solana_sdk::sysvar::clock::id(), // puts a TX error in results
|
||||
&present_account_key, // puts a TX error in results
|
||||
bank.last_blockhash(),
|
||||
1,
|
||||
0,
|
||||
@ -1926,6 +1931,10 @@ pub mod tests {
|
||||
.expect("funding failed");
|
||||
}
|
||||
|
||||
let present_account_key = Keypair::new();
|
||||
let present_account = Account::new(1, 10, &Pubkey::default());
|
||||
bank.store_account(&present_account_key.pubkey(), &present_account);
|
||||
|
||||
let mut i = 0;
|
||||
let mut hash = bank.last_blockhash();
|
||||
let mut root: Option<Arc<Bank>> = None;
|
||||
@ -1947,7 +1956,7 @@ pub mod tests {
|
||||
|
||||
transactions.push(system_transaction::create_account(
|
||||
&mint_keypair,
|
||||
&solana_sdk::sysvar::clock::id(), // puts a TX error in results
|
||||
&present_account_key, // puts a TX error in results
|
||||
bank.last_blockhash(),
|
||||
100,
|
||||
100,
|
||||
|
@ -402,8 +402,10 @@ mod tests {
|
||||
|
||||
fn create_sample_payment(keypair: &Keypair, hash: Hash) -> Transaction {
|
||||
let pubkey = keypair.pubkey();
|
||||
let ixs = budget_instruction::payment(&pubkey, &pubkey, 1);
|
||||
Transaction::new_signed_instructions(&[keypair], ixs, hash)
|
||||
let budget_contract = Keypair::new();
|
||||
let budget_pubkey = budget_contract.pubkey();
|
||||
let ixs = budget_instruction::payment(&pubkey, &pubkey, &budget_pubkey, 1);
|
||||
Transaction::new_signed_instructions(&[keypair, &budget_contract], ixs, hash)
|
||||
}
|
||||
|
||||
fn create_sample_timestamp(keypair: &Keypair, hash: Hash) -> Transaction {
|
||||
|
@ -247,6 +247,7 @@ mod tests {
|
||||
EpochSchedule, DEFAULT_LEADER_SCHEDULE_SLOT_OFFSET, DEFAULT_SLOTS_PER_EPOCH,
|
||||
MINIMUM_SLOTS_PER_EPOCH,
|
||||
};
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use std::{sync::mpsc::channel, sync::Arc, thread::Builder};
|
||||
|
||||
#[test]
|
||||
@ -496,11 +497,11 @@ mod tests {
|
||||
|
||||
// Create new vote account
|
||||
let node_pubkey = Pubkey::new_rand();
|
||||
let vote_pubkey = Pubkey::new_rand();
|
||||
let vote_account = Keypair::new();
|
||||
setup_vote_and_stake_accounts(
|
||||
&bank,
|
||||
&mint_keypair,
|
||||
&vote_pubkey,
|
||||
&vote_account,
|
||||
&node_pubkey,
|
||||
BOOTSTRAP_LEADER_LAMPORTS,
|
||||
);
|
||||
|
@ -88,7 +88,7 @@ where
|
||||
// Find if any slot has achieved sufficient votes for supermajority lockout
|
||||
let mut total = 0;
|
||||
for (stake, slot) in stakes_and_lockouts {
|
||||
total += stake;
|
||||
total += *stake;
|
||||
if total > supermajority_stake {
|
||||
return Some(slot);
|
||||
}
|
||||
@ -125,10 +125,11 @@ pub(crate) mod tests {
|
||||
pub(crate) fn setup_vote_and_stake_accounts(
|
||||
bank: &Bank,
|
||||
from_account: &Keypair,
|
||||
vote_pubkey: &Pubkey,
|
||||
vote_account: &Keypair,
|
||||
node_pubkey: &Pubkey,
|
||||
amount: u64,
|
||||
) {
|
||||
let vote_pubkey = vote_account.pubkey();
|
||||
fn process_instructions<T: KeypairUtil>(
|
||||
bank: &Bank,
|
||||
keypairs: &[&T],
|
||||
@ -145,14 +146,14 @@ pub(crate) mod tests {
|
||||
|
||||
process_instructions(
|
||||
bank,
|
||||
&[from_account],
|
||||
&[from_account, vote_account],
|
||||
vote_instruction::create_account(
|
||||
&from_account.pubkey(),
|
||||
vote_pubkey,
|
||||
&vote_pubkey,
|
||||
&VoteInit {
|
||||
node_pubkey: *node_pubkey,
|
||||
authorized_voter: *vote_pubkey,
|
||||
authorized_withdrawer: *vote_pubkey,
|
||||
authorized_voter: vote_pubkey,
|
||||
authorized_withdrawer: vote_pubkey,
|
||||
commission: 0,
|
||||
},
|
||||
amount,
|
||||
@ -168,7 +169,7 @@ pub(crate) mod tests {
|
||||
stake_instruction::create_stake_account_and_delegate_stake(
|
||||
&from_account.pubkey(),
|
||||
&stake_account_pubkey,
|
||||
vote_pubkey,
|
||||
&vote_pubkey,
|
||||
&Authorized::auto(&stake_account_pubkey),
|
||||
amount,
|
||||
),
|
||||
@ -193,7 +194,7 @@ pub(crate) mod tests {
|
||||
} = create_genesis_block(10_000);
|
||||
|
||||
let bank = Bank::new(&genesis_block);
|
||||
let vote_pubkey = Pubkey::new_rand();
|
||||
let vote_account = Keypair::new();
|
||||
|
||||
// Give the validator some stake but don't setup a staking account
|
||||
// Validator has no lamports staked, so they get filtered out. Only the bootstrap leader
|
||||
@ -206,7 +207,7 @@ pub(crate) mod tests {
|
||||
setup_vote_and_stake_accounts(
|
||||
&bank,
|
||||
&mint_keypair,
|
||||
&vote_pubkey,
|
||||
&vote_account,
|
||||
&mint_keypair.pubkey(),
|
||||
stake,
|
||||
);
|
||||
|
Reference in New Issue
Block a user