Introduce failing test

This commit is contained in:
Paul Hauner
2019-04-22 21:31:39 +10:00
parent 2f69185ccb
commit ec43a4085c
4 changed files with 59 additions and 3 deletions

View File

@@ -19,9 +19,13 @@ impl CachedTreeHashSubTree<u64> for u64 {
let leaf = merkleize(self.to_le_bytes().to_vec());
cache.maybe_update_chunk(cache.chunk_index, &leaf)?;
dbg!(cache.overlay_index);
cache.chunk_index += 1;
cache.overlay_index += 1;
dbg!(cache.overlay_index);
Ok(())
}
}

View File

@@ -63,6 +63,11 @@ where
let new_overlay = BTreeOverlay::new(self, cache.chunk_index)?;
let old_overlay = cache.get_overlay(cache.overlay_index, cache.chunk_index)?;
dbg!(cache.overlay_index);
// dbg!(&new_overlay);
// dbg!(&old_overlay);
// If the merkle tree required to represent the new list is of a different size to the one
// required for the previous list, then update our cache.
//
@@ -106,7 +111,6 @@ where
TreeHashType::Container | TreeHashType::List | TreeHashType::Vector => {
let mut local_overlay_index = cache.overlay_index;
for i in 0..new_overlay.num_leaf_nodes() {
cache.overlay_index = local_overlay_index;
@@ -122,7 +126,6 @@ where
(Some(_old), Some(new)) => {
cache.chunk_index = new.start;
self[i].update_tree_hash_cache(cache)?;
local_overlay_index += 1;
@@ -131,7 +134,7 @@ where
//
// Viz., the list has been shortened.
(Some(old), None) => {
if new_overlay.num_items == 0 {
if new_overlay.num_items == 0 {
// In this case, the list has been made empty and we should make
// this node padding.
cache.maybe_update_chunk(new_overlay.root(), &[0; HASHSIZE])?;
@@ -188,6 +191,8 @@ where
cache.chunk_index = new_overlay.next_node();
dbg!(&cache.overlay_index);
Ok(())
}
}