Skip to content

Commit

Permalink
reactivated test
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Jul 9, 2024
1 parent 9827e2b commit 1a28e75
Showing 1 changed file with 64 additions and 49 deletions.
113 changes: 64 additions & 49 deletions grovedb/src/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1663,14 +1663,14 @@ mod tests {
let proof = db.prove_query(&path_query, None).unwrap().unwrap();
let (hash, result_set) = GroveDb::verify_query_raw(&proof, &path_query).unwrap();
assert_eq!(hash, db.root_hash(None).unwrap().unwrap());
println!(
"{}",
result_set
.iter()
.map(|a| a.to_string())
.collect::<Vec<String>>()
.join(" | ")
);
// println!(
// "{}",
// result_set
// .iter()
// .map(|a| a.to_string())
// .collect::<Vec<String>>()
// .join(" | ")
// );
assert_eq!(result_set.len(), 5);
compare_result_sets(&elements, &result_set);

Expand Down Expand Up @@ -1850,14 +1850,14 @@ mod tests {
let (hash, result_set) = GroveDb::verify_query_raw(&proof, &path_query).unwrap();
assert_eq!(hash, db.root_hash(None).unwrap().unwrap());

println!(
"{}",
result_set
.iter()
.map(|a| a.to_string())
.collect::<Vec<_>>()
.join(", ")
);
// println!(
// "{}",
// result_set
// .iter()
// .map(|a| a.to_string())
// .collect::<Vec<_>>()
// .join(", ")
// );
assert_eq!(result_set.len(), 5);

// TODO: verify that the result set is exactly the same
Expand Down Expand Up @@ -2014,39 +2014,54 @@ mod tests {
.expect("successful subtree insert");
// // if you don't have an item at the subquery path translation, you shouldn't
// be // added to the result set.
// let mut query = Query::new();
// query.insert_all();
// query.set_subquery_path(vec![b"d".to_vec()]);
//
// let path = vec![TEST_LEAF.to_vec()];
//
// let path_query = PathQuery::new_unsized(path, query.clone());
//
// let (elements, _) = db
// .query_raw(
// &path_query,
// false,
// true,
// false,
// QueryResultType::QueryPathKeyElementTrioResultType,
// None,
// )
// .unwrap()
// .expect("expected successful get_path_query");
//
// assert_eq!(elements,
// QueryResultElements::from_elements(vec![PathKeyElementTrioResultItem((vec![b"
// test_leaf".to_vec(), b"a".to_vec()], b"d".to_vec(),
// Element::Tree(Some(b"d".to_vec()), None) )),
// PathKeyElementTrioResultItem((vec![b"test_leaf".to_vec(), b"b".to_vec()],
// b"d".to_vec(), Element::Tree(Some(b"j".to_vec()), None) ))]));
//
// let proof = db.prove_query(&path_query, None).unwrap().unwrap();
// let (hash, result_set) = GroveDb::verify_query_raw(&proof,
// &path_query).unwrap(); assert_eq!(hash,
// db.root_hash(None).unwrap().unwrap()); println!("{}",
// result_set.iter().map(|a| a.to_string()).collect::<Vec<_>>().join("| "));
// assert_eq!(result_set.len(), 2);
let mut query = Query::new();
query.insert_all();
query.set_subquery_path(vec![b"d".to_vec()]);

let path = vec![TEST_LEAF.to_vec()];

let path_query = PathQuery::new_unsized(path, query.clone());

let (elements, _) = db
.query_raw(
&path_query,
false,
true,
false,
QueryResultType::QueryPathKeyElementTrioResultType,
None,
)
.unwrap()
.expect("expected successful get_path_query");

assert_eq!(
elements,
QueryResultElements::from_elements(vec![
PathKeyElementTrioResultItem((
vec![b"test_leaf".to_vec(), b"a".to_vec()],
b"d".to_vec(),
Element::Tree(Some(b"d".to_vec()), None)
)),
PathKeyElementTrioResultItem((
vec![b"test_leaf".to_vec(), b"b".to_vec()],
b"d".to_vec(),
Element::Tree(Some(b"j".to_vec()), None)
))
])
);

let proof = db.prove_query(&path_query, None).unwrap().unwrap();
let (hash, result_set) = GroveDb::verify_query_raw(&proof, &path_query).unwrap();
assert_eq!(hash, db.root_hash(None).unwrap().unwrap());
// println!(
// "{}",
// result_set
// .iter()
// .map(|a| a.to_string())
// .collect::<Vec<_>>()
// .join("| ")
// );
assert_eq!(result_set.len(), 2);

// apply path translation then query
let mut query = Query::new();
Expand Down

0 comments on commit 1a28e75

Please sign in to comment.