github.com/quic-go/quic-go@v0.44.0/multiplexer_test.go (about) 1 package quic 2 3 import ( 4 "net" 5 6 . "github.com/onsi/ginkgo/v2" 7 . "github.com/onsi/gomega" 8 ) 9 10 var _ = Describe("Multiplexer", func() { 11 It("adds new packet conns", func() { 12 conn1 := NewMockPacketConn(mockCtrl) 13 conn1.EXPECT().LocalAddr().Return(&net.UDPAddr{IP: net.IPv4(1, 2, 3, 4), Port: 1234}) 14 getMultiplexer().AddConn(conn1) 15 conn2 := NewMockPacketConn(mockCtrl) 16 conn2.EXPECT().LocalAddr().Return(&net.UDPAddr{IP: net.IPv4(1, 2, 3, 4), Port: 1235}) 17 getMultiplexer().AddConn(conn2) 18 }) 19 20 It("panics when the same connection is added twice", func() { 21 conn := NewMockPacketConn(mockCtrl) 22 conn.EXPECT().LocalAddr().Return(&net.UDPAddr{IP: net.IPv4(1, 2, 3, 4), Port: 4321}).Times(2) 23 getMultiplexer().AddConn(conn) 24 Expect(func() { getMultiplexer().AddConn(conn) }).To(Panic()) 25 }) 26 })