@@ -916,19 +916,32 @@ fn dtls12_reciprocal_close_notify_and_no_further_sends() {
916916 let ( mut client, mut server, now_hs) = setup_connected_12_pair ( now) ;
917917 now = now_hs;
918918
919+ assert ! ( !client. is_closing( ) ) ;
920+ assert ! ( !client. is_closed( ) ) ;
921+ assert ! ( !server. is_closing( ) ) ;
922+ assert ! ( !server. is_closed( ) ) ;
923+
919924 // Client sends close_notify
920925 client. close ( ) . unwrap ( ) ;
926+ assert ! ( client. is_closing( ) ) ;
927+ assert ! ( !client. is_closed( ) ) ;
928+
921929 now += Duration :: from_millis ( 10 ) ;
922930 client. handle_timeout ( now) . expect ( "client timeout" ) ;
923931 let client_out = drain_outputs ( & mut client) ;
924932 assert ! (
925933 !client_out. packets. is_empty( ) ,
926934 "Client should emit close_notify alert"
927935 ) ;
936+ assert ! ( !client. is_closing( ) ) ;
937+ assert ! ( client. is_closed( ) ) ;
928938
929939 // Deliver to server
930940 deliver_packets ( & client_out. packets , & mut server) ;
931941 server. handle_timeout ( now) . expect ( "server timeout" ) ;
942+ assert ! ( server. is_closing( ) ) ;
943+ assert ! ( !server. is_closed( ) ) ;
944+
932945 let server_out = drain_outputs ( & mut server) ;
933946
934947 // Server should emit CloseNotify event
@@ -942,17 +955,24 @@ fn dtls12_reciprocal_close_notify_and_no_further_sends() {
942955 !server_out. packets. is_empty( ) ,
943956 "Server should emit a reciprocal close_notify packet"
944957 ) ;
958+ assert ! ( !server. is_closing( ) ) ;
959+ assert ! ( server. is_closed( ) ) ;
945960
946961 // Deliver reciprocal back to client and verify it sees CloseNotify.
947962 deliver_packets ( & server_out. packets , & mut client) ;
948963 client
949964 . handle_timeout ( now)
950965 . expect ( "client timeout after reciprocal" ) ;
966+ assert ! ( client. is_closing( ) ) ;
967+ assert ! ( !client. is_closed( ) ) ;
968+
951969 let client_out2 = drain_outputs ( & mut client) ;
952970 assert ! (
953971 client_out2. close_notify,
954972 "Client should emit Output::CloseNotify after receiving reciprocal close_notify"
955973 ) ;
974+ assert ! ( !client. is_closing( ) ) ;
975+ assert ! ( client. is_closed( ) ) ;
956976
957977 // No half-close in DTLS 1.2: both sides must reject further sends.
958978 assert ! (
@@ -965,6 +985,44 @@ fn dtls12_reciprocal_close_notify_and_no_further_sends() {
965985 ) ;
966986}
967987
988+ #[ test]
989+ #[ cfg( feature = "rcgen" ) ]
990+ fn dtls12_close_state_matrix ( ) {
991+ let mut now = Instant :: now ( ) ;
992+ let ( mut client, mut server, now_hs) = setup_connected_12_pair ( now) ;
993+ now = now_hs;
994+
995+ assert ! ( !client. is_closing( ) ) ;
996+ assert ! ( !client. is_closed( ) ) ;
997+ assert ! ( !server. is_closing( ) ) ;
998+ assert ! ( !server. is_closed( ) ) ;
999+
1000+ client. close ( ) . unwrap ( ) ;
1001+ assert ! ( client. is_closing( ) , "local close pending" ) ;
1002+ assert ! ( !client. is_closed( ) , "local close not drained" ) ;
1003+
1004+ now += Duration :: from_millis ( 10 ) ;
1005+ client. handle_timeout ( now) . expect ( "client timeout" ) ;
1006+ let client_out = drain_outputs ( & mut client) ;
1007+ assert ! ( !client_out. packets. is_empty( ) , "local close_notify packet" ) ;
1008+ assert ! ( !client. is_closing( ) , "local close drained" ) ;
1009+ assert ! ( client. is_closed( ) , "local close terminal" ) ;
1010+
1011+ deliver_packets ( & client_out. packets , & mut server) ;
1012+ server. handle_timeout ( now) . expect ( "server timeout" ) ;
1013+ assert ! ( server. is_closing( ) , "remote close pending" ) ;
1014+ assert ! ( !server. is_closed( ) , "remote close not drained" ) ;
1015+
1016+ let server_out = drain_outputs ( & mut server) ;
1017+ assert ! ( server_out. close_notify, "remote CloseNotify event" ) ;
1018+ assert ! (
1019+ !server_out. packets. is_empty( ) ,
1020+ "remote reciprocal close_notify packet"
1021+ ) ;
1022+ assert ! ( !server. is_closing( ) , "remote close drained" ) ;
1023+ assert ! ( server. is_closed( ) , "remote close terminal" ) ;
1024+ }
1025+
9681026#[ test]
9691027#[ cfg( feature = "rcgen" ) ]
9701028fn dtls12_discard_pending_writes_on_close_notify ( ) {
0 commit comments