Skip to content

Commit

Permalink
test: more select median tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msgmaxim committed Sep 4, 2023
1 parent b2f29a6 commit d2a5ee2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions state-chain/runtime/src/chainflip/decompose_recompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,17 @@ mod tests {
assert_eq!(select_median::<u16>(values).unwrap(), 32);
}

#[test]
fn select_median_out_of_order() {
let values = vec![4, 1, 8, 7, 100];
assert_eq!(select_median::<u16>(values).unwrap(), 7);
}

#[test]
fn select_median_empty() {
assert_eq!(select_median::<u16>(vec![]), None);
}

// For BTC, we witness multiple values, and median should be
// selected for each value independently:
#[test]
Expand Down Expand Up @@ -303,4 +314,9 @@ mod tests {
})
);
}

#[test]
fn select_median_btc_info_empty() {
assert_eq!(select_median_btc_info(vec![]), None);
}
}

0 comments on commit d2a5ee2

Please sign in to comment.