banking_stage_entryfication fails when run as cargo test
Add some retry for getting entries from the channel.
This commit is contained in:
committed by
sakridge
parent
a4b6d181a2
commit
f8e07ef5a3
@ -602,23 +602,31 @@ mod tests {
|
|||||||
poh_service.join().unwrap();
|
poh_service.join().unwrap();
|
||||||
drop(poh_recorder);
|
drop(poh_recorder);
|
||||||
|
|
||||||
// Collect the ledger and feed it to a new bank.
|
// Poll the entry_receiver, feeding it into a new bank
|
||||||
|
// until the balance is what we expect.
|
||||||
|
let bank = Bank::new(&genesis_block);
|
||||||
|
for _ in 0..10 {
|
||||||
let entries: Vec<_> = entry_receiver
|
let entries: Vec<_> = entry_receiver
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|x| x.1.into_iter().map(|e| e.0))
|
.flat_map(|x| x.1.into_iter().map(|e| e.0))
|
||||||
.collect();
|
.collect();
|
||||||
// same assertion as running through the bank, really...
|
|
||||||
assert!(entries.len() >= 2);
|
|
||||||
|
|
||||||
// Assert the user holds one lamport, not two. If the stage only outputs one
|
for entry in &entries {
|
||||||
// entry, then the second transaction will be rejected, because it drives
|
|
||||||
// the account balance below zero before the credit is added.
|
|
||||||
let bank = Bank::new(&genesis_block);
|
|
||||||
for entry in entries {
|
|
||||||
bank.process_transactions(&entry.transactions)
|
bank.process_transactions(&entry.transactions)
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|x| assert_eq!(*x, Ok(())));
|
.for_each(|x| assert_eq!(*x, Ok(())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bank.get_balance(&alice.pubkey()) == 1 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(Duration::from_millis(100));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// 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()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user