Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 0d64ba4

Browse files
authored
client/beefy: fix incorrect BEEFY justifications import test (#12593)
Signed-off-by: Adrian Catangiu <[email protected]>
1 parent 07a6332 commit 0d64ba4

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

Diff for: client/beefy/src/tests.rs

+27-8
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,16 @@ fn beefy_importing_blocks() {
755755
block_on(block_import.import_block(params(block, None), HashMap::new())).unwrap(),
756756
ImportResult::AlreadyInChain
757757
);
758-
// Verify no justifications present:
758+
// Verify no BEEFY justifications present:
759759
{
760760
// none in backend,
761-
assert!(full_client.justifications(&block_id).unwrap().is_none());
761+
assert_eq!(
762+
full_client
763+
.justifications(&block_id)
764+
.unwrap()
765+
.and_then(|j| j.get(BEEFY_ENGINE_ID).cloned()),
766+
None
767+
);
762768
// and none sent to BEEFY worker.
763769
block_on(poll_fn(move |cx| {
764770
assert_eq!(justif_recv.poll_next_unpin(cx), Poll::Pending);
@@ -787,11 +793,18 @@ fn beefy_importing_blocks() {
787793
..Default::default()
788794
}),
789795
);
790-
// Verify justification successfully imported:
796+
// Verify BEEFY justification successfully imported:
791797
{
792-
// available in backend,
793-
assert!(full_client.justifications(&BlockId::Number(block_num)).unwrap().is_some());
794-
// and also sent to BEEFY worker.
798+
// still not in backend (worker is responsible for appending to backend),
799+
assert_eq!(
800+
full_client
801+
.justifications(&block_id)
802+
.unwrap()
803+
.and_then(|j| j.get(BEEFY_ENGINE_ID).cloned()),
804+
None
805+
);
806+
// but sent to BEEFY worker
807+
// (worker will append it to backend when all previous mandatory justifs are there as well).
795808
block_on(poll_fn(move |cx| {
796809
match justif_recv.poll_next_unpin(cx) {
797810
Poll::Ready(Some(_justification)) => (),
@@ -823,10 +836,16 @@ fn beefy_importing_blocks() {
823836
..Default::default()
824837
}),
825838
);
826-
// Verify bad justifications was not imported:
839+
// Verify bad BEEFY justifications was not imported:
827840
{
828841
// none in backend,
829-
assert!(full_client.justifications(&block_id).unwrap().is_none());
842+
assert_eq!(
843+
full_client
844+
.justifications(&BlockId::Number(block_num))
845+
.unwrap()
846+
.and_then(|j| j.get(BEEFY_ENGINE_ID).cloned()),
847+
None
848+
);
830849
// and none sent to BEEFY worker.
831850
block_on(poll_fn(move |cx| {
832851
assert_eq!(justif_recv.poll_next_unpin(cx), Poll::Pending);

0 commit comments

Comments
 (0)