forked from berty/weshnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing_test.go
52 lines (44 loc) · 1.16 KB
/
testing_test.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
package weshnet
import (
"context"
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"berty.tech/weshnet/v2/pkg/protocoltypes"
)
func TestClient_impl(t *testing.T) {
var _ Service = (*service)(nil)
var _ protocoltypes.ProtocolServiceServer = (*service)(nil)
}
func TestEmptyArgs(t *testing.T) {
// disable ressources manager for test
os.Setenv("LIBP2P_RCMGR", "false")
// initialize new client
client, err := NewService(Opts{})
require.NoError(t, err)
err = client.Close()
require.NoError(t, err)
client.Close()
}
func TestTestingProtocol(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
opts := TestingOpts{}
tp, cleanup := NewTestingProtocol(ctx, t, &opts, nil)
assert.NotNil(t, tp)
cleanup()
cancel()
}
func TestTestingProtocolWithMockedPeers(t *testing.T) {
for amount := 0; amount < 5; amount++ {
t.Run(fmt.Sprintf("%d-peers", amount), func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
opts := TestingOpts{}
tp, cleanup := NewTestingProtocolWithMockedPeers(ctx, t, &opts, nil, amount)
assert.NotNil(t, tp)
cleanup()
cancel()
})
}
}