ecbd5f08c3
* overlay proto * grpc server and client * fix import to storj * tests * change imports * imports cleanup/comments * PR comments addressed from @jtolds
45 lines
897 B
Go
45 lines
897 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package overlay
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"google.golang.org/grpc"
|
|
|
|
proto "github.com/coyle/storj/protos/overlay" // naming proto to avoid confusion with this package
|
|
)
|
|
|
|
func TestNewServer(t *testing.T) {
|
|
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 0))
|
|
assert.NoError(t, err)
|
|
|
|
srv := NewServer()
|
|
assert.NotNil(t, srv)
|
|
|
|
go srv.Serve(lis)
|
|
srv.Stop()
|
|
}
|
|
|
|
func TestNewClient(t *testing.T) {
|
|
|
|
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 0))
|
|
assert.NoError(t, err)
|
|
srv := NewServer()
|
|
go srv.Serve(lis)
|
|
defer srv.Stop()
|
|
|
|
address := lis.Addr().String()
|
|
c, err := NewClient(&address, grpc.WithInsecure())
|
|
assert.NoError(t, err)
|
|
|
|
r, err := c.Lookup(context.Background(), &proto.LookupRequest{})
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, r)
|
|
}
|