|
1 | 1 | use crate::common::mock_application::MockApplication; |
2 | 2 | use crate::common::mock_counterparty::MockCounterparty; |
| 3 | +use crate::common::session_assertions::SessionAssertions; |
3 | 4 | use crate::common::test_messages::TestMessage; |
4 | 5 | use hotfix::application::ApplicationRef; |
5 | 6 | use hotfix::config::SessionConfig; |
6 | | -use hotfix::session::SessionRef; |
| 7 | +use hotfix::session::{SessionRef, Status}; |
7 | 8 | use hotfix::store::in_memory::InMemoryMessageStore; |
8 | 9 | use hotfix_message::Part; |
9 | 10 | use hotfix_message::fix44::MSG_TYPE; |
@@ -56,16 +57,18 @@ async fn test_heartbeats() { |
56 | 57 | /// if no response is received within the timeout period. |
57 | 58 | #[tokio::test(start_paused = true)] |
58 | 59 | async fn test_peer_timeout() { |
59 | | - let (_session, mut mock_counterparty) = setup().await; |
| 60 | + let (session, mut mock_counterparty) = setup().await; |
60 | 61 | let peer_interval = (1.2 * HEARTBEAT_INTERVAL as f64) as u64 + 1; |
61 | 62 |
|
62 | 63 | // assert that a logon message is received (type 'A') |
63 | 64 | mock_counterparty |
64 | 65 | .assert_next(|msg| assert_eq!(msg.header().get::<&str>(MSG_TYPE).unwrap(), "A")) |
65 | 66 | .await; |
| 67 | + session.assert_status(Status::AwaitingLogon).await; |
| 68 | + |
66 | 69 | // counterparty responds with a logon to establish a happy session |
67 | 70 | mock_counterparty.send_logon().await; |
68 | | - tokio::task::yield_now().await; |
| 71 | + session.assert_status(Status::Active).await; |
69 | 72 |
|
70 | 73 | // let's wait enough time for a heartbeat and assert that the heartbeat was sent |
71 | 74 | tokio::time::advance(std::time::Duration::from_secs(HEARTBEAT_INTERVAL + 1)).await; |
|
0 commit comments