(t *testing.T)
| 17 | const localhostIPStr = "127.0.0.1" |
| 18 | |
| 19 | func 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 | |
| 71 | func TestCandidatePriority(t *testing.T) { |
| 72 | for _, test := range []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…