fix(ci): update fake_peer_set test to avoid spurious failures (#5758)

* moves mempool.enable below peer_set.expect_request

* adds `sync_close_to_tip` call before starting gossip_best_tip_block_hashes task
This commit is contained in:
Arya 2022-12-01 04:43:11 -05:00 committed by GitHub
parent b3faa750b9
commit 8f9031880e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 10 deletions

View File

@ -78,13 +78,11 @@ async fn mempool_requests_for_transactions() {
.await; .await;
match response { match response {
Ok(Response::TransactionIds(response)) => assert_eq!(response, added_transaction_ids), Ok(Response::TransactionIds(response)) => assert_eq!(response, added_transaction_ids),
Ok(Response::Nil) => if !added_transaction_ids.is_empty() { Ok(Response::Nil) => assert!(
info!( added_transaction_ids.is_empty(),
"response {response:?} to `MempoolTransactionIds` request \ "`MempoolTransactionIds` request should match added_transaction_ids {:?}, got Ok(Nil)",
should match added_transaction_ids {added_transaction_ids:?}, \ added_transaction_ids
ignoring test failure because this test is unreliable due to timing issues", ),
);
}
_ => unreachable!( _ => unreachable!(
"`MempoolTransactionIds` requests should always respond `Ok(Vec<UnminedTxId> | Nil)`, got {:?}", "`MempoolTransactionIds` requests should always respond `Ok(Vec<UnminedTxId> | Nil)`, got {:?}",
response response
@ -857,7 +855,8 @@ async fn setup(
.unwrap(); .unwrap();
committed_blocks.push(block_one); committed_blocks.push(block_one);
// Don't wait for the chain tip update here, we wait for AdvertiseBlock below. // Don't wait for the chain tip update here, we wait for expect_request(AdvertiseBlock) below,
// which is called by the gossip_best_tip_block_hashes task once the chain tip changes.
let (mut mempool_service, transaction_receiver) = Mempool::new( let (mut mempool_service, transaction_receiver) = Mempool::new(
&MempoolConfig::default(), &MempoolConfig::default(),
@ -869,8 +868,8 @@ async fn setup(
chain_tip_change.clone(), chain_tip_change.clone(),
); );
// Enable the mempool // Pretend we're close to tip
mempool_service.enable(&mut recent_syncs).await; SyncStatus::sync_close_to_tip(&mut recent_syncs);
let sync_gossip_task_handle = tokio::spawn(sync::gossip_best_tip_block_hashes( let sync_gossip_task_handle = tokio::spawn(sync::gossip_best_tip_block_hashes(
sync_status.clone(), sync_status.clone(),
@ -894,6 +893,13 @@ async fn setup(
.respond(Response::Nil); .respond(Response::Nil);
} }
// Enable the mempool
// Note: this needs to be done after the mock peer set service has received the AdvertiseBlock
// request to ensure that the call to `last_tip_change` returns the chain tip block for block_one
// and not the genesis block, or else the transactions from the genesis block will be added to
// the mempool storage's rejection list and tests will fail.
mempool_service.enable(&mut recent_syncs).await;
// Add transactions to the mempool, skipping verification and broadcast // Add transactions to the mempool, skipping verification and broadcast
let mut added_transactions = Vec::new(); let mut added_transactions = Vec::new();
if add_transactions { if add_transactions {