1package quic 2 3import ( 4 "net" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8) 9 10var _ = Describe("Connection (for sending packets)", func() { 11 var ( 12 c sendConn 13 packetConn *MockPacketConn 14 addr net.Addr 15 ) 16 17 BeforeEach(func() { 18 addr = &net.UDPAddr{IP: net.IPv4(192, 168, 100, 200), Port: 1337} 19 packetConn = NewMockPacketConn(mockCtrl) 20 c = newSendPconn(packetConn, addr) 21 }) 22 23 It("writes", func() { 24 packetConn.EXPECT().WriteTo([]byte("foobar"), addr) 25 Expect(c.Write([]byte("foobar"))).To(Succeed()) 26 }) 27 28 It("gets the remote address", func() { 29 Expect(c.RemoteAddr().String()).To(Equal("192.168.100.200:1337")) 30 }) 31 32 It("gets the local address", func() { 33 addr := &net.UDPAddr{ 34 IP: net.IPv4(192, 168, 0, 1), 35 Port: 1234, 36 } 37 packetConn.EXPECT().LocalAddr().Return(addr) 38 Expect(c.LocalAddr()).To(Equal(addr)) 39 }) 40 41 It("closes", func() { 42 packetConn.EXPECT().Close() 43 Expect(c.Close()).To(Succeed()) 44 }) 45}) 46