Skip to content

Commit e55db86

Browse files
committed
Add test case for happy logon flow
1 parent a52fb36 commit e55db86

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

crates/hotfix/tests/session_test_cases/heartbeat_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async fn test_heartbeats() {
2323
.await;
2424
// counterparty responds with a logon to establish a happy session
2525
mock_counterparty.send_logon().await;
26-
tokio::task::yield_now().await;
26+
session.assert_status(Status::Active).await;
2727

2828
// let's wait enough time for a heartbeat and assert that the heartbeat was sent
2929
tokio::time::advance(std::time::Duration::from_secs(HEARTBEAT_INTERVAL + 1)).await;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use crate::common::session_assertions::SessionAssertions;
2+
use crate::common::setup::setup;
3+
use hotfix::session::Status;
4+
use hotfix_message::Part;
5+
use hotfix_message::fix44::MSG_TYPE;
6+
7+
/// Tests successful FIX session establishment via logon message exchange.
8+
/// Verifies that a session sends a logon message, receives a response,
9+
/// transitions to Active status, and disconnects cleanly.
10+
#[tokio::test]
11+
async fn test_happy_logon() {
12+
let (session, mut mock_counterparty) = setup().await;
13+
14+
// assert that a logon message is received (type 'A')
15+
mock_counterparty
16+
.assert_next(|msg| assert_eq!(msg.header().get::<&str>(MSG_TYPE).unwrap(), "A"))
17+
.await;
18+
// counterparty responds with a logon to establish a happy session
19+
mock_counterparty.send_logon().await;
20+
session.assert_status(Status::Active).await;
21+
22+
session
23+
.disconnect("Test Session Finished".to_string())
24+
.await;
25+
mock_counterparty.assert_disconnected().await;
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
mod heartbeat_tests;
2+
mod logon_tests;

0 commit comments

Comments
 (0)