From 03d94ad6c7d86d854c180bbf4ba079658e7ef5b2 Mon Sep 17 00:00:00 2001 From: Dmitry Markin Date: Tue, 8 Aug 2023 19:14:17 +0300 Subject: [PATCH] Add test for syncing fork not fitting into one response --- client/network/test/src/sync.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/network/test/src/sync.rs b/client/network/test/src/sync.rs index 389177b4aaf1b..30a43ce9b37b5 100644 --- a/client/network/test/src/sync.rs +++ b/client/network/test/src/sync.rs @@ -246,6 +246,20 @@ async fn sync_no_common_longer_chain_fails() { assert!(!net.peers()[0].blockchain_canon_equals(peer1)); } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn sync_fork_multiple_responses_works() { + sp_tracing::try_init_simple(); + let mut net = TestNet::new(2); + + // NOTE: the test succeeds if we push <= 128 blocks below. + let f0_best = net.peer(0).push_blocks(129, true).pop().unwrap(); + net.peer(1).push_blocks(130, false); + + net.run_until_sync().await; + + assert!(net.peer(1).has_block(f0_best)); +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn sync_justifications() { sp_tracing::try_init_simple();