Files
ice/agent_get_best_valid_candidate_pair_test.go
Raja SubramanianandGitHub c8227261a2 Trace log inbound messages (#641)
* Trace log inbound messages

On an ICE restart in controlled mode, seeing incoming messages
getting discarded to due to username mismatch. That is because the
broswer is still using its old candidate and user name. As the
controlled agent waits for `useCandidate` from the controlling agent,
the controlled agent does not get to connected/nominated state inspite
of getting several success responses. Suspect the controlling side does
not have `useCandidate` for the new pair and it is still sending it for
the old pair. Logging more details in trace to understand it better.

* Fix test
2024-01-11 13:46:39 +05:30

58 lines
1.6 KiB
Go

// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
//go:build !js
// +build !js
package ice
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAgentGetBestValidCandidatePair(t *testing.T) {
f := setupTestAgentGetBestValidCandidatePair(t)
remoteCandidatesFromLowestPriorityToHighest := []Candidate{f.relayRemote, f.srflxRemote, f.prflxRemote, f.hostRemote}
for _, remoteCandidate := range remoteCandidatesFromLowestPriorityToHighest {
candidatePair := f.sut.addPair(f.hostLocal, remoteCandidate)
candidatePair.state = CandidatePairStateSucceeded
actualBestPair := f.sut.getBestValidCandidatePair()
expectedBestPair := &CandidatePair{Remote: remoteCandidate, Local: f.hostLocal, state: CandidatePairStateSucceeded}
require.Equal(t, actualBestPair.String(), expectedBestPair.String())
}
assert.NoError(t, f.sut.Close())
}
func setupTestAgentGetBestValidCandidatePair(t *testing.T) *TestAgentGetBestValidCandidatePairFixture {
fixture := new(TestAgentGetBestValidCandidatePairFixture)
fixture.hostLocal = newHostLocal(t)
fixture.relayRemote = newRelayRemote(t)
fixture.srflxRemote = newSrflxRemote(t)
fixture.prflxRemote = newPrflxRemote(t)
fixture.hostRemote = newHostRemote(t)
agent, err := NewAgent(&AgentConfig{})
require.NoError(t, err)
fixture.sut = agent
return fixture
}
type TestAgentGetBestValidCandidatePairFixture struct {
sut *Agent
hostLocal Candidate
relayRemote Candidate
srflxRemote Candidate
prflxRemote Candidate
hostRemote Candidate
}