2018-09-30 21:33:55 +02:00
|
|
|
package libp2pwebrtcdirect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-07-25 14:32:54 -04:00
|
|
|
"github.com/pion/webrtc/v3"
|
|
|
|
|
|
|
|
logging "github.com/ipfs/go-log/v2"
|
2019-01-22 12:02:08 +01:00
|
|
|
|
2022-07-25 14:32:54 -04:00
|
|
|
mplex "github.com/libp2p/go-libp2p/p2p/muxer/mplex"
|
|
|
|
utils "github.com/libp2p/go-libp2p/p2p/transport/testsuite"
|
2018-09-30 21:33:55 +02:00
|
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
|
|
)
|
|
|
|
|
2019-01-22 12:02:08 +01:00
|
|
|
func TestTransport(t *testing.T) {
|
2022-07-25 14:32:54 -04:00
|
|
|
//t.Skip("This test is failing, see https://github.com/libp2p/go-libp2p-webrtc-direct/issues/37")
|
2019-01-22 12:02:08 +01:00
|
|
|
logging.SetLogLevel("*", "warning")
|
|
|
|
|
|
|
|
ta := NewTransport(
|
2019-02-21 15:19:05 +01:00
|
|
|
webrtc.Configuration{},
|
2019-01-22 12:02:08 +01:00
|
|
|
new(mplex.Transport),
|
|
|
|
)
|
|
|
|
tb := NewTransport(
|
2019-02-21 15:19:05 +01:00
|
|
|
webrtc.Configuration{},
|
2019-01-22 12:02:08 +01:00
|
|
|
new(mplex.Transport),
|
|
|
|
)
|
|
|
|
|
|
|
|
addr := "/ip4/127.0.0.1/tcp/0/http/p2p-webrtc-direct"
|
2019-04-18 16:16:28 +02:00
|
|
|
|
2020-01-06 20:44:03 +01:00
|
|
|
utils.SubtestTransport(t, ta, tb, addr, "peerA")
|
2018-09-30 21:33:55 +02:00
|
|
|
}
|
|
|
|
|
2019-01-22 12:02:08 +01:00
|
|
|
func TestTransportCantListenUtp(t *testing.T) {
|
|
|
|
utpa, err := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/50000")
|
2018-09-30 21:33:55 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2019-01-22 12:02:08 +01:00
|
|
|
tpt := NewTransport(
|
2019-02-21 15:19:05 +01:00
|
|
|
webrtc.Configuration{},
|
2019-01-22 12:02:08 +01:00
|
|
|
new(mplex.Transport),
|
2018-09-30 21:33:55 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
_, err = tpt.Listen(utpa)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("shouldnt be able to listen on utp addr with tcp transport")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|