@@ -1491,6 +1491,13 @@ mod tests {
14911491 let blob = RangeSyncBlob :: new ( ) ;
14921492 let writer = Write :: from_pooler ( & context, blob. clone ( ) , 0 , NZUsize ! ( 8 ) ) ;
14931493
1494+ // A fresh writer has no buffered bytes or prior plain blob mutation, so sync is a no-op.
1495+ writer. sync ( ) . await . unwrap ( ) ;
1496+ let ( durable, full_syncs, range_syncs) = blob. snapshot ( ) ;
1497+ assert ! ( durable. is_empty( ) ) ;
1498+ assert_eq ! ( full_syncs, 0 ) ;
1499+ assert_eq ! ( range_syncs, 0 ) ;
1500+
14941501 // The write remains entirely buffered, so sync can make just this range durable.
14951502 writer. write_at ( 0 , b"abc" ) . await . unwrap ( ) ;
14961503 writer. sync ( ) . await . unwrap ( ) ;
@@ -1500,6 +1507,13 @@ mod tests {
15001507 assert_eq ! ( durable. as_slice( ) , b"abc" ) ;
15011508 assert_eq ! ( full_syncs, 0 ) ;
15021509 assert_eq ! ( range_syncs, 1 ) ;
1510+
1511+ // The prior sync used write_at_sync, so there is still no pending full-sync barrier.
1512+ writer. sync ( ) . await . unwrap ( ) ;
1513+ let ( durable, full_syncs, range_syncs) = blob. snapshot ( ) ;
1514+ assert_eq ! ( durable. as_slice( ) , b"abc" ) ;
1515+ assert_eq ! ( full_syncs, 0 ) ;
1516+ assert_eq ! ( range_syncs, 1 ) ;
15031517 } ) ;
15041518 }
15051519
@@ -1521,6 +1535,13 @@ mod tests {
15211535 assert_eq ! ( full_syncs, 1 ) ;
15221536 assert_eq ! ( range_syncs, 0 ) ;
15231537
1538+ // With no new writes, sync has no work left.
1539+ writer. sync ( ) . await . unwrap ( ) ;
1540+ let ( durable, full_syncs, range_syncs) = blob. snapshot ( ) ;
1541+ assert_eq ! ( durable. as_slice( ) , b"abcdefg" ) ;
1542+ assert_eq ! ( full_syncs, 1 ) ;
1543+ assert_eq ! ( range_syncs, 0 ) ;
1544+
15241545 // After the full sync, the next buffer-only write can use range sync again.
15251546 writer. write_at ( 7 , b"h" ) . await . unwrap ( ) ;
15261547 writer. sync ( ) . await . unwrap ( ) ;
0 commit comments