File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1832,6 +1832,29 @@ mod tests {
1832
1832
}
1833
1833
}
1834
1834
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
+
1835
1858
trait TestTree < H : TestHashable > {
1836
1859
fn assert_root ( & self , values : & [ u64 ] ) ;
1837
1860
You can’t perform that action at this time.
0 commit comments