8b9711cb5e
* better waitlist-gating (cherry picked from commit 490fe02b7c3558da18678dfb651c92ec9c4a75b5) * fix broken test * linter fixes * linter fixes * make extension verification optional * add certifcate gating script for captplanet * fixing tests * linter fixes * linter fixes? * moar linter fixes * Revert "moar linter fixes" This reverts commit 8139ccbd73cbbead987b7667567844f50f7df2c8. * just kill me * refactor * refactor tests * liniter... * cleanup
60 lines
1.1 KiB
Go
60 lines
1.1 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/pkg/pb"
|
|
"storj.io/storj/pkg/provider"
|
|
)
|
|
|
|
var ctx = context.Background()
|
|
|
|
func TestDialNode(t *testing.T) {
|
|
ca, err := provider.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: "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: "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: "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)
|
|
}
|