go-libp2p-webrtc-direct/webrtcdirect_test.go

48 lines
934 B
Go
Raw Normal View History

2018-09-30 19:33:55 +00:00
package libp2pwebrtcdirect
import (
"testing"
logging "github.com/ipfs/go-log"
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
)
func TestTransport(t *testing.T) {
logging.SetLogLevel("*", "warning")
ta := NewTransport(
2019-02-21 14:19:05 +00:00
webrtc.Configuration{},
new(mplex.Transport),
)
tb := NewTransport(
2019-02-21 14:19:05 +00:00
webrtc.Configuration{},
new(mplex.Transport),
)
addr := "/ip4/127.0.0.1/tcp/0/http/p2p-webrtc-direct"
2020-01-06 19:44:03 +00:00
utils.SubtestTransport(t, ta, tb, addr, "peerA")
2018-09-30 19:33:55 +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)
}
tpt := NewTransport(
2019-02-21 14:19:05 +00:00
webrtc.Configuration{},
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")
}
}