forked from libp2p/go-libp2p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_suite.go
46 lines (38 loc) · 1.05 KB
/
utils_suite.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
package ttransport
import (
"reflect"
"runtime"
"testing"
"github.com/zbliujia/go-libp2p/core/peer"
"github.com/zbliujia/go-libp2p/core/transport"
ma "github.com/multiformats/go-multiaddr"
)
var Subtests = []func(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, peerA peer.ID){
SubtestProtocols,
SubtestBasic,
SubtestCancel,
SubtestPingPong,
// Stolen from the stream muxer test suite.
SubtestStress1Conn1Stream1Msg,
SubtestStress1Conn1Stream100Msg,
SubtestStress1Conn100Stream100Msg,
SubtestStressManyConn10Stream50Msg,
SubtestStress1Conn1000Stream10Msg,
SubtestStress1Conn100Stream100Msg10MB,
SubtestStreamOpenStress,
SubtestStreamReset,
}
func getFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}
func SubtestTransport(t *testing.T, ta, tb transport.Transport, addr string, peerA peer.ID) {
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)
})
}
}