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

Function TestCandidateTypePreference

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

Source from the content-addressed store, hash-verified

17const localhostIPStr = "127.0.0.1"
18
19func TestCandidateTypePreference(t *testing.T) {
20 req := require.New(t)
21
22 hostDefaultPreference := uint16(126)
23 prflxDefaultPreference := uint16(110)
24 srflxDefaultPreference := uint16(100)
25 relayDefaultPreference := uint16(0)
26
27 tcpOffsets := []uint16{0, 10}
28
29 for _, tcpOffset := range tcpOffsets {
30 agent := &Agent{
31 tcpPriorityOffset: tcpOffset,
32 }
33
34 for _, networkType := range supportedNetworkTypes() {
35 hostCandidate := candidateBase{
36 candidateType: CandidateTypeHost,
37 networkType: networkType,
38 currAgent: agent,
39 }
40 prflxCandidate := candidateBase{
41 candidateType: CandidateTypePeerReflexive,
42 networkType: networkType,
43 currAgent: agent,
44 }
45 srflxCandidate := candidateBase{
46 candidateType: CandidateTypeServerReflexive,
47 networkType: networkType,
48 currAgent: agent,
49 }
50 relayCandidate := candidateBase{
51 candidateType: CandidateTypeRelay,
52 networkType: networkType,
53 currAgent: agent,
54 }
55
56 if networkType.IsTCP() {
57 req.Equal(hostDefaultPreference-tcpOffset, hostCandidate.TypePreference())
58 req.Equal(prflxDefaultPreference-tcpOffset, prflxCandidate.TypePreference())
59 req.Equal(srflxDefaultPreference-tcpOffset, srflxCandidate.TypePreference())
60 } else {
61 req.Equal(hostDefaultPreference, hostCandidate.TypePreference())
62 req.Equal(prflxDefaultPreference, prflxCandidate.TypePreference())
63 req.Equal(srflxDefaultPreference, srflxCandidate.TypePreference())
64 }
65
66 req.Equal(relayDefaultPreference, relayCandidate.TypePreference())
67 }
68 }
69}
70
71func TestCandidatePriority(t *testing.T) {
72 for _, test := range []struct {

Callers

nothing calls this directly

Calls 4

TypePreferenceMethod · 0.95
supportedNetworkTypesFunction · 0.85
IsTCPMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…