@@ -816,14 +816,14 @@ mod tests {
816816 } )
817817 . unwrap ( ) ;
818818
819- let ( tx, mut rx) = sync:: channel :: < Patch > ( 1 ) ;
819+ let ( tx, mut rx) = sync:: channel :: < ( Patch , Option < Value > ) > ( 1 ) ;
820820 let channel = Channel :: from ( tx) ;
821821
822822 let received = Arc :: new ( tokio:: sync:: Mutex :: new ( Vec :: new ( ) ) ) ;
823823 let received_clone = received. clone ( ) ;
824824 let ack_task = tokio:: spawn ( async move {
825825 while let Some ( msg) = rx. recv ( ) . await {
826- received_clone. lock ( ) . await . push ( msg. data . clone ( ) ) ;
826+ received_clone. lock ( ) . await . push ( msg. data . 0 . clone ( ) ) ;
827827 msg. ack ( ) ;
828828 }
829829 } ) ;
@@ -875,14 +875,14 @@ mod tests {
875875 } )
876876 . unwrap ( ) ;
877877
878- let ( tx, mut rx) = sync:: channel :: < Patch > ( 10 ) ;
878+ let ( tx, mut rx) = sync:: channel :: < ( Patch , Option < Value > ) > ( 10 ) ;
879879 let channel = Channel :: from ( tx) ;
880880
881881 let received = Arc :: new ( tokio:: sync:: Mutex :: new ( Vec :: new ( ) ) ) ;
882882 let received_clone = received. clone ( ) ;
883883 let ack_task = tokio:: spawn ( async move {
884884 while let Some ( msg) = rx. recv ( ) . await {
885- received_clone. lock ( ) . await . push ( msg. data . clone ( ) ) ;
885+ received_clone. lock ( ) . await . push ( msg. data . 0 . clone ( ) ) ;
886886 msg. ack ( ) ;
887887 }
888888 } ) ;
@@ -930,15 +930,15 @@ mod tests {
930930 } ;
931931 let system = System :: try_from ( state) . unwrap ( ) ;
932932
933- let ( tx, mut rx) = sync:: channel :: < Patch > ( 1 ) ;
933+ let ( tx, mut rx) = sync:: channel :: < ( Patch , Option < Value > ) > ( 1 ) ;
934934 let channel = Channel :: from ( tx) ;
935935
936936 // Spawn a task to receive and acknowledge messages
937937 let received_patches = Arc :: new ( tokio:: sync:: Mutex :: new ( Vec :: new ( ) ) ) ;
938938 let received_patches_clone = received_patches. clone ( ) ;
939939 let ack_task = tokio:: spawn ( async move {
940940 while let Some ( msg) = rx. recv ( ) . await {
941- received_patches_clone. lock ( ) . await . push ( msg. data . clone ( ) ) ;
941+ received_patches_clone. lock ( ) . await . push ( msg. data . 0 . clone ( ) ) ;
942942 msg. ack ( ) ;
943943 }
944944 } ) ;
@@ -987,15 +987,15 @@ mod tests {
987987 let state = MyState { numbers } ;
988988 let system = System :: try_from ( state) . unwrap ( ) ;
989989
990- let ( tx, mut rx) = sync:: channel :: < Patch > ( 1 ) ;
990+ let ( tx, mut rx) = sync:: channel :: < ( Patch , Option < Value > ) > ( 1 ) ;
991991 let channel = Channel :: from ( tx) ;
992992
993993 // Spawn a task to receive and acknowledge messages
994994 let received_patches = Arc :: new ( tokio:: sync:: Mutex :: new ( Vec :: new ( ) ) ) ;
995995 let received_patches_clone = received_patches. clone ( ) ;
996996 let ack_task = tokio:: spawn ( async move {
997997 while let Some ( msg) = rx. recv ( ) . await {
998- received_patches_clone. lock ( ) . await . push ( msg. data . clone ( ) ) ;
998+ received_patches_clone. lock ( ) . await . push ( msg. data . 0 . clone ( ) ) ;
999999 msg. ack ( ) ;
10001000 }
10011001 } ) ;
@@ -1080,7 +1080,7 @@ mod tests {
10801080 } )
10811081 . unwrap ( ) ;
10821082
1083- let ( tx, mut rx) = sync:: channel :: < Patch > ( 1 ) ;
1083+ let ( tx, mut rx) = sync:: channel :: < ( Patch , Option < Value > ) > ( 1 ) ;
10841084 let channel = Channel :: from ( tx) ;
10851085
10861086 let received = Arc :: new ( tokio:: sync:: Mutex :: new ( Vec :: new ( ) ) ) ;
@@ -1101,18 +1101,19 @@ mod tests {
11011101
11021102 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 10 ) ) . await ;
11031103
1104- let patches = received. lock ( ) . await ;
1105- assert_eq ! ( patches. len( ) , 1 ) ;
1104+ let messages = received. lock ( ) . await ;
1105+ assert_eq ! ( messages. len( ) , 1 ) ;
1106+ let ( patch, checkpoint) = & messages[ 0 ] ;
11061107 assert_eq ! (
1107- patches [ 0 ] ,
1108+ * patch ,
11081109 serde_json:: from_value:: <Patch >( json!( [
11091110 { "op" : "add" , "path" : "/numbers/0" , "value" : 10 } ,
11101111 ] ) )
11111112 . unwrap( )
11121113 ) ;
1113- drop ( patches ) ;
1114-
1115- assert_eq ! ( channel . checkpoint ( ) . await , Some ( json! ( [ 10 ] ) ) ) ;
1114+ // commit() sends the new state value as the checkpoint
1115+ assert_eq ! ( * checkpoint , Some ( json! ( [ 10 ] ) ) ) ;
1116+ drop ( messages ) ;
11161117
11171118 drop ( channel) ;
11181119 ack_task. abort ( ) ;
@@ -1138,7 +1139,7 @@ mod tests {
11381139 } ;
11391140 let system = System :: try_from ( state) . unwrap ( ) ;
11401141
1141- let ( tx, mut rx) = sync:: channel :: < Patch > ( 1 ) ;
1142+ let ( tx, mut rx) = sync:: channel :: < ( Patch , Option < Value > ) > ( 1 ) ;
11421143 let channel = Channel :: from ( tx) ;
11431144
11441145 let received = Arc :: new ( tokio:: sync:: Mutex :: new ( Vec :: new ( ) ) ) ;
@@ -1159,18 +1160,19 @@ mod tests {
11591160
11601161 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 10 ) ) . await ;
11611162
1162- let patches = received. lock ( ) . await ;
1163- assert_eq ! ( patches. len( ) , 1 ) ;
1163+ let messages = received. lock ( ) . await ;
1164+ assert_eq ! ( messages. len( ) , 1 ) ;
1165+ let ( patch, checkpoint) = & messages[ 0 ] ;
11641166 assert_eq ! (
1165- patches [ 0 ] ,
1167+ * patch ,
11661168 serde_json:: from_value:: <Patch >( json!( [
11671169 { "op" : "add" , "path" : "/numbers/new" , "value" : 42 } ,
11681170 ] ) )
11691171 . unwrap( )
11701172 ) ;
1171- drop ( patches ) ;
1172-
1173- assert_eq ! ( channel . checkpoint ( ) . await , Some ( json! ( 42 ) ) ) ;
1173+ // commit() sends the committed value as the checkpoint
1174+ assert_eq ! ( * checkpoint , Some ( json! ( 42 ) ) ) ;
1175+ drop ( messages ) ;
11741176
11751177 drop ( channel) ;
11761178 ack_task. abort ( ) ;
0 commit comments