|
1 | | -use crate::common::mock_application::MockApplication; |
2 | | -use crate::common::mock_counterparty::MockCounterparty; |
3 | 1 | use crate::common::session_assertions::SessionAssertions; |
4 | | -use crate::common::test_messages::TestMessage; |
5 | | -use hotfix::application::ApplicationRef; |
6 | | -use hotfix::config::SessionConfig; |
7 | | -use hotfix::session::{SessionRef, Status}; |
8 | | -use hotfix::store::in_memory::InMemoryMessageStore; |
| 2 | +use crate::common::setup::{HEARTBEAT_INTERVAL, setup}; |
| 3 | +use hotfix::session::Status; |
9 | 4 | use hotfix_message::Part; |
10 | 5 | use hotfix_message::fix44::MSG_TYPE; |
11 | 6 |
|
12 | | -const HEARTBEAT_INTERVAL: u64 = 30; |
13 | | - |
14 | 7 | /// Tests the automatic heartbeat mechanism in an active FIX session: |
15 | 8 | /// 1. Establishes a session by exchanging logon messages with the counterparty |
16 | 9 | /// 2. Advances time beyond the configured heartbeat interval |
@@ -88,41 +81,3 @@ async fn test_peer_timeout() { |
88 | 81 | tokio::time::advance(std::time::Duration::from_secs(peer_interval)).await; |
89 | 82 | mock_counterparty.assert_disconnected().await; |
90 | 83 | } |
91 | | - |
92 | | -async fn setup() -> (SessionRef<TestMessage>, MockCounterparty<TestMessage>) { |
93 | | - let config = create_session_config(); |
94 | | - let counterparty_config = create_counterparty_session_config(config.clone()); |
95 | | - |
96 | | - let application_ref = ApplicationRef::new(MockApplication {}); |
97 | | - let message_store = InMemoryMessageStore::default(); |
98 | | - |
99 | | - let session = SessionRef::new(config, application_ref, message_store); |
100 | | - let mock_counterparty = MockCounterparty::start(session.clone(), counterparty_config).await; |
101 | | - |
102 | | - (session, mock_counterparty) |
103 | | -} |
104 | | - |
105 | | -fn create_session_config() -> SessionConfig { |
106 | | - SessionConfig { |
107 | | - begin_string: "FIX.4.4".to_string(), |
108 | | - sender_comp_id: "dummy-initiator".to_string(), |
109 | | - target_comp_id: "dummy-acceptor".to_string(), |
110 | | - data_dictionary_path: None, |
111 | | - connection_host: "".to_string(), |
112 | | - connection_port: 0, |
113 | | - tls_config: None, |
114 | | - heartbeat_interval: HEARTBEAT_INTERVAL, |
115 | | - reconnect_interval: 30, |
116 | | - reset_on_logon: false, |
117 | | - schedule: None, |
118 | | - } |
119 | | -} |
120 | | - |
121 | | -/// Create a session configuration for the counterparty from our configuration. |
122 | | -fn create_counterparty_session_config(session_config: SessionConfig) -> SessionConfig { |
123 | | - SessionConfig { |
124 | | - sender_comp_id: session_config.target_comp_id.clone(), |
125 | | - target_comp_id: session_config.sender_comp_id.clone(), |
126 | | - ..session_config |
127 | | - } |
128 | | -} |
0 commit comments