From b0a360f5ac817bf1a30e36833d37668b55fc9af0 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 20 Aug 2024 15:04:15 +0700 Subject: [PATCH] added option to allow cache to visualize_verify_grovedb --- grovedb/src/batch/just_in_time_cost_tests.rs | 2 +- grovedb/src/batch/multi_insert_cost_tests.rs | 2 +- grovedb/src/batch/single_insert_cost_tests.rs | 10 +++++----- grovedb/src/lib.rs | 14 +++++++++----- grovedb/src/tests/mod.rs | 15 ++++++++++----- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/grovedb/src/batch/just_in_time_cost_tests.rs b/grovedb/src/batch/just_in_time_cost_tests.rs index 860abacf..a3fa9aec 100644 --- a/grovedb/src/batch/just_in_time_cost_tests.rs +++ b/grovedb/src/batch/just_in_time_cost_tests.rs @@ -414,7 +414,7 @@ mod tests { .cost; let issues = db - .visualize_verify_grovedb(Some(&tx), true, &Default::default()) + .visualize_verify_grovedb(Some(&tx), true, false, &Default::default()) .unwrap(); assert_eq!( issues.len(), diff --git a/grovedb/src/batch/multi_insert_cost_tests.rs b/grovedb/src/batch/multi_insert_cost_tests.rs index 8b0a5721..8a1200e6 100644 --- a/grovedb/src/batch/multi_insert_cost_tests.rs +++ b/grovedb/src/batch/multi_insert_cost_tests.rs @@ -449,7 +449,7 @@ mod tests { ); let issues = db - .visualize_verify_grovedb(Some(&tx), true, &Default::default()) + .visualize_verify_grovedb(Some(&tx), true, false, &Default::default()) .unwrap(); assert_eq!( issues.len(), diff --git a/grovedb/src/batch/single_insert_cost_tests.rs b/grovedb/src/batch/single_insert_cost_tests.rs index b9fb1573..2a269159 100644 --- a/grovedb/src/batch/single_insert_cost_tests.rs +++ b/grovedb/src/batch/single_insert_cost_tests.rs @@ -969,7 +969,7 @@ mod tests { ); let issues = db - .visualize_verify_grovedb(Some(&tx), true, &Default::default()) + .visualize_verify_grovedb(Some(&tx), true, false, &Default::default()) .unwrap(); assert_eq!( issues.len(), @@ -1082,7 +1082,7 @@ mod tests { ); let issues = db - .visualize_verify_grovedb(Some(&tx), true, &Default::default()) + .visualize_verify_grovedb(Some(&tx), true, false, &Default::default()) .unwrap(); assert_eq!( issues.len(), @@ -1362,7 +1362,7 @@ mod tests { ); let issues = db - .visualize_verify_grovedb(Some(&tx), true, &Default::default()) + .visualize_verify_grovedb(Some(&tx), true, false, &Default::default()) .unwrap(); assert_eq!( issues.len(), @@ -1546,7 +1546,7 @@ mod tests { ); let issues = db - .visualize_verify_grovedb(Some(&tx), true, &Default::default()) + .visualize_verify_grovedb(Some(&tx), true, false, &Default::default()) .unwrap(); assert_eq!( issues.len(), @@ -1640,7 +1640,7 @@ mod tests { ); let issues = db - .visualize_verify_grovedb(Some(&tx), true, &Default::default()) + .visualize_verify_grovedb(Some(&tx), true, false, &Default::default()) .unwrap(); assert_eq!( issues.len(), diff --git a/grovedb/src/lib.rs b/grovedb/src/lib.rs index a634d52b..feef0721 100644 --- a/grovedb/src/lib.rs +++ b/grovedb/src/lib.rs @@ -902,10 +902,11 @@ impl GroveDb { &self, transaction: TransactionArg, verify_references: bool, + allow_cache: bool, grove_version: &GroveVersion, ) -> Result, Error> { Ok(self - .verify_grovedb(transaction, verify_references, grove_version)? + .verify_grovedb(transaction, verify_references, allow_cache, grove_version)? .iter() .map(|(path, (root_hash, expected, actual))| { ( @@ -929,6 +930,7 @@ impl GroveDb { &self, transaction: TransactionArg, verify_references: bool, + allow_cache: bool, grove_version: &GroveVersion, ) -> Result>, (CryptoHash, CryptoHash, CryptoHash)>, Error> { if let Some(transaction) = transaction { @@ -946,6 +948,7 @@ impl GroveDb { None, transaction, verify_references, + allow_cache, grove_version, ) } else { @@ -957,6 +960,7 @@ impl GroveDb { &SubtreePath::empty(), None, verify_references, + allow_cache, grove_version, ) } @@ -970,13 +974,12 @@ impl GroveDb { path: &SubtreePath, batch: Option<&'db StorageBatch>, verify_references: bool, + allow_cache: bool, grove_version: &GroveVersion, ) -> Result>, (CryptoHash, CryptoHash, CryptoHash)>, Error> { let mut all_query = Query::new(); all_query.insert_all(); - let allow_cache = true; - let mut issues = HashMap::new(); let mut element_iterator = KVIterator::new(merk.storage.raw_iter(), &all_query).unwrap(); @@ -1024,6 +1027,7 @@ impl GroveDb { &new_path_ref, batch, verify_references, + true, grove_version, )?); } @@ -1114,13 +1118,12 @@ impl GroveDb { batch: Option<&'db StorageBatch>, transaction: &Transaction, verify_references: bool, + allow_cache: bool, grove_version: &GroveVersion, ) -> Result>, (CryptoHash, CryptoHash, CryptoHash)>, Error> { let mut all_query = Query::new(); all_query.insert_all(); - let allow_cache = true; - let mut issues = HashMap::new(); let mut element_iterator = KVIterator::new(merk.storage.raw_iter(), &all_query).unwrap(); @@ -1170,6 +1173,7 @@ impl GroveDb { batch, transaction, verify_references, + true, grove_version, )?); } diff --git a/grovedb/src/tests/mod.rs b/grovedb/src/tests/mod.rs index ec3cdbfa..41263669 100644 --- a/grovedb/src/tests/mod.rs +++ b/grovedb/src/tests/mod.rs @@ -3990,7 +3990,12 @@ mod tests { )); // `verify_grovedb` must identify issues - assert!(db.verify_grovedb(None, true, grove_version).unwrap().len() > 0); + assert!( + db.verify_grovedb(None, true, false, grove_version) + .unwrap() + .len() + > 0 + ); } #[test] @@ -4043,7 +4048,7 @@ mod tests { .unwrap(); assert!(db - .verify_grovedb(None, true, grove_version) + .verify_grovedb(None, true, false, grove_version) .unwrap() .is_empty()); @@ -4060,7 +4065,7 @@ mod tests { .unwrap(); assert!(!db - .verify_grovedb(None, true, grove_version) + .verify_grovedb(None, true, false, grove_version) .unwrap() .is_empty()); } @@ -4098,7 +4103,7 @@ mod tests { .unwrap(); assert!(db - .verify_grovedb(None, true, grove_version) + .verify_grovedb(None, true, false, grove_version) .unwrap() .is_empty()); @@ -4115,7 +4120,7 @@ mod tests { .unwrap(); assert!(!db - .verify_grovedb(None, true, grove_version) + .verify_grovedb(None, true, false, grove_version) .unwrap() .is_empty()); }