1- use crate :: config:: { SessionConfig , VerificationConfig } ;
1+ use crate :: config:: SessionConfig ;
2+ use crate :: message:: ResendRequest ;
23use crate :: message:: logout:: Logout ;
34use crate :: message:: reject:: Reject ;
45use crate :: message:: sequence_reset:: SequenceReset ;
56use crate :: message:: verification_issue:: { CompIdType , MessageError , VerificationIssue } ;
6- use crate :: message:: { ResendRequest , is_admin} ;
77use crate :: session:: error:: SessionOperationError ;
88use hotfix_message:: Part ;
99use hotfix_message:: field_types:: Timestamp ;
@@ -22,7 +22,6 @@ const SENDING_TIME_THRESHOLD: u64 = 120;
2222pub ( crate ) struct VerificationFlags {
2323 pub ( crate ) check_too_high : bool ,
2424 pub ( crate ) check_too_low : bool ,
25- #[ allow( dead_code) ]
2625 pub ( crate ) check_orig_sending_time : bool ,
2726}
2827
@@ -43,36 +42,28 @@ impl VerificationFlags {
4342 self . check_too_high || self . check_too_low
4443 }
4544
46- pub ( crate ) fn for_message (
47- message : & Message ,
48- user_config : & VerificationConfig ,
49- ) -> Result < Self , SessionOperationError > {
45+ pub ( crate ) fn for_message ( message : & Message ) -> Result < Self , SessionOperationError > {
5046 let message_type: & str = message
5147 . header ( )
5248 . get ( MSG_TYPE )
5349 . map_err ( |_| SessionOperationError :: MissingField ( "MSG_TYPE" ) ) ?;
5450
5551 let possible_duplicate = message. header ( ) . get :: < bool > ( POSS_DUP_FLAG ) . unwrap_or ( false ) ;
56- let check_orig_sending_time = if is_admin ( message_type) {
57- possible_duplicate && user_config. check_orig_sending_time_for_admin
58- } else {
59- possible_duplicate
60- } ;
6152
6253 let flags = match message_type {
6354 // check_too_high=false: QFJ-673 deadlock fix. When both sides send
6455 // ResendRequest simultaneously, each side's ResendRequest will have a seq
6556 // number higher than expected. By not treating that as an error, we allow
6657 // the ResendRequest to be processed.
6758 ResendRequest :: MSG_TYPE | Reject :: MSG_TYPE => {
68- Self :: new ( false , true , check_orig_sending_time )
59+ Self :: new ( false , true , possible_duplicate )
6960 }
70- Logout :: MSG_TYPE => Self :: new ( false , false , check_orig_sending_time ) ,
61+ Logout :: MSG_TYPE => Self :: new ( false , false , possible_duplicate ) ,
7162 SequenceReset :: MSG_TYPE => {
7263 let is_gap_fill: bool = message. get ( GAP_FILL_FLAG ) . unwrap_or ( false ) ;
73- Self :: new ( is_gap_fill, is_gap_fill, check_orig_sending_time )
64+ Self :: new ( is_gap_fill, is_gap_fill, false )
7465 }
75- _ => Self :: new ( true , true , check_orig_sending_time ) ,
66+ _ => Self :: new ( true , true , possible_duplicate ) ,
7667 } ;
7768
7869 Ok ( flags)
@@ -246,8 +237,8 @@ fn check_target_comp_id(
246237
247238#[ cfg( test) ]
248239mod tests {
249- use super :: { Message , SessionConfig , VerificationConfig , VerificationFlags , verify_message} ;
250- use crate :: message:: heartbeat :: Heartbeat ;
240+ use super :: { Message , SessionConfig , VerificationFlags , verify_message} ;
241+ use crate :: message:: sequence_reset :: SequenceReset ;
251242 use crate :: message:: verification_issue:: { CompIdType , MessageError , VerificationIssue } ;
252243 use hotfix_message:: field_types:: Timestamp ;
253244 use hotfix_message:: { Part , fix44} ;
@@ -267,7 +258,6 @@ mod tests {
267258 reconnect_interval : 0 ,
268259 reset_on_logon : false ,
269260 schedule : None ,
270- verification : VerificationConfig :: default ( ) ,
271261 }
272262 }
273263
@@ -296,62 +286,47 @@ mod tests {
296286 }
297287
298288 #[ test]
299- fn test_creating_flags_for_admin_message_should_check_orig_sending_time_when_enabled ( ) {
300- let mut msg =
301- build_test_message_with_type ( "FIX.4.4" , Heartbeat :: MSG_TYPE , "TARGET" , "SENDER" , 42 ) ;
302- msg. header_mut ( ) . set ( fix44:: POSS_DUP_FLAG , true ) ;
303-
304- let flags = VerificationFlags :: for_message ( & msg, & VerificationConfig :: default ( ) ) . unwrap ( ) ;
305-
306- assert ! ( flags. check_orig_sending_time) ;
307- assert ! ( flags. check_too_high) ;
308- assert ! ( flags. check_too_low) ;
309- }
310-
311- #[ test]
312- fn test_creating_flags_for_admin_message_should_skip_check_orig_sending_time_when_not_poss_dup ( )
313- {
314- let msg =
315- build_test_message_with_type ( "FIX.4.4" , Heartbeat :: MSG_TYPE , "TARGET" , "SENDER" , 42 ) ;
289+ fn test_creating_flags_for_gap_fill_message_should_skip_check_orig_sending_time ( ) {
290+ let msg = build_test_message_with_type (
291+ "FIX.4.4" ,
292+ SequenceReset :: MSG_TYPE ,
293+ "TARGET" ,
294+ "SENDER" ,
295+ 42 ,
296+ ) ;
316297
317- let flags = VerificationFlags :: for_message ( & msg, & VerificationConfig :: default ( ) ) . unwrap ( ) ;
298+ let flags = VerificationFlags :: for_message ( & msg) . unwrap ( ) ;
318299
319300 assert ! ( !flags. check_orig_sending_time) ;
320- assert ! ( flags. check_too_high) ;
321- assert ! ( flags. check_too_low) ;
301+ assert ! ( ! flags. check_too_high) ;
302+ assert ! ( ! flags. check_too_low) ;
322303 }
323304
324305 #[ test]
325- fn test_creating_flags_for_admin_message_should_skip_check_orig_sending_time_when_disabled ( ) {
326- let mut msg =
327- build_test_message_with_type ( "FIX.4.4" , Heartbeat :: MSG_TYPE , "TARGET" , "SENDER" , 42 ) ;
306+ fn test_creating_flags_for_gap_fill_message_should_skip_check_orig_sending_time_even_for_poss_duplicate ( )
307+ {
308+ let mut msg = build_test_message_with_type (
309+ "FIX.4.4" ,
310+ SequenceReset :: MSG_TYPE ,
311+ "TARGET" ,
312+ "SENDER" ,
313+ 42 ,
314+ ) ;
328315 msg. header_mut ( ) . set ( fix44:: POSS_DUP_FLAG , true ) ;
329316
330- let flags = VerificationFlags :: for_message (
331- & msg,
332- & VerificationConfig {
333- check_orig_sending_time_for_admin : false ,
334- } ,
335- )
336- . unwrap ( ) ;
317+ let flags = VerificationFlags :: for_message ( & msg) . unwrap ( ) ;
337318
338319 assert ! ( !flags. check_orig_sending_time) ;
339- assert ! ( flags. check_too_high) ;
340- assert ! ( flags. check_too_low) ;
320+ assert ! ( ! flags. check_too_high) ;
321+ assert ! ( ! flags. check_too_low) ;
341322 }
342323
343324 #[ test]
344325 fn test_creating_flags_for_app_messages_does_not_skip_orig_sending_time ( ) {
345326 let mut msg = build_test_message ( "FIX.4.4" , "TARGET" , "SENDER" , 42 ) ;
346327 msg. header_mut ( ) . set ( fix44:: POSS_DUP_FLAG , true ) ;
347328
348- let flags = VerificationFlags :: for_message (
349- & msg,
350- & VerificationConfig {
351- check_orig_sending_time_for_admin : false ,
352- } ,
353- )
354- . unwrap ( ) ;
329+ let flags = VerificationFlags :: for_message ( & msg) . unwrap ( ) ;
355330
356331 assert ! ( flags. check_orig_sending_time) ;
357332 assert ! ( flags. check_too_high) ;
@@ -362,13 +337,7 @@ mod tests {
362337 fn test_creating_flags_for_app_messages_skip_orig_sending_time_when_it_is_not_poss_dup ( ) {
363338 let msg = build_test_message ( "FIX.4.4" , "TARGET" , "SENDER" , 42 ) ;
364339
365- let flags = VerificationFlags :: for_message (
366- & msg,
367- & VerificationConfig {
368- check_orig_sending_time_for_admin : true ,
369- } ,
370- )
371- . unwrap ( ) ;
340+ let flags = VerificationFlags :: for_message ( & msg) . unwrap ( ) ;
372341
373342 assert ! ( !flags. check_orig_sending_time) ;
374343 assert ! ( flags. check_too_high) ;
0 commit comments