Skip to content

Commit

Permalink
schore(p2p): disable test until P2P spec catches up
Browse files Browse the repository at this point in the history
  • Loading branch information
kkovaacs committed Feb 20, 2024
1 parent 697f6b0 commit 73f61e1
Showing 1 changed file with 43 additions and 46 deletions.
89 changes: 43 additions & 46 deletions crates/pathfinder/src/p2p_network/sync_handlers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ mod boundary_conditions {

/// Property tests, grouped to be immediately visible when executed
mod prop {
use crate::p2p_network::client::conv::{
cairo_def_from_dto, sierra_defs_from_dto, Receipt as P2PReceipt,
SignedBlockHeader as P2PSignedBlockHeader,
};
use crate::p2p_network::client::conv::{cairo_def_from_dto, sierra_defs_from_dto};
use crate::p2p_network::sync_handlers;
use futures::channel::mpsc;
use futures::StreamExt;
Expand All @@ -107,7 +104,6 @@ mod prop {
use p2p_proto::common::{BlockNumberOrHash, Iteration};
use p2p_proto::event::{EventsRequest, EventsResponse};
use p2p_proto::header::{BlockHeadersRequest, BlockHeadersResponse};
use p2p_proto::receipt::{ReceiptsRequest, ReceiptsResponse};
use p2p_proto::state::{
ContractDiff, ContractStoredValue, StateDiffsRequest, StateDiffsResponse,
};
Expand Down Expand Up @@ -395,47 +391,48 @@ mod prop {
}
}

proptest! {
#[test]
fn get_receipts((num_blocks, seed, start_block, limit, step, direction) in strategy::composite()) {
// Fake storage with a given number of blocks
let (storage, in_db) = fixtures::storage_with_seed(seed, num_blocks);
// Compute the overlapping set between the db and the request
// These are the receipts that we expect to be read from the db
// Grouped by block number
let expected = overlapping::get(in_db, start_block, limit, step, num_blocks, direction).into_iter()
.map(|(h, _, tr, _, _, _)|
(
// Block number
h.number,
// List of receipts
tr.into_iter().map(|(_, r)| P2PReceipt::from(r)).collect::<Vec<_>>()
)
).collect::<Vec<_>>();
// Run the handler
let request = ReceiptsRequest { iteration: Iteration { start: BlockNumberOrHash::Number(start_block), limit, step, direction, } };
let mut responses = Runtime::new().unwrap().block_on(async {
let (tx, rx) = mpsc::channel(0);
let getter_fut = sync_handlers::get_receipts(storage, request, tx);
let (_, responses) = tokio::join!(getter_fut, rx.collect::<Vec<_>>());
responses
});

// Make sure the last reply is Fin
assert_eq!(responses.pop().unwrap(), ReceiptsResponse::Fin);

// Check the rest
let mut actual = responses.into_iter().map(|response| match response {
ReceiptsResponse::Receipt(receipt) => P2PReceipt::try_from(receipt).unwrap(),
_ => panic!("unexpected response"),
}).collect::<Vec<_>>();

for expected_for_block in expected {
let actual_for_block = actual.drain(..expected_for_block.1.len()).collect::<Vec<_>>();
prop_assert_eq_sorted!(expected_for_block.1, actual_for_block, "block number: {}", expected_for_block.0);
}
}
}
// FIXME: commented out until data_availability gets added to P2P receipt protobuf
// proptest! {
// #[test]
// fn get_receipts((num_blocks, seed, start_block, limit, step, direction) in strategy::composite()) {
// // Fake storage with a given number of blocks
// let (storage, in_db) = fixtures::storage_with_seed(seed, num_blocks);
// // Compute the overlapping set between the db and the request
// // These are the receipts that we expect to be read from the db
// // Grouped by block number
// let expected = overlapping::get(in_db, start_block, limit, step, num_blocks, direction).into_iter()
// .map(|(h, _, tr, _, _, _)|
// (
// // Block number
// h.number,
// // List of receipts
// tr.into_iter().map(|(_, r)| P2PReceipt::from(r)).collect::<Vec<_>>()
// )
// ).collect::<Vec<_>>();
// // Run the handler
// let request = ReceiptsRequest { iteration: Iteration { start: BlockNumberOrHash::Number(start_block), limit, step, direction, } };
// let mut responses = Runtime::new().unwrap().block_on(async {
// let (tx, rx) = mpsc::channel(0);
// let getter_fut = sync_handlers::get_receipts(storage, request, tx);
// let (_, responses) = tokio::join!(getter_fut, rx.collect::<Vec<_>>());
// responses
// });

// // Make sure the last reply is Fin
// assert_eq!(responses.pop().unwrap(), ReceiptsResponse::Fin);

// // Check the rest
// let mut actual = responses.into_iter().map(|response| match response {
// ReceiptsResponse::Receipt(receipt) => P2PReceipt::try_from(receipt).unwrap(),
// _ => panic!("unexpected response"),
// }).collect::<Vec<_>>();

// for expected_for_block in expected {
// let actual_for_block = actual.drain(..expected_for_block.1.len()).collect::<Vec<_>>();
// prop_assert_eq_sorted!(expected_for_block.1, actual_for_block, "block number: {}", expected_for_block.0);
// }
// }
// }

proptest! {
#[test]
Expand Down

0 comments on commit 73f61e1

Please sign in to comment.