storj/pkg/transport/transport_test.go
Dennis Coyle ea077e4dcb
node-node communication (#145)
* node-node communication

* PR reviews comments from @bryanchriswhite addressed
2018-07-19 10:48:08 -04:00

50 lines
1.0 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package transport
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
proto "storj.io/storj/protos/overlay"
)
func TestDialNode(t *testing.T) {
oc := Transport{}
// node.Address.Address == "" condition test
node := proto.Node{
Id: "DUMMYID1",
Address: &proto.NodeAddress{
Transport: proto.NodeTransport_TCP,
Address: "",
},
}
conn, err := oc.DialNode(context.Background(), &node)
assert.Error(t, err)
assert.Nil(t, conn)
// node.Address == nil condition test
node = proto.Node{
Id: "DUMMYID2",
Address: nil,
}
conn, err = oc.DialNode(context.Background(), &node)
assert.Error(t, err)
assert.Nil(t, conn)
// node is valid argument condition test
node = proto.Node{
Id: "DUMMYID3",
Address: &proto.NodeAddress{
Transport: proto.NodeTransport_TCP,
Address: "127.0.0.0:9000",
},
}
conn, err = oc.DialNode(context.Background(), &node)
assert.NoError(t, err)
assert.NotNil(t, conn)
}