@@ -418,6 +418,36 @@ func (s *MessageSuite) TestReBuildWithRepeatingGroupForResend() {
418418 s .True (bytes .Equal (expectedBytes , resendBytes ), "Unexpected bytes,\n expected: %s\n but was: %s" , expectedBytes , resendBytes )
419419}
420420
421+ func (s * MessageSuite ) TestReBuildWithRepeatingGroupMultipleEntriesInGroupForResend () {
422+ // Given the following message with a repeating group that has 2 entries
423+ origHeader := "8=FIXT.1.19=18435=834=349=ISLD52=20240415-03:43:17.92356=TW"
424+ origBody := "6=1.0011=114=1.0017=131=1.0032=1.0037=138=1.0039=254=155=1150=2151=0.00453=2448=xyzzy447=D452=1448=foobar447=D452=3"
425+ origTrailer := "10=152"
426+ rawMsg := bytes .NewBufferString (origHeader + origBody + origTrailer )
427+
428+ // When I reparse the message from the store during a resend request
429+ s .Nil (ParseMessage (s .msg , rawMsg ))
430+
431+ // And I update the headers for resend
432+ s .msg .Header .SetField (tagOrigSendingTime , FIXString ("20240415-03:43:17.923" ))
433+ s .msg .Header .SetField (tagSendingTime , FIXString ("20240415-14:41:23.456" ))
434+ s .msg .Header .SetField (tagPossDupFlag , FIXBoolean (true ))
435+
436+ // The bodyBytes will still be correct
437+ origBodyBytes := []byte (origBody )
438+ s .True (bytes .Equal (origBodyBytes , s .msg .bodyBytes ), "Incorrect body bytes, \n expected: %s\n but was: %s" , origBodyBytes , s .msg .bodyBytes )
439+
440+ // So when I combine the updated header + the original bodyBytes + the as-is trailer
441+ resendBytes := s .msg .buildWithBodyBytes (origBodyBytes )
442+
443+ // Then the reparsed, rebuilt message will retain the correct ordering of repeating group tags during resend
444+ expectedResendHeader := "8=FIXT.1.19=21535=834=343=Y49=ISLD52=20240415-14:41:23.45656=TW122=20240415-03:43:17.923"
445+ expectedResendBody := "6=1.0011=114=1.0017=131=1.0032=1.0037=138=1.0039=254=155=1150=2151=0.00453=2448=xyzzy447=D452=1448=foobar447=D452=3"
446+ expectedResendTrailer := "10=147"
447+ expectedResendBytes := []byte (expectedResendHeader + expectedResendBody + expectedResendTrailer )
448+ s .True (bytes .Equal (expectedResendBytes , resendBytes ), "Unexpected bytes,\n expected: %s\n but was: %s" , expectedResendBytes , resendBytes )
449+ }
450+
421451func (s * MessageSuite ) TestReverseRoute () {
422452 s .Nil (ParseMessage (s .msg , bytes .NewBufferString ("8=FIX.4.29=17135=D34=249=TW50=KK52=20060102-15:04:0556=ISLD57=AP144=BB115=JCD116=CS128=MG129=CB142=JV143=RY145=BH11=ID21=338=10040=w54=155=INTC60=20060102-15:04:0510=123" )))
423453
0 commit comments