mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
ad7c8697fd
Some constants were being incorrectly generated using 2^N (XOR) instead of 1 << N. This resulted in incorrect candidate priorities being used to evaluate candidate pairs. Resolves #14.
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package ice
|
|
|
|
import "testing"
|
|
|
|
func TestCandidatePriority(t *testing.T) {
|
|
for _, test := range []struct {
|
|
Candidate *Candidate
|
|
WantPriority uint32
|
|
}{
|
|
{
|
|
Candidate: &Candidate{
|
|
Type: CandidateTypeHost,
|
|
LocalPreference: defaultLocalPreference,
|
|
Component: ComponentRTP,
|
|
},
|
|
WantPriority: 2130706431,
|
|
},
|
|
{
|
|
Candidate: &Candidate{
|
|
Type: CandidateTypePeerReflexive,
|
|
LocalPreference: defaultLocalPreference,
|
|
Component: ComponentRTP,
|
|
},
|
|
WantPriority: 1862270975,
|
|
},
|
|
{
|
|
Candidate: &Candidate{
|
|
Type: CandidateTypeServerReflexive,
|
|
LocalPreference: defaultLocalPreference,
|
|
Component: ComponentRTP,
|
|
},
|
|
WantPriority: 1694498815,
|
|
},
|
|
{
|
|
Candidate: &Candidate{
|
|
Type: CandidateTypeRelay,
|
|
LocalPreference: defaultLocalPreference,
|
|
Component: ComponentRTP,
|
|
},
|
|
WantPriority: 16777215,
|
|
},
|
|
} {
|
|
if got, want := test.Candidate.Priority(), test.WantPriority; got != want {
|
|
t.Fatalf("Candidate(%v).Priority() = %d, want %d", test.Candidate, got, want)
|
|
}
|
|
}
|
|
}
|