2019-04-18 14:16:28 +00:00
|
|
|
package libp2pwebrtcdirect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
"testing"
|
|
|
|
|
2019-05-07 11:49:22 +00:00
|
|
|
detectrace "github.com/jbenet/go-detect-race"
|
2019-06-02 10:20:25 +00:00
|
|
|
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"
|
2019-04-18 14:16:28 +00:00
|
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
|
|
)
|
|
|
|
|
2019-06-02 10:20:25 +00:00
|
|
|
// The contents of this file are copied from libp2p/go-libp2p-core/transport/test
|
2019-04-18 14:16:28 +00:00
|
|
|
// 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) {
|
2019-06-02 10:20:25 +00:00
|
|
|
|
2019-05-07 11:49:22 +00:00
|
|
|
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){
|
2019-06-02 10:20:25 +00:00
|
|
|
ttransport.SubtestProtocols,
|
|
|
|
ttransport.SubtestBasic,
|
2019-05-07 11:49:22 +00:00
|
|
|
|
2019-06-02 10:20:25 +00:00
|
|
|
ttransport.SubtestCancel,
|
|
|
|
ttransport.SubtestPingPong,
|
2019-05-07 11:49:22 +00:00
|
|
|
|
|
|
|
// Stolen from the stream muxer test suite.
|
2019-06-02 10:20:25 +00:00
|
|
|
ttransport.SubtestStress1Conn1Stream1Msg,
|
2019-05-07 11:49:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
subtests = []func(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA peer.ID){
|
2019-06-02 10:20:25 +00:00
|
|
|
ttransport.SubtestStress1Conn1Stream100Msg,
|
|
|
|
ttransport.SubtestStress1Conn100Stream100Msg,
|
|
|
|
ttransport.SubtestStress50Conn10Stream50Msg,
|
|
|
|
ttransport.SubtestStress1Conn1000Stream10Msg,
|
|
|
|
ttransport.SubtestStress1Conn100Stream100Msg10MB,
|
|
|
|
ttransport.SubtestStreamOpenStress,
|
|
|
|
ttransport.SubtestStreamReset,
|
2019-05-07 11:49:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-18 14:16:28 +00:00
|
|
|
maddr, err := ma.NewMultiaddr(addr)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-05-07 11:49:22 +00:00
|
|
|
for _, f := range subtests {
|
2019-04-18 14:16:28 +00:00
|
|
|
t.Run(getFunctionName(f), func(t *testing.T) {
|
|
|
|
f(t, ta, tb, maddr, peerA)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|