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
 | 
				
			||||||
        let entries: Vec<_> = entry_receiver
 | 
					        // until the balance is what we expect.
 | 
				
			||||||
            .iter()
 | 
					        let bank = Bank::new(&genesis_block);
 | 
				
			||||||
            .flat_map(|x| x.1.into_iter().map(|e| e.0))
 | 
					        for _ in 0..10 {
 | 
				
			||||||
            .collect();
 | 
					            let entries: Vec<_> = entry_receiver
 | 
				
			||||||
        // same assertion as running through the bank, really...
 | 
					                .iter()
 | 
				
			||||||
        assert!(entries.len() >= 2);
 | 
					                .flat_map(|x| x.1.into_iter().map(|e| e.0))
 | 
				
			||||||
 | 
					                .collect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for entry in &entries {
 | 
				
			||||||
 | 
					                bank.process_transactions(&entry.transactions)
 | 
				
			||||||
 | 
					                    .iter()
 | 
				
			||||||
 | 
					                    .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
 | 
					        // 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);
 | 
					 | 
				
			||||||
        for entry in entries {
 | 
					 | 
				
			||||||
            bank.process_transactions(&entry.transactions)
 | 
					 | 
				
			||||||
                .iter()
 | 
					 | 
				
			||||||
                .for_each(|x| assert_eq!(*x, Ok(())));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        assert_eq!(bank.get_balance(&alice.pubkey()), 1);
 | 
					        assert_eq!(bank.get_balance(&alice.pubkey()), 1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user