Unverified Commit 37a190d7 authored by Marten Seemann's avatar Marten Seemann
Browse files

implement transport.Matches

parent eb02a73d
......@@ -6,6 +6,7 @@ import (
pstore "github.com/libp2p/go-libp2p-peerstore"
tpt "github.com/libp2p/go-libp2p-transport"
ma "github.com/multiformats/go-multiaddr"
"github.com/whyrusleeping/mafmt"
)
// QuicTransport implements a QUIC Transport
......@@ -50,8 +51,8 @@ func (t *QuicTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) {
return ln, nil
}
func (t *QuicTransport) Matches(ma.Multiaddr) bool {
panic("not implemented")
func (t *QuicTransport) Matches(a ma.Multiaddr) bool {
return mafmt.QUIC.Matches(a)
}
var _ tpt.Transport = &QuicTransport{}
package libp2pquic
import (
ma "github.com/multiformats/go-multiaddr"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Transport", func() {
var t *QuicTransport
BeforeEach(func() {
t = NewQuicTransport(nil)
})
It("matches", func() {
invalidAddr, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234")
Expect(err).ToNot(HaveOccurred())
validAddr, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234/quic")
Expect(err).ToNot(HaveOccurred())
Expect(t.Matches(invalidAddr)).To(BeFalse())
Expect(t.Matches(validAddr)).To(BeTrue())
})
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment