From 9526849c143a4298b014aa0a44301da71cb14021 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 23 Apr 2025 19:05:01 +0200 Subject: [PATCH] chore: add update_db_with_and_check (#15885) --- crates/stages/stages/src/stages/mod.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/crates/stages/stages/src/stages/mod.rs b/crates/stages/stages/src/stages/mod.rs index 95b4028fad..f1de71bf86 100644 --- a/crates/stages/stages/src/stages/mod.rs +++ b/crates/stages/stages/src/stages/mod.rs @@ -360,9 +360,20 @@ mod tests { ) where ::Value: Default, { + update_db_with_and_check::(db, key, expected, &Default::default()); + } + + /// Inserts the given value at key and compare the check consistency result against the expected + /// one. + fn update_db_with_and_check>( + db: &TestStageDB, + key: u64, + expected: Option, + value: &T::Value, + ) { let provider_rw = db.factory.provider_rw().unwrap(); let mut cursor = provider_rw.tx_ref().cursor_write::().unwrap(); - cursor.insert(key, &Default::default()).unwrap(); + cursor.insert(key, value).unwrap(); provider_rw.commit().unwrap(); assert!(matches!( @@ -487,14 +498,20 @@ mod tests { .unwrap(); // Creates a gap of one transaction: static_file db - update_db_and_check::( + update_db_with_and_check::( &db, current + 2, Some(PipelineTarget::Unwind(89)), + &Default::default(), ); // Fill the gap, and ensure no unwind is necessary. - update_db_and_check::(&db, current + 1, None); + update_db_with_and_check::( + &db, + current + 1, + None, + &Default::default(), + ); } #[test]