forked from libp2p/go-libp2p-webrtc-direct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransport_test.go
59 lines (49 loc) · 1.78 KB
/
transport_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
package libp2pwebrtcdirect
import (
"reflect"
"runtime"
"testing"
detectrace "github.com/jbenet/go-detect-race"
peer "github.com/libp2p/go-libp2p-core/peer"
tpt "github.com/libp2p/go-libp2p-core/transport"
ttransport "github.com/libp2p/go-libp2p-testing/suites/transport"
ma "github.com/multiformats/go-multiaddr"
)
// The contents of this file are copied from libp2p/go-libp2p-core/transport/test
// in order to disable some tests while we investigate performance issues when
// running the tests on resource restricted environments like the Travis CI.
func getFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}
func SubtestTransport(t *testing.T, ta, tb tpt.Transport, addr string, peerA peer.ID) {
subtests := []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){}
if detectrace.WithRace() {
subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){
ttransport.SubtestProtocols,
ttransport.SubtestBasic,
ttransport.SubtestCancel,
ttransport.SubtestPingPong,
// Stolen from the stream muxer test suite.
ttransport.SubtestStress1Conn1Stream1Msg,
}
} else {
subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){
ttransport.SubtestStress1Conn1Stream100Msg,
ttransport.SubtestStress1Conn100Stream100Msg,
ttransport.SubtestStress50Conn10Stream50Msg,
ttransport.SubtestStress1Conn1000Stream10Msg,
ttransport.SubtestStress1Conn100Stream100Msg10MB,
ttransport.SubtestStreamOpenStress,
ttransport.SubtestStreamReset,
}
}
maddr, err := ma.NewMultiaddr(addr)
if err != nil {
t.Fatal(err)
}
for _, f := range subtests {
t.Run(getFunctionName(f), func(t *testing.T) {
f(t, ta, tb, maddr, peerA)
})
}
}