credit_only credits forwarding (#6509)
* credit_only_credits_forwarding * whack transfer_now() * fixup * bench should retry the airdrop TX * fixup * try to make bench-exchange a bit more robust, informative
This commit is contained in:
@ -1096,21 +1096,21 @@ mod tests {
|
||||
// fund another account so we can send 2 good transactions in a single batch.
|
||||
let keypair = Keypair::new();
|
||||
let fund_tx =
|
||||
system_transaction::transfer_now(&mint_keypair, &keypair.pubkey(), 2, start_hash);
|
||||
system_transaction::transfer(&mint_keypair, &keypair.pubkey(), 2, start_hash);
|
||||
bank.process_transaction(&fund_tx).unwrap();
|
||||
|
||||
// good tx
|
||||
let to = Pubkey::new_rand();
|
||||
let tx = system_transaction::transfer_now(&mint_keypair, &to, 1, start_hash);
|
||||
let tx = system_transaction::transfer(&mint_keypair, &to, 1, start_hash);
|
||||
|
||||
// good tx, but no verify
|
||||
let to2 = Pubkey::new_rand();
|
||||
let tx_no_ver = system_transaction::transfer_now(&keypair, &to2, 2, start_hash);
|
||||
let tx_no_ver = system_transaction::transfer(&keypair, &to2, 2, start_hash);
|
||||
|
||||
// bad tx, AccountNotFound
|
||||
let keypair = Keypair::new();
|
||||
let to3 = Pubkey::new_rand();
|
||||
let tx_anf = system_transaction::transfer_now(&keypair, &to3, 1, start_hash);
|
||||
let tx_anf = system_transaction::transfer(&keypair, &to3, 1, start_hash);
|
||||
|
||||
// send 'em over
|
||||
let packets = to_packets(&[tx_no_ver, tx_anf, tx]);
|
||||
@ -1186,12 +1186,8 @@ mod tests {
|
||||
|
||||
// Process a batch that includes a transaction that receives two lamports.
|
||||
let alice = Keypair::new();
|
||||
let tx = system_transaction::transfer_now(
|
||||
&mint_keypair,
|
||||
&alice.pubkey(),
|
||||
2,
|
||||
genesis_block.hash(),
|
||||
);
|
||||
let tx =
|
||||
system_transaction::transfer(&mint_keypair, &alice.pubkey(), 2, genesis_block.hash());
|
||||
|
||||
let packets = to_packets(&[tx]);
|
||||
let packets = packets
|
||||
@ -1200,13 +1196,9 @@ mod tests {
|
||||
.collect();
|
||||
verified_sender.send(packets).unwrap();
|
||||
|
||||
// Process a second batch that spends one of those lamports.
|
||||
let tx = system_transaction::transfer_now(
|
||||
&alice,
|
||||
&mint_keypair.pubkey(),
|
||||
1,
|
||||
genesis_block.hash(),
|
||||
);
|
||||
// Process a second batch that uses the same from account, so conflicts with above TX
|
||||
let tx =
|
||||
system_transaction::transfer(&mint_keypair, &alice.pubkey(), 1, genesis_block.hash());
|
||||
let packets = to_packets(&[tx]);
|
||||
let packets = packets
|
||||
.into_iter()
|
||||
@ -1241,7 +1233,7 @@ mod tests {
|
||||
);
|
||||
|
||||
// wait for banking_stage to eat the packets
|
||||
while bank.get_balance(&alice.pubkey()) != 1 {
|
||||
while bank.get_balance(&alice.pubkey()) < 2 {
|
||||
sleep(Duration::from_millis(100));
|
||||
}
|
||||
exit.store(true, Ordering::Relaxed);
|
||||
@ -1265,10 +1257,10 @@ mod tests {
|
||||
.for_each(|x| assert_eq!(*x, Ok(())));
|
||||
}
|
||||
|
||||
// Assert the user holds one lamport, not two. If the stage only outputs one
|
||||
// Assert the user holds two lamports, not three. If the stage only outputs one
|
||||
// entry, then the second transaction will be rejected, because it drives
|
||||
// the account balance below zero before the credit is added.
|
||||
assert_eq!(bank.get_balance(&alice.pubkey()), 1);
|
||||
assert_eq!(bank.get_balance(&alice.pubkey()), 2);
|
||||
}
|
||||
Blocktree::destroy(&ledger_path).unwrap();
|
||||
}
|
||||
@ -1607,7 +1599,7 @@ mod tests {
|
||||
let bank = Arc::new(Bank::new(&genesis_block));
|
||||
let pubkey = Pubkey::new_rand();
|
||||
|
||||
let transactions = vec![system_transaction::transfer_now(
|
||||
let transactions = vec![system_transaction::transfer(
|
||||
&mint_keypair,
|
||||
&pubkey,
|
||||
1,
|
||||
|
@ -138,7 +138,7 @@ mod test {
|
||||
|
||||
let keypair = Keypair::new();
|
||||
let mut blockhash = entries[3].hash;
|
||||
let tx = system_transaction::transfer_now(&keypair, &keypair.pubkey(), 1, Hash::default());
|
||||
let tx = system_transaction::transfer(&keypair, &keypair.pubkey(), 1, Hash::default());
|
||||
let entry = Entry::new(&mut blockhash, 1, vec![tx]);
|
||||
blockhash = entry.hash;
|
||||
entries.push(entry);
|
||||
|
@ -87,7 +87,7 @@ mod tests {
|
||||
..
|
||||
} = create_genesis_block(2);
|
||||
let bank0 = Arc::new(Bank::new(&genesis_block));
|
||||
let tx = system_transaction::transfer_now(
|
||||
let tx = system_transaction::transfer(
|
||||
&mint_keypair,
|
||||
&Pubkey::new_rand(),
|
||||
1,
|
||||
|
@ -101,7 +101,7 @@ mod tests {
|
||||
Entry::new_mut(
|
||||
&mut id,
|
||||
&mut num_hashes,
|
||||
vec![system_transaction::transfer_now(
|
||||
vec![system_transaction::transfer(
|
||||
&keypair,
|
||||
&keypair.pubkey(),
|
||||
1,
|
||||
|
@ -602,7 +602,7 @@ mod tests {
|
||||
fn test_to_packets() {
|
||||
let keypair = Keypair::new();
|
||||
let hash = Hash::new(&[1; 32]);
|
||||
let tx = system_transaction::transfer_now(&keypair, &keypair.pubkey(), 1, hash);
|
||||
let tx = system_transaction::transfer(&keypair, &keypair.pubkey(), 1, hash);
|
||||
let rv = to_packets(&vec![tx.clone(); 1]);
|
||||
assert_eq!(rv.len(), 1);
|
||||
assert_eq!(rv[0].packets.len(), 1);
|
||||
|
@ -956,7 +956,7 @@ mod test {
|
||||
blockhash,
|
||||
1,
|
||||
vec![
|
||||
system_transaction::transfer_now(&keypair1, &keypair2.pubkey(), 2, *blockhash), // should be fine,
|
||||
system_transaction::transfer(&keypair1, &keypair2.pubkey(), 2, *blockhash), // should be fine,
|
||||
system_transaction::transfer(
|
||||
&missing_keypair,
|
||||
&missing_keypair2.pubkey(),
|
||||
@ -983,7 +983,7 @@ mod test {
|
||||
// Use wrong blockhash so that the entry causes an entry verification failure
|
||||
&bad_hash,
|
||||
1,
|
||||
vec![system_transaction::transfer_now(
|
||||
vec![system_transaction::transfer(
|
||||
&genesis_keypair,
|
||||
&keypair2.pubkey(),
|
||||
2,
|
||||
|
@ -391,7 +391,7 @@ mod tests {
|
||||
None,
|
||||
);
|
||||
|
||||
let tx = system_transaction::transfer_now(&alice, &contract_funds.pubkey(), 51, blockhash);
|
||||
let tx = system_transaction::transfer(&alice, &contract_funds.pubkey(), 51, blockhash);
|
||||
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions).unwrap();
|
||||
|
||||
let ixs = budget_instruction::when_signed(
|
||||
@ -435,7 +435,7 @@ mod tests {
|
||||
assert_eq!(serde_json::to_string(&expected).unwrap(), response);
|
||||
}
|
||||
|
||||
let tx = system_transaction::transfer_now(&alice, &witness.pubkey(), 1, blockhash);
|
||||
let tx = system_transaction::transfer(&alice, &witness.pubkey(), 1, blockhash);
|
||||
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions).unwrap();
|
||||
sleep(Duration::from_millis(200));
|
||||
let ix = budget_instruction::apply_signature(
|
||||
|
@ -10,7 +10,7 @@ pub fn test_tx() -> Transaction {
|
||||
let keypair1 = Keypair::new();
|
||||
let pubkey1 = keypair1.pubkey();
|
||||
let zero = Hash::default();
|
||||
system_transaction::transfer_now(&keypair1, &pubkey1, 42, zero)
|
||||
system_transaction::transfer(&keypair1, &pubkey1, 42, zero)
|
||||
}
|
||||
|
||||
pub fn test_multisig_tx() -> Transaction {
|
||||
|
Reference in New Issue
Block a user