-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbasic_test.go
51 lines (40 loc) · 968 Bytes
/
basic_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
package bifrost
import (
"context"
"testing"
"github.com/aperturerobotics/bifrost/sim/graph"
"github.com/aperturerobotics/bifrost/sim/simulate"
"github.com/sirupsen/logrus"
)
// TestBasic tests a simple connection between two peers on a LAN.
func TestBasic(t *testing.T) {
ctx, ctxCancel := context.WithCancel(context.Background())
defer ctxCancel()
log := logrus.New()
log.SetLevel(logrus.DebugLevel)
le := logrus.NewEntry(log)
g := graph.NewGraph()
descrip := `p0 <-> [lan1] <-> p1`
p0 := addPeer(t, g)
p1 := addPeer(t, g)
lan1 := graph.AddLAN(g)
lan1.AddPeer(g, p0)
lan1.AddPeer(g, p1)
sim := initSimulator(
t,
ctx,
le,
g,
simulate.WithVerbose(),
)
le.Infof("attempting to dial %v", descrip)
if err := simulate.TestConnectivity(
ctx,
sim.GetPeerByID(p0.GetPeerID()),
sim.GetPeerByID(p1.GetPeerID()),
); err != nil {
t.Fatal(err.Error())
}
le.Infof("successful connectivity test: %v", descrip)
// <-ctx.Done()
}