From 7b7fdb42d935e3a5155ab1cef5661f9e7cd8a271 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Wed, 2 Mar 2022 08:31:14 -0600 Subject: [PATCH] minor test refactoring (#23423) --- runtime/src/accounts_db.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 735ebf410f..eb3b2d8bd7 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -12352,26 +12352,21 @@ pub mod tests { } else { panic!("All roots should have been flushed to storage"); }; - if !should_clean || slot == slots.last().unwrap() { + let expected_accounts = if !should_clean || slot == slots.last().unwrap() { // The slot was not cleaned before being flushed to storage, // so it also contains all the original updates. - assert_eq!( - slot_accounts, - keys[*slot as usize..] - .iter() - .cloned() - .collect::>() - ); + keys[*slot as usize..] + .iter() + .cloned() + .collect::>() } else { // If clean was specified, only the latest slot should have all the updates. // All these other slots have been cleaned before flush - assert_eq!( - slot_accounts, - std::iter::once(keys[*slot as usize]) - .into_iter() - .collect::>() - ); - } + std::iter::once(keys[*slot as usize]) + .into_iter() + .collect::>() + }; + assert_eq!(slot_accounts, expected_accounts); } }