From 6c9d0403f9dca5a82d771c6966a29ca2071b0ce6 Mon Sep 17 00:00:00 2001 From: dandanlen <3168260+dandanlen@users.noreply.github.com> Date: Sat, 21 Oct 2023 00:52:23 +0200 Subject: [PATCH] chore: add missing import (#4152) --- api/lib/src/queries.rs | 61 ++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/api/lib/src/queries.rs b/api/lib/src/queries.rs index e4723c74bf..d3d0d3c29b 100644 --- a/api/lib/src/queries.rs +++ b/api/lib/src/queries.rs @@ -222,34 +222,43 @@ fn compute_distance(index: usize, slot: usize, len: usize) -> usize { } } -#[test] -fn test_slot_extraction() { - let slot = Slot::from(42); - assert_eq!( - Some(slot), - extract_slot_from_digest_item(&DigestItem::PreRuntime( - AURA_ENGINE_ID, - Encode::encode(&slot) - )) - ); - assert_eq!( - None, - extract_slot_from_digest_item(&DigestItem::PreRuntime(*b"BORA", Encode::encode(&slot))) - ); - assert_eq!(None, extract_slot_from_digest_item(&DigestItem::Other(b"SomethingElse".to_vec()))); -} +#[cfg(test)] +mod test { + use super::*; + use codec::Encode; -#[test] -fn test_compute_distance() { - let index: usize = 5; - let slot: usize = 7; - let len: usize = 15; + #[test] + fn test_slot_extraction() { + let slot = Slot::from(42); + assert_eq!( + Some(slot), + extract_slot_from_digest_item(&DigestItem::PreRuntime( + AURA_ENGINE_ID, + Encode::encode(&slot) + )) + ); + assert_eq!( + None, + extract_slot_from_digest_item(&DigestItem::PreRuntime(*b"BORA", Encode::encode(&slot))) + ); + assert_eq!( + None, + extract_slot_from_digest_item(&DigestItem::Other(b"SomethingElse".to_vec())) + ); + } - assert_eq!(compute_distance(index, slot, len), 13); + #[test] + fn test_compute_distance() { + let index: usize = 5; + let slot: usize = 7; + let len: usize = 15; - let index: usize = 18; - let slot: usize = 7; - let len: usize = 24; + assert_eq!(compute_distance(index, slot, len), 13); - assert_eq!(compute_distance(index, slot, len), 11); + let index: usize = 18; + let slot: usize = 7; + let len: usize = 24; + + assert_eq!(compute_distance(index, slot, len), 11); + } }