mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
Warp sync part II (#9284)
* Gap sync * Gap epoch test * Simplified network requests * Update client/db/src/utils.rs Co-authored-by: cheme <emericchevalier.pro@gmail.com> * Fixed v1 migration and added some comments * Next epoch is always regular * Removed fork tree change * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Added a comment and converted assert to error Co-authored-by: cheme <emericchevalier.pro@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -1202,6 +1202,38 @@ fn syncs_indexed_blocks() {
|
||||
.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn warp_sync() {
|
||||
sp_tracing::try_init_simple();
|
||||
let mut net = TestNet::new(0);
|
||||
// Create 3 synced peers and 1 peer trying to warp sync.
|
||||
net.add_full_peer_with_config(Default::default());
|
||||
net.add_full_peer_with_config(Default::default());
|
||||
net.add_full_peer_with_config(Default::default());
|
||||
net.add_full_peer_with_config(FullPeerConfig {
|
||||
sync_mode: SyncMode::Warp,
|
||||
..Default::default()
|
||||
});
|
||||
let gap_end = net.peer(0).push_blocks(63, false);
|
||||
net.peer(0).push_blocks(1, false);
|
||||
net.peer(1).push_blocks(64, false);
|
||||
net.peer(2).push_blocks(64, false);
|
||||
// Wait for peer 1 to sync state.
|
||||
net.block_until_sync();
|
||||
assert!(!net.peer(3).client().has_state_at(&BlockId::Number(1)));
|
||||
assert!(net.peer(3).client().has_state_at(&BlockId::Number(64)));
|
||||
|
||||
// Wait for peer 1 download block history
|
||||
block_on(futures::future::poll_fn::<(), _>(|cx| {
|
||||
net.poll(cx);
|
||||
if net.peer(3).has_block(&gap_end) {
|
||||
Poll::Ready(())
|
||||
} else {
|
||||
Poll::Pending
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn syncs_huge_blocks() {
|
||||
use sp_core::storage::well_known_keys::HEAP_PAGES;
|
||||
|
||||
Reference in New Issue
Block a user