/
test_utils.go
53 lines (45 loc) · 994 Bytes
/
test_utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package client
import (
"context"
"testing"
"github.com/textileio/filecoin/api/server"
"github.com/textileio/filecoin/tests"
"google.golang.org/grpc"
)
var (
grpcHostNetwork = "tcp"
grpcHostAddress = "127.0.0.1:50051"
ctx = context.Background()
)
func setupServer(t *testing.T) func() {
lotusAddr, token := tests.ClientConfigMA()
conf := server.Config{
LotusAddress: lotusAddr,
LotusAuthToken: token,
GrpcHostNetwork: grpcHostNetwork,
GrpcHostAddress: grpcHostAddress,
}
server, err := server.NewServer(conf)
checkErr(t, err)
return func() {
server.Close()
}
}
func setupConnection(t *testing.T) (*grpc.ClientConn, func()) {
conn, err := grpc.Dial(grpcHostAddress, grpc.WithInsecure())
checkErr(t, err)
return conn, func() {
conn.Close()
}
}
func checkErr(t *testing.T, err error) {
t.Helper()
if err != nil {
t.Fatal(err)
}
}
func skipIfShort(t *testing.T) {
if testing.Short() {
t.Skip("skipping since is a short test run")
}
}