forked from quic-go/quic-go
identify connections by their local addr when adding to the multiplexer
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
package quic
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
type testConn struct {
|
||||
counter int
|
||||
net.PacketConn
|
||||
}
|
||||
|
||||
var _ = Describe("Client Multiplexer", func() {
|
||||
It("adds a new packet conn ", func() {
|
||||
conn := newMockPacketConn()
|
||||
@@ -12,6 +19,18 @@ var _ = Describe("Client Multiplexer", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("recognizes when the same connection is added twice", func() {
|
||||
pconn := newMockPacketConn()
|
||||
pconn.addr = &net.UDPAddr{IP: net.IPv4(1, 2, 3, 4), Port: 4321}
|
||||
conn := testConn{PacketConn: pconn}
|
||||
_, err := getMultiplexer().AddConn(conn, 8, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
conn.counter++
|
||||
_, err = getMultiplexer().AddConn(conn, 8, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(getMultiplexer().(*connMultiplexer).conns).To(HaveLen(1))
|
||||
})
|
||||
|
||||
It("errors when adding an existing conn with a different connection ID length", func() {
|
||||
conn := newMockPacketConn()
|
||||
_, err := getMultiplexer().AddConn(conn, 5, nil)
|
||||
|
||||
Reference in New Issue
Block a user