Increase detail of cached hashing testing

This commit is contained in:
Paul Hauner 2019-04-27 16:33:31 +10:00
parent 80fa5d08c5
commit b70ebd09ea
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -29,13 +29,34 @@ where
// Create a new hasher from the "modified" struct.
let modified_hasher = CachedTreeHasher::new(modified).unwrap();
// Test that the modified hasher has the same number of chunks as a newly built hasher.
assert_eq!(
hasher.cache.chunk_modified.len(),
modified_hasher.cache.chunk_modified.len(),
"Number of chunks is different"
);
assert_eq!(
hasher.cache.cache.len(),
modified_hasher.cache.cache.len(),
"Number of bytes is different"
);
assert_eq!(
hasher.cache.cache, modified_hasher.cache.cache,
"Bytes are different"
);
assert_eq!(
hasher.cache.schemas.len(),
modified_hasher.cache.schemas.len(),
"Number of schemas is different"
);
assert_eq!(
hasher.cache.schemas, modified_hasher.cache.schemas,
"Schemas are different"
);
// Test the root generated by the updated hasher matches a non-cached tree hash root.
let standard_root = modified.tree_hash_root();
let cached_root = hasher