Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrects ResetOnLogon for initiators #635

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected] 5001 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 5001 $(STORE) "definitions/server/$@/*.def"
fix41:
cd _test; ./runat.sh [email protected] 5002 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 5002 $(STORE) "definitions/server/$@/*.def"
fix42:
cd _test; ./runat.sh [email protected] 5003 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 5003 $(STORE) "definitions/server/$@/*.def"
fix43:
cd _test; ./runat.sh [email protected] 5004 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 5004 $(STORE) "definitions/server/$@/*.def"
fix44:
cd _test; ./runat.sh [email protected] 5005 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 5005 $(STORE) "definitions/server/$@/*.def"
fix50:
cd _test; ./runat.sh [email protected] 5006 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 5006 $(STORE) "definitions/server/$@/*.def"
fix50sp1:
cd _test; ./runat.sh [email protected] 5007 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 5007 $(STORE) "definitions/server/$@/*.def"
fix50sp2:
cd _test; ./runat.sh [email protected] 5008 $(STORE_TYPE) "definitions/server/$@/*.def"
cd _test; ./runat.sh [email protected] 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
Loading