go-libp2p-webrtc-direct/webrtcdirect_test.go

49 lines
970 B
Go
Raw Normal View History

2018-09-30 19:33:55 +00:00
package libp2pwebrtcdirect
import (
"testing"
logging "github.com/ipfs/go-log"
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
mplex "github.com/whyrusleeping/go-smux-multiplex"
)
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"
// TODO: Re-enable the entire test suite
// utils.SubtestTransport(t, ta, tb, addr, "peerA")
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")
}
}