fix tests
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled

This commit is contained in:
Boog900 2024-06-13 23:07:35 +01:00
parent 3e87556411
commit cfe5bea453
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2

View file

@ -50,41 +50,43 @@ proptest! {
let tokio_pool = tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap(); let tokio_pool = tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap();
tokio_pool.block_on(timeout(Duration::from_secs(600), async move { tokio_pool.block_on(async move {
let client_pool = ClientPool::new(); timeout(Duration::from_secs(600), async move {
let client_pool = ClientPool::new();
let mut peer_ids = Vec::with_capacity(peers); let mut peer_ids = Vec::with_capacity(peers);
for _ in 0..peers { for _ in 0..peers {
let client = mock_block_downloader_client(blockchain.clone()); let client = mock_block_downloader_client(blockchain.clone());
peer_ids.push(client.info.id); peer_ids.push(client.info.id);
client_pool.add_new_client(client); client_pool.add_new_client(client);
} }
let stream = download_blocks( let stream = download_blocks(
client_pool, client_pool,
SyncStateSvc(peer_ids) , SyncStateSvc(peer_ids) ,
OurChainSvc { OurChainSvc {
genesis: *blockchain.blocks.first().unwrap().0 genesis: *blockchain.blocks.first().unwrap().0
}, },
BlockDownloaderConfig { BlockDownloaderConfig {
buffer_size: 1_000, buffer_size: 1_000,
in_progress_queue_size: 10_000, in_progress_queue_size: 10_000,
check_client_pool_interval: Duration::from_secs(5), check_client_pool_interval: Duration::from_secs(5),
target_batch_size: 5_000, target_batch_size: 5_000,
initial_batch_size: 1, initial_batch_size: 1,
}); });
let blocks = stream.map(|blocks| blocks.blocks).concat().await; let blocks = stream.map(|blocks| blocks.blocks).concat().await;
assert_eq!(blocks.len() + 1, blockchain.blocks.len()); assert_eq!(blocks.len() + 1, blockchain.blocks.len());
for (i, block) in blocks.into_iter().enumerate() { for (i, block) in blocks.into_iter().enumerate() {
assert_eq!(&block, blockchain.blocks.get_index(i + 1).unwrap().1); assert_eq!(&block, blockchain.blocks.get_index(i + 1).unwrap().1);
} }
})).unwrap(); }).await
}).unwrap();
} }
} }