Skip to content

Commit

Permalink
Use unique listeningPort to workaround dial error
Browse files Browse the repository at this point in the history
  • Loading branch information
mhchia committed Aug 21, 2018
1 parent f011b97 commit 22d2037
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
// gologging "github.com/whyrusleeping/go-logging"
)

var nodeCount int

func makeUnbootstrappedNode(t *testing.T, ctx context.Context, number int) *Node {
return makeTestingNode(t, ctx, number, false, nil)
}
Expand All @@ -22,8 +24,12 @@ func makeTestingNode(
number int,
doBootstrapping bool,
bootstrapPeers []pstore.PeerInfo) *Node {
listeningPort := number + 10000
node, err := makeNode(ctx, listeningPort, int64(number), doBootstrapping, bootstrapPeers)
// FIXME:
// 1. Use 20000 to avoid conflitcs with the running nodes in the environment
// 2. Avoid reuse of listeningPort in the entire test, to avoid `dial error`s
listeningPort := 20000 + nodeCount
nodeCount++
node, err := makeNode(ctx, listeningPort, number, doBootstrapping, bootstrapPeers)
if err != nil {
t.Error("Failed to create node")
}
Expand Down

0 comments on commit 22d2037

Please sign in to comment.