Rename tokens to lamports in core/
This commit is contained in:
parent
53f09c44f3
commit
f1d1852691
|
@ -491,7 +491,7 @@ mod tests {
|
||||||
poh_recorder.lock().unwrap().set_bank(&bank);
|
poh_recorder.lock().unwrap().set_bank(&bank);
|
||||||
let _banking_stage = BankingStage::new(&cluster_info, &poh_recorder, verified_receiver);
|
let _banking_stage = BankingStage::new(&cluster_info, &poh_recorder, verified_receiver);
|
||||||
|
|
||||||
// Process a batch that includes a transaction that receives two tokens.
|
// Process a batch that includes a transaction that receives two lamports.
|
||||||
let alice = Keypair::new();
|
let alice = Keypair::new();
|
||||||
let tx = SystemTransaction::new_account(
|
let tx = SystemTransaction::new_account(
|
||||||
&mint_keypair,
|
&mint_keypair,
|
||||||
|
@ -506,7 +506,7 @@ mod tests {
|
||||||
.send(vec![(packets[0].clone(), vec![1u8])])
|
.send(vec![(packets[0].clone(), vec![1u8])])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Process a second batch that spends one of those tokens.
|
// Process a second batch that spends one of those lamports.
|
||||||
let tx = SystemTransaction::new_account(
|
let tx = SystemTransaction::new_account(
|
||||||
&alice,
|
&alice,
|
||||||
mint_keypair.pubkey(),
|
mint_keypair.pubkey(),
|
||||||
|
@ -532,7 +532,7 @@ mod tests {
|
||||||
// same assertion as running through the bank, really...
|
// same assertion as running through the bank, really...
|
||||||
assert!(entries.len() >= 2);
|
assert!(entries.len() >= 2);
|
||||||
|
|
||||||
// Assert the user holds one token, not two. If the stage only outputs one
|
// Assert the user holds one lamport, not two. If the stage only outputs one
|
||||||
// entry, then the second transaction will be rejected, because it drives
|
// entry, then the second transaction will be rejected, because it drives
|
||||||
// the account balance below zero before the credit is added.
|
// the account balance below zero before the credit is added.
|
||||||
let bank = Bank::new(&genesis_block);
|
let bank = Bank::new(&genesis_block);
|
||||||
|
|
|
@ -329,15 +329,15 @@ impl Service for Fullnode {
|
||||||
// leader selection, and append `num_ending_ticks` empty tick entries.
|
// leader selection, and append `num_ending_ticks` empty tick entries.
|
||||||
pub fn make_active_set_entries(
|
pub fn make_active_set_entries(
|
||||||
active_keypair: &Arc<Keypair>,
|
active_keypair: &Arc<Keypair>,
|
||||||
token_source: &Keypair,
|
lamport_source: &Keypair,
|
||||||
stake: u64,
|
stake: u64,
|
||||||
slot_to_vote_on: u64,
|
slot_to_vote_on: u64,
|
||||||
blockhash: &Hash,
|
blockhash: &Hash,
|
||||||
num_ending_ticks: u64,
|
num_ending_ticks: u64,
|
||||||
) -> (Vec<Entry>, Keypair) {
|
) -> (Vec<Entry>, Keypair) {
|
||||||
// 1) Assume the active_keypair node has no tokens staked
|
// 1) Assume the active_keypair node has no lamports staked
|
||||||
let transfer_tx = SystemTransaction::new_account(
|
let transfer_tx = SystemTransaction::new_account(
|
||||||
&token_source,
|
&lamport_source,
|
||||||
active_keypair.pubkey(),
|
active_keypair.pubkey(),
|
||||||
stake,
|
stake,
|
||||||
*blockhash,
|
*blockhash,
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl LocalCluster {
|
||||||
let ledger_path = tmp_copy_blocktree!(&genesis_ledger_path);
|
let ledger_path = tmp_copy_blocktree!(&genesis_ledger_path);
|
||||||
ledger_paths.push(ledger_path.clone());
|
ledger_paths.push(ledger_path.clone());
|
||||||
|
|
||||||
// Send each validator some tokens to vote
|
// Send each validator some lamports to vote
|
||||||
let validator_balance = Self::transfer(
|
let validator_balance = Self::transfer(
|
||||||
&mut client,
|
&mut client,
|
||||||
&mint_keypair,
|
&mint_keypair,
|
||||||
|
|
|
@ -214,7 +214,7 @@ impl Replicator {
|
||||||
|
|
||||||
let mut client = mk_client(&leader);
|
let mut client = mk_client(&leader);
|
||||||
|
|
||||||
Self::get_airdrop_tokens(&mut client, keypair, &leader_info);
|
Self::get_airdrop_lamports(&mut client, keypair, &leader_info);
|
||||||
info!("Done downloading ledger at {}", ledger_path);
|
info!("Done downloading ledger at {}", ledger_path);
|
||||||
|
|
||||||
let ledger_path = Path::new(ledger_path);
|
let ledger_path = Path::new(ledger_path);
|
||||||
|
@ -358,7 +358,7 @@ impl Replicator {
|
||||||
))?
|
))?
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_airdrop_tokens(client: &mut ThinClient, keypair: &Keypair, leader_info: &NodeInfo) {
|
fn get_airdrop_lamports(client: &mut ThinClient, keypair: &Keypair, leader_info: &NodeInfo) {
|
||||||
if retry_get_balance(client, &keypair.pubkey(), None).is_none() {
|
if retry_get_balance(client, &keypair.pubkey(), None).is_none() {
|
||||||
let mut drone_addr = leader_info.tpu;
|
let mut drone_addr = leader_info.tpu;
|
||||||
drone_addr.set_port(DRONE_PORT);
|
drone_addr.set_port(DRONE_PORT);
|
||||||
|
|
|
@ -97,10 +97,10 @@ impl RpcRequestHandler for MockRpcClient {
|
||||||
pub fn request_airdrop_transaction(
|
pub fn request_airdrop_transaction(
|
||||||
_drone_addr: &SocketAddr,
|
_drone_addr: &SocketAddr,
|
||||||
_id: &Pubkey,
|
_id: &Pubkey,
|
||||||
tokens: u64,
|
lamports: u64,
|
||||||
_blockhash: Hash,
|
_blockhash: Hash,
|
||||||
) -> Result<Transaction, Error> {
|
) -> Result<Transaction, Error> {
|
||||||
if tokens == 0 {
|
if lamports == 0 {
|
||||||
Err(Error::new(ErrorKind::Other, "Airdrop failed"))?
|
Err(Error::new(ErrorKind::Other, "Airdrop failed"))?
|
||||||
}
|
}
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
|
|
|
@ -152,9 +152,9 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bank_staked_nodes_at_epoch() {
|
fn test_bank_staked_nodes_at_epoch() {
|
||||||
let pubkey = Keypair::new().pubkey();
|
let pubkey = Keypair::new().pubkey();
|
||||||
let bootstrap_tokens = 3;
|
let bootstrap_lamports = 3;
|
||||||
let (genesis_block, _) =
|
let (genesis_block, _) =
|
||||||
GenesisBlock::new_with_leader(bootstrap_tokens, pubkey, bootstrap_tokens);
|
GenesisBlock::new_with_leader(bootstrap_lamports, pubkey, bootstrap_lamports);
|
||||||
let bank = Bank::new(&genesis_block);
|
let bank = Bank::new(&genesis_block);
|
||||||
|
|
||||||
// Epoch doesn't exist
|
// Epoch doesn't exist
|
||||||
|
@ -181,7 +181,7 @@ mod tests {
|
||||||
let bank_voter = Keypair::new();
|
let bank_voter = Keypair::new();
|
||||||
|
|
||||||
// Give the validator some stake but don't setup a staking account
|
// Give the validator some stake but don't setup a staking account
|
||||||
// Validator has no tokens staked, so they get filtered out. Only the bootstrap leader
|
// Validator has no lamports staked, so they get filtered out. Only the bootstrap leader
|
||||||
// created by the genesis block will get included
|
// created by the genesis block will get included
|
||||||
bank.transfer(1, &mint_keypair, validator.pubkey(), genesis_block.hash())
|
bank.transfer(1, &mint_keypair, validator.pubkey(), genesis_block.hash())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -106,11 +106,10 @@ pub mod tests {
|
||||||
from_keypair: &Keypair,
|
from_keypair: &Keypair,
|
||||||
voting_pubkey: &Pubkey,
|
voting_pubkey: &Pubkey,
|
||||||
bank: &Bank,
|
bank: &Bank,
|
||||||
num_tokens: u64,
|
lamports: u64,
|
||||||
) {
|
) {
|
||||||
let blockhash = bank.last_blockhash();
|
let blockhash = bank.last_blockhash();
|
||||||
let tx =
|
let tx = VoteTransaction::new_account(from_keypair, *voting_pubkey, blockhash, lamports, 0);
|
||||||
VoteTransaction::new_account(from_keypair, *voting_pubkey, blockhash, num_tokens, 0);
|
|
||||||
bank.process_transaction(&tx).unwrap();
|
bank.process_transaction(&tx).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,10 +123,10 @@ pub mod tests {
|
||||||
from_keypair: &Keypair,
|
from_keypair: &Keypair,
|
||||||
voting_keypair: &T,
|
voting_keypair: &T,
|
||||||
bank: &Bank,
|
bank: &Bank,
|
||||||
num_tokens: u64,
|
lamports: u64,
|
||||||
slot: u64,
|
slot: u64,
|
||||||
) {
|
) {
|
||||||
new_vote_account(from_keypair, &voting_keypair.pubkey(), bank, num_tokens);
|
new_vote_account(from_keypair, &voting_keypair.pubkey(), bank, lamports);
|
||||||
push_vote(voting_keypair, bank, slot);
|
push_vote(voting_keypair, bank, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue