Skip to content

Commit

Permalink
shuffle shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Leśniak committed Aug 1, 2023
1 parent ac86362 commit 858cbc2
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions finality-aleph/src/sync/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,39 @@ mod tests {
response
}

async fn grow_trunk(
handler: &mut TestHandler,
backend: &mut Backend,
notifier: &mut impl ChainStatusNotifier<MockHeader>,
bottom: &MockIdentifier,
length: usize,
) -> MockIdentifier {
let branch: Vec<_> = bottom.random_branch().take(length).collect();
let top = branch.last().expect("should not be empty").id();
for header in branch.iter() {
let block = MockBlock::new(header.clone(), true);
let justification = MockJustification::for_header(header.clone());
handler
.handle_justification_from_user(justification)
.expect("should work");
backend.import_block(block);
match notifier.next().await {
Ok(BlockImported(header)) => {
handler.block_imported(header).expect("should work");
}
_ => panic!("should notify about imported block"),
}
match notifier.next().await {
Ok(BlockFinalized(finalized_header)) => assert_eq!(
header, &finalized_header,
"should finalize the current header"
),
_ => panic!("shoould notify about finalized block"),
}
}
top
}

#[test]
fn creates_dangling_branch() {
let (mut handler, _backend, _notifier, _genesis) = setup();
Expand Down Expand Up @@ -860,39 +893,6 @@ mod tests {
);
}

async fn grow_trunk(
handler: &mut TestHandler,
backend: &mut Backend,
notifier: &mut impl ChainStatusNotifier<MockHeader>,
bottom: &MockIdentifier,
length: usize,
) -> MockIdentifier {
let branch: Vec<_> = bottom.random_branch().take(length).collect();
let top = branch.last().expect("should not be empty").id();
for header in branch.iter() {
let block = MockBlock::new(header.clone(), true);
let justification = MockJustification::for_header(header.clone());
handler
.handle_justification_from_user(justification)
.expect("should work");
backend.import_block(block);
match notifier.next().await {
Ok(BlockImported(header)) => {
handler.block_imported(header).expect("should work");
}
_ => panic!("should notify about imported block"),
}
match notifier.next().await {
Ok(BlockFinalized(finalized_header)) => assert_eq!(
header, &finalized_header,
"should finalize the current header"
),
_ => panic!("shoould notify about finalized block"),
}
}
top
}

#[tokio::test]
async fn syncs_to_a_long_trunk() {
let (mut handler, mut backend, mut notifier, _genesis) = setup();
Expand Down

0 comments on commit 858cbc2

Please sign in to comment.