From 1523a16ef01643cf8776e09ca8537502f1c4befd Mon Sep 17 00:00:00 2001
From: josh <josh@elixxir.io>
Date: Tue, 8 Sep 2020 14:15:08 -0700
Subject: [PATCH] Change interconnect service to run on a different port for
 tests

---
 node/endpoint.go | 18 +++++++++---------
 node/handler.go  | 10 ++++++++--
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/node/endpoint.go b/node/endpoint.go
index 669ca0d6..d014c55f 100644
--- a/node/endpoint.go
+++ b/node/endpoint.go
@@ -44,14 +44,14 @@ func (s *Comms) CreateNewRound(ctx context.Context, msg *messages.AuthenticatedM
 	// Verify the message authentication
 	authState, err := s.AuthenticatedReceiver(msg)
 	if err != nil {
-		return  &messages.Ack{}, errors.Errorf("Unable handles reception of AuthenticatedMessage: %+v", err)
+		return &messages.Ack{}, errors.Errorf("Unable handles reception of AuthenticatedMessage: %+v", err)
 	}
 
 	// Unnmarshall the any message to the message type needed
 	roundInfoMsg := &pb.RoundInfo{}
 	err = ptypes.UnmarshalAny(msg.Message, roundInfoMsg)
 	if err != nil {
-		return  &messages.Ack{}, errors.New(err.Error())
+		return &messages.Ack{}, errors.New(err.Error())
 	}
 
 	// Call the server handler to start a new round
@@ -127,18 +127,18 @@ func (s *Comms) PostRoundPublicKey(ctx context.Context,
 	// Verify the message authentication
 	authState, err := s.AuthenticatedReceiver(msg)
 	if err != nil {
-		return  &messages.Ack{}, errors.Errorf("Unable handles reception of AuthenticatedMessage: %+v", err)
+		return &messages.Ack{}, errors.Errorf("Unable handles reception of AuthenticatedMessage: %+v", err)
 	}
 	//Marshall the any message to the message type needed
 	publicKeyMsg := &pb.RoundPublicKey{}
 	err = ptypes.UnmarshalAny(msg.Message, publicKeyMsg)
 	if err != nil {
-		return  &messages.Ack{}, errors.New(err.Error())
+		return &messages.Ack{}, errors.New(err.Error())
 	}
 
 	err = s.handler.PostRoundPublicKey(publicKeyMsg, authState)
 	if err != nil {
-		return  &messages.Ack{}, errors.New(err.Error())
+		return &messages.Ack{}, errors.New(err.Error())
 	}
 	return &messages.Ack{}, nil
 }
@@ -340,12 +340,12 @@ func (s *Comms) Poll(ctx context.Context, msg *messages.AuthenticatedMessage) (*
 func (s *Comms) RoundError(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error) {
 	authState, err := s.AuthenticatedReceiver(msg)
 	if err != nil {
-		return  &messages.Ack{}, errors.Errorf("Unable to handle reception of AuthenticatedMessage: %+v", err)
+		return &messages.Ack{}, errors.Errorf("Unable to handle reception of AuthenticatedMessage: %+v", err)
 	}
 	errMsg := &pb.RoundError{}
 	err = ptypes.UnmarshalAny(msg.Message, errMsg)
 	if err != nil {
-		return  &messages.Ack{}, err
+		return &messages.Ack{}, err
 	}
 
 	return &messages.Ack{}, s.handler.RoundError(errMsg, authState)
@@ -355,13 +355,13 @@ func (s *Comms) SendRoundTripPing(ctx context.Context, msg *messages.Authenticat
 	// Verify the message authentication
 	authState, err := s.AuthenticatedReceiver(msg)
 	if err != nil {
-		return  &messages.Ack{}, errors.Errorf("Unable handles reception of AuthenticatedMessage: %+v", err)
+		return &messages.Ack{}, errors.Errorf("Unable handles reception of AuthenticatedMessage: %+v", err)
 	}
 	//Marshall the any message to the message type needed
 	roundTripPing := &pb.RoundTripPing{}
 	err = ptypes.UnmarshalAny(msg.Message, roundTripPing)
 	if err != nil {
-		return  &messages.Ack{}, err
+		return &messages.Ack{}, err
 	}
 
 	err = s.handler.SendRoundTripPing(roundTripPing, authState)
diff --git a/node/handler.go b/node/handler.go
index 12f8de8b..83763a30 100644
--- a/node/handler.go
+++ b/node/handler.go
@@ -53,8 +53,14 @@ func StartNode(id *id.ID, localServer string, handler Handler,
 			return
 		}
 		newPort, err := strconv.Atoi(port)
-		newPort++
-		interconnect.StartCMixInterconnect(id, string(newPort), handler, certPEMblock, keyPEMblock)
+		if err != nil {
+			jww.WARN.Printf("Unable to start consensus node: Unparseable port: %v", err)
+			return
+		}
+		newPort = newPort + 1
+		interconnectPort := strconv.Itoa(newPort)
+
+		interconnect.StartCMixInterconnect(id, interconnectPort, handler, certPEMblock, keyPEMblock)
 	}()
 
 	go func() {
-- 
GitLab