Skip to content

Commit

Permalink
fix wrong units in remaining time warning
Browse files Browse the repository at this point in the history
close #1226
  • Loading branch information
edouardparis committed Aug 14, 2024
1 parent b947968 commit c70a5cb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion gui/src/app/view/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub fn expire_message_units(sequence: u32) -> Vec<String> {
let n_days = n_minutes / 1440;

#[allow(clippy::nonminimal_bool)]
if n_days != 0 || n_months != 0 || n_days != 0 {
if n_years != 0 || n_months != 0 || n_days != 0 {
[(n_years, "year"), (n_months, "month"), (n_days, "day")]
.iter()
.filter_map(|(n, u)| {
Expand All @@ -375,3 +375,20 @@ pub fn expire_message_units(sequence: u32) -> Vec<String> {
.collect()
}
}

#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_expire_message_units() {
let testcases = [
(61, vec!["10 hours".to_string(), "10 minutes".to_string()]),
(1112, vec!["7 days".to_string()]),
(52600, vec!["1 year".to_string()]),
];

for (seq, result) in testcases {
assert_eq!(expire_message_units(seq), result);
}
}
}

0 comments on commit c70a5cb

Please sign in to comment.