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

Fix Send(Messagable) which does not account for TargetSubID & SenderSubID #514

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,24 @@ func Send(m Messagable) (err error) {
return err
}

var targetSubID FIXString
msg.Header.GetField(tagTargetSubID, &targetSubID)

var senderCompID FIXString
if err := msg.Header.GetField(tagSenderCompID, &senderCompID); err != nil {
return err
}

sessionID := SessionID{BeginString: string(beginString), TargetCompID: string(targetCompID), SenderCompID: string(senderCompID)}
var senderSubID FIXString
msg.Header.GetField(tagSenderSubID, &senderSubID)

sessionID := SessionID{
BeginString: string(beginString),
TargetCompID: string(targetCompID),
TargetSubID: string(targetSubID),
SenderCompID: string(senderCompID),
SenderSubID: string(senderSubID),
}

return SendToTarget(msg, sessionID)
}
Expand Down
56 changes: 56 additions & 0 deletions registry_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) quickfixengine.org All rights reserved.
//
// This file may be distributed under the terms of the quickfixengine.org
// license as defined by quickfixengine.org and appearing in the file
// LICENSE included in the packaging of this file.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
// THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE.
//
// See http://www.quickfixengine.org/LICENSE for licensing information.
//
// Contact ask@quickfixengine.org if any conditions of this licensing
// are not clear to you.

package quickfix

import (
"errors"
"testing"
)

func TestPR514(t *testing.T) {
sessionID := SessionID{
BeginString: BeginStringFIX42,
TargetCompID: "BigCorp",
TargetSubID: "acceptor",
SenderCompID: "SmallCorp",
SenderSubID: "initiator",
}
storeFactory := NewMemoryStoreFactory()
store, err := storeFactory.Create(sessionID)
if err != nil {
t.Error(err)
}
s := &session{
sessionID: sessionID,
store: store,
}
if err := registerSession(s); err != nil {
t.Error(err)
}

msg := NewMessage()
msg.Header.SetString(tagBeginString, sessionID.BeginString)
msg.Header.SetString(tagTargetCompID, sessionID.TargetCompID)
msg.Header.SetString(tagTargetSubID, sessionID.TargetSubID)
msg.Header.SetString(tagSenderCompID, sessionID.SenderCompID)
msg.Header.SetString(tagSenderSubID, sessionID.SenderSubID)

if err := Send(msg); err != nil {
if errors.Is(err, errUnknownSession) {
t.Errorf("Unable to find registered session: %s", err)
}
}
}
Loading