Skip to content

Commit 27d20f5

Browse files
committed
Test garbage collection of ommers
1 parent 9f422d0 commit 27d20f5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,29 @@ mod tests {
18321832
}
18331833
}
18341834

1835+
#[test]
1836+
fn gc() {
1837+
let mut t = BridgeTree::<String, 8>::new();
1838+
let mut last_gc_pos = None;
1839+
1840+
for current_leaf_pos in 0..256 {
1841+
t.append(String::from_u64(0)).unwrap();
1842+
t.mark().unwrap();
1843+
1844+
for position in last_gc_pos.unwrap_or_default()..=current_leaf_pos {
1845+
_ = t.witness(position.into()).unwrap();
1846+
}
1847+
1848+
if current_leaf_pos - last_gc_pos.unwrap_or_default() > 10 {
1849+
for position in last_gc_pos.unwrap_or_default()..current_leaf_pos {
1850+
t.remove_mark(position.into()).unwrap();
1851+
}
1852+
t.garbage_collect_ommers();
1853+
last_gc_pos = Some(current_leaf_pos);
1854+
}
1855+
}
1856+
}
1857+
18351858
trait TestTree<H: TestHashable> {
18361859
fn assert_root(&self, values: &[u64]);
18371860

0 commit comments

Comments
 (0)