@@ -12,21 +12,15 @@ mod common;
1212
1313const HEARTBEAT_INTERVAL : u64 = 30 ;
1414
15- #[ tokio:: test]
16- async fn test_happy_login_flow ( ) {
17- let ( session, mut mock_counterparty) = setup ( ) . await ;
18-
19- // assert that a logon message is received (type 'A')
20- mock_counterparty
21- . assert_next ( |msg| assert_eq ! ( msg. header( ) . get:: <& str >( MSG_TYPE ) . unwrap( ) , "A" ) )
22- . await ;
23-
24- session
25- . disconnect ( "Test Session Finished" . to_string ( ) )
26- . await ;
27- mock_counterparty. assert_disconnected ( ) . await ;
28- }
29-
15+ /// Tests the automatic heartbeat mechanism in an active FIX session:
16+ /// 1. Establishes a session by exchanging logon messages with the counterparty
17+ /// 2. Advances time beyond the configured heartbeat interval
18+ /// 3. Verifies that a heartbeat message (type '0') is automatically sent
19+ /// 4. Cleanly disconnects the session
20+ ///
21+ /// This test ensures that the session maintains connectivity by sending
22+ /// periodic heartbeat messages when no other messages are being exchanged,
23+ /// as required by the FIX protocol to prevent timeout disconnections.
3024#[ tokio:: test( start_paused = true ) ]
3125async fn test_heartbeats ( ) {
3226 let ( session, mut mock_counterparty) = setup ( ) . await ;
@@ -51,6 +45,15 @@ async fn test_heartbeats() {
5145 mock_counterparty. assert_disconnected ( ) . await ;
5246}
5347
48+ /// Tests the peer timeout and disconnection mechanism:
49+ /// 1. Establishes a session by exchanging logon messages
50+ /// 2. Simulates peer inactivity by advancing time past the peer timeout threshold
51+ /// 3. Verifies that a TestRequest message is sent to check peer responsiveness
52+ /// 4. Continues to simulate peer silence and verifies automatic disconnection
53+ ///
54+ /// This test ensures the session properly handles unresponsive peers by first
55+ /// attempting to verify connectivity with a TestRequest, then disconnecting
56+ /// if no response is received within the timeout period.
5457#[ tokio:: test( start_paused = true ) ]
5558async fn test_peer_timeout ( ) {
5659 let ( _session, mut mock_counterparty) = setup ( ) . await ;
0 commit comments