@@ -370,3 +370,43 @@ async fn test_message_with_sending_time_too_old_is_rejected() {
370370 when ( & session) . requests_disconnect ( ) . await ;
371371 then ( & mut counterparty) . gets_disconnected ( ) . await ;
372372}
373+
374+ /// Tests that a message with PossDupFlag=Y but missing OrigSendingTime is rejected.
375+ ///
376+ /// When PossDupFlag is set to Y, OrigSendingTime (tag 122) is required.
377+ /// The session should reject with SessionRejectReason = 1 (RequiredTagMissing).
378+ #[ tokio:: test]
379+ async fn test_scenario_2g_possdup_without_orig_sending_time ( ) {
380+ let ( mut session, mut counterparty) = given_an_active_session ( ) . await ;
381+
382+ // a valid execution report is sent and processed normally
383+ let seq_number = counterparty. next_target_sequence_number ( ) ;
384+ when ( & mut counterparty)
385+ . sends_message ( TestMessage :: dummy_execution_report ( ) )
386+ . await ;
387+ then ( & mut session)
388+ . target_sequence_number_reaches ( seq_number)
389+ . await ;
390+
391+ // the message is resent with PossDupFlag=Y but without OrigSendingTime
392+ when ( & mut counterparty)
393+ . sends_raw_message ( build_execution_report_with_missing_orig_sending_time (
394+ seq_number,
395+ ) )
396+ . await ;
397+
398+ // then we send a reject with SessionRejectReason = 1 (RequiredTagMissing)
399+ then ( & mut counterparty)
400+ . receives ( |msg| {
401+ assert_msg_type ( msg, MsgType :: Reject ) ;
402+ assert_eq ! (
403+ msg. get:: <SessionRejectReason >( SESSION_REJECT_REASON )
404+ . unwrap( ) ,
405+ SessionRejectReason :: RequiredTagMissing
406+ ) ;
407+ } )
408+ . await ;
409+
410+ when ( & session) . requests_disconnect ( ) . await ;
411+ then ( & mut counterparty) . gets_disconnected ( ) . await ;
412+ }
0 commit comments