go-libp2p-webrtc-direct/webrtcdirect_test.go

49 lines
961 B
Go
Raw Normal View History

2018-09-30 21:33:55 +02:00
package libp2pwebrtcdirect
import (
"testing"
logging "github.com/ipfs/go-log"
mplex "github.com/libp2p/go-libp2p-mplex"
2018-09-30 21:33:55 +02:00
ma "github.com/multiformats/go-multiaddr"
2019-04-06 17:47:28 +02:00
"github.com/pion/webrtc/v2"
2018-09-30 21:33:55 +02:00
)
func TestTransport(t *testing.T) {
logging.SetLogLevel("*", "warning")
ta := NewTransport(
2019-02-21 15:19:05 +01:00
webrtc.Configuration{},
new(mplex.Transport),
)
tb := NewTransport(
2019-02-21 15:19:05 +01:00
webrtc.Configuration{},
new(mplex.Transport),
)
addr := "/ip4/127.0.0.1/tcp/0/http/p2p-webrtc-direct"
// TODO: Re-enable the entire test suite
// utils.SubtestTransport(t, ta, tb, addr, "peerA")
SubtestTransport(t, ta, tb, addr, "peerA")
2018-09-30 21:33:55 +02: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)
}
tpt := NewTransport(
2019-02-21 15:19:05 +01:00
webrtc.Configuration{},
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")
}
}