forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblackbox_test.go
60 lines (47 loc) · 1.38 KB
/
blackbox_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
53
54
55
56
57
58
59
60
package bertyprotocol_test
import (
"context"
"fmt"
"testing"
keystore "github.com/ipfs/go-ipfs-keystore"
"github.com/stretchr/testify/assert"
"berty.tech/berty/v2/go/internal/testutil"
"berty.tech/berty/v2/go/pkg/bertyprotocol"
"berty.tech/berty/v2/go/pkg/protocoltypes"
)
func TestTestingClient_impl(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
logger, cleanup := testutil.Logger(t)
defer cleanup()
client, cleanup := bertyprotocol.TestingService(ctx, t, bertyprotocol.Opts{
Logger: logger,
DeviceKeystore: bertyprotocol.NewDeviceKeystore(keystore.NewMemKeystore()),
})
defer cleanup()
// test service
_, _ = client.InstanceGetConfiguration(ctx, &protocoltypes.InstanceGetConfiguration_Request{})
status := client.Status()
expected := bertyprotocol.Status{}
assert.Equal(t, expected, status)
}
func ExampleNew_basic() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
client, err := bertyprotocol.New(ctx, bertyprotocol.Opts{})
if err != nil {
panic(err)
}
ret, err := client.InstanceGetConfiguration(ctx, &protocoltypes.InstanceGetConfiguration_Request{})
if err != nil {
panic(err)
}
for _, listener := range ret.Listeners {
if listener == "/p2p-circuit" {
fmt.Println(listener)
}
}
// Output:
// /p2p-circuit
}
// FIXME: create examples that actually use groups and contacts