Skip to content

Commit

Permalink
Merge pull request #635 from ackleymi/initiator-logon-reset
Browse files Browse the repository at this point in the history
Corrects ResetOnLogon for initiators
  • Loading branch information
ackleymi authored Apr 30, 2024
2 parents c3c49cb + 0256864 commit c187bdb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,30 @@ lint: linters-install
# ---------------------------------------------------------------
# Targets related to running acceptance tests -

ifdef STORE_TYPE
STORE := $(STORE_TYPE)
else
STORE := memory
endif

build-test-srv:
cd _test; go build -o echo_server ./test-server/
cd _test; go build -v -o echo_server ./test-server/
fix40:
cd _test; ./runat.sh $@.cfg 5001 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5001 $(STORE) "definitions/server/$@/*.def"
fix41:
cd _test; ./runat.sh $@.cfg 5002 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5002 $(STORE) "definitions/server/$@/*.def"
fix42:
cd _test; ./runat.sh $@.cfg 5003 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5003 $(STORE) "definitions/server/$@/*.def"
fix43:
cd _test; ./runat.sh $@.cfg 5004 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5004 $(STORE) "definitions/server/$@/*.def"
fix44:
cd _test; ./runat.sh $@.cfg 5005 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5005 $(STORE) "definitions/server/$@/*.def"
fix50:
cd _test; ./runat.sh $@.cfg 5006 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5006 $(STORE) "definitions/server/$@/*.def"
fix50sp1:
cd _test; ./runat.sh $@.cfg 5007 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5007 $(STORE) "definitions/server/$@/*.def"
fix50sp2:
cd _test; ./runat.sh $@.cfg 5008 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh $@.cfg 5008 $(STORE) "definitions/server/$@/*.def"

ACCEPT_SUITE=fix40 fix41 fix42 fix43 fix44 fix50 fix50sp1 fix50sp2
accept: $(ACCEPT_SUITE)
Expand Down
3 changes: 1 addition & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ func (s *session) prepMessageForSend(msg *Message, inReplyTo *Message) (msgBytes
}

if isAdminMessageType(msgType) {
s.application.ToAdmin(msg, s.sessionID)

if bytes.Equal(msgType, msgTypeLogon) {
var resetSeqNumFlag FIXBoolean
if msg.Body.Has(tagResetSeqNumFlag) {
Expand All @@ -330,6 +328,7 @@ func (s *session) prepMessageForSend(msg *Message, inReplyTo *Message) (msgBytes
msg.Header.SetField(tagMsgSeqNum, FIXInt(seqNum))
}
}
s.application.ToAdmin(msg, s.sessionID)
} else {
if err = s.application.ToApp(msg, s.sessionID); err != nil {
return
Expand Down
8 changes: 8 additions & 0 deletions session_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ func (sm *stateMachine) Connect(session *session) {
return
}
}

if session.ResetOnLogon {
if err := session.store.Reset(); err != nil {
session.logError(err)
return
}
}

session.log.OnEvent("Sending logon request")
if err := session.sendLogon(); err != nil {
session.logError(err)
Expand Down
10 changes: 7 additions & 3 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,18 @@ func (s *SessionSuite) TestInitiateLogonResetSeqNumFlag() {
}
s.session.State = latentState{}
s.session.HeartBtInt = time.Duration(45) * time.Second
s.Require().Nil(s.store.Reset())
s.NextSenderMsgSeqNum(1)
s.NextTargetMsgSeqNum(1)
s.IncrNextTargetMsgSeqNum()
s.IncrNextSenderMsgSeqNum()
s.session.ResetOnLogon = true
s.session.InitiateLogon = true

s.NextSenderMsgSeqNum(2)
s.NextTargetMsgSeqNum(2)

s.MockApp.On("ToAdmin")
s.MockApp.decorateToAdmin = func(msg *Message) {
msg.Body.SetField(tagResetSeqNumFlag, FIXBoolean(true))
}
s.session.onAdmin(adminMsg)

s.MockApp.AssertExpectations(s.T())
Expand Down

0 comments on commit c187bdb

Please sign in to comment.