storj/pkg/transport/transport_test.go
Bryan White 2a0c4e60d2
preparing for use of customtype gogo extension with NodeID type (#693)
* preparing for use of `customtype` gogo extension with `NodeID` type

* review changes

* preparing for use of `customtype` gogo extension with `NodeID` type

* review changes

* wip

* tests passing

* wip fixing tests

* more wip test fixing

* remove NodeIDList from proto files

* linter fixes

* linter fixes

* linter/review fixes

* more freaking linter fixes

* omg just kill me - linterrrrrrrr

* travis linter, i will muder you and your family in your sleep

* goimports everything - burn in hell travis

* goimports update

* go mod tidy
2018-11-29 19:39:27 +01:00

61 lines
1.3 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package transport
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"storj.io/storj/internal/identity"
"storj.io/storj/internal/teststorj"
"storj.io/storj/pkg/pb"
)
var ctx = context.Background()
func TestDialNode(t *testing.T) {
ca, err := testidentity.NewTestCA(ctx)
assert.NoError(t, err)
identity, err := ca.NewIdentity()
assert.NoError(t, err)
oc := Transport{
identity: identity,
}
// node.Address.Address == "" condition test
node := pb.Node{
Id: teststorj.NodeIDFromString("DUMMYID1"),
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: "",
},
}
conn, err := oc.DialNode(ctx, &node)
assert.Error(t, err)
assert.Nil(t, conn)
// node.Address == nil condition test
node = pb.Node{
Id: teststorj.NodeIDFromString("DUMMYID2"),
Address: nil,
}
conn, err = oc.DialNode(ctx, &node)
assert.Error(t, err)
assert.Nil(t, conn)
// node is valid argument condition test
node = pb.Node{
Id: teststorj.NodeIDFromString("DUMMYID3"),
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: "127.0.0.0:9000",
},
}
conn, err = oc.DialNode(ctx, &node)
assert.NoError(t, err)
assert.NotNil(t, conn)
}