Unverified Commit 0b44affe authored by Marten Seemann's avatar Marten Seemann
Browse files

add tests for transport.Listen

parent 46ad9d04
...@@ -14,6 +14,28 @@ var _ = Describe("Transport", func() { ...@@ -14,6 +14,28 @@ var _ = Describe("Transport", func() {
t = NewQuicTransport(nil) t = NewQuicTransport(nil)
}) })
Context("listening", func() {
It("creates a new listener", func() {
maddr, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234/quic")
Expect(err).ToNot(HaveOccurred())
ln, err := t.Listen(maddr)
Expect(err).ToNot(HaveOccurred())
Expect(ln.Multiaddr()).To(Equal(maddr))
})
It("returns an existing listener", func() {
maddr, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1235/quic")
Expect(err).ToNot(HaveOccurred())
ln, err := t.Listen(maddr)
Expect(err).ToNot(HaveOccurred())
Expect(ln.Multiaddr()).To(Equal(maddr))
ln2, err := t.Listen(maddr)
Expect(err).ToNot(HaveOccurred())
Expect(ln2).To(Equal(ln))
Expect(t.listeners).To(HaveLen(1))
})
})
It("matches", func() { It("matches", func() {
invalidAddr, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234") invalidAddr, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
......
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