MCPcopy Create free account
hub / github.com/pion/ice / TestCandidateWriteTo

Function TestCandidateWriteTo

candidate_test.go:602–640  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

600}
601
602func TestCandidateWriteTo(t *testing.T) {
603 listener, err := net.ListenTCP("tcp", &net.TCPAddr{
604 IP: net.IP{127, 0, 0, 1},
605 Port: 0,
606 })
607 require.NoError(t, err, "error creating test TCP listener")
608
609 conn, err := net.DialTCP("tcp", nil, listener.Addr().(*net.TCPAddr)) // nolint
610 require.NoError(t, err, "error dialing test TCP connection")
611
612 loggerFactory := logging.NewDefaultLoggerFactory()
613 packetConn := newTCPPacketConn(tcpPacketParams{
614 ReadBuffer: 2048,
615 Logger: loggerFactory.NewLogger("tcp-packet-conn"),
616 })
617
618 err = packetConn.AddConn(conn, nil)
619 require.NoError(t, err, "error adding test TCP connection to packet connection")
620
621 c1 := &candidateBase{
622 conn: packetConn,
623 currAgent: &Agent{
624 log: loggerFactory.NewLogger("agent"),
625 },
626 }
627
628 c2 := &candidateBase{
629 resolvedAddr: listener.Addr(),
630 }
631
632 _, err = c1.writeTo([]byte("test"), c2)
633 require.NoError(t, err, "writing to open conn")
634
635 err = packetConn.Close()
636 require.NoError(t, err, "error closing test TCP connection")
637
638 _, err = c1.writeTo([]byte("test"), c2)
639 require.Error(t, err, "writing to closed conn")
640}
641
642func TestMarshalUnmarshalCandidateWithZoneID(t *testing.T) {
643 candidateWithZoneID := mustCandidateHost(t, &CandidateHostConfig{

Callers

nothing calls this directly

Calls 8

writeToMethod · 0.95
newTCPPacketConnFunction · 0.85
AddConnMethod · 0.80
CloseMethod · 0.65
ListenTCPMethod · 0.45
DialTCPMethod · 0.45
NewLoggerMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…