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