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

Function assertAddressRewriteOption

agent_options_test.go:808–842  ·  view source on GitHub ↗
(
	t *testing.T,
	rules []AddressRewriteRule,
	candidateType CandidateType,
	expectedFirstIP string,
	expectedSecondIP string,
	lookupLocalIP string,
)

Source from the content-addressed store, hash-verified

806}
807
808func assertAddressRewriteOption(
809 t *testing.T,
810 rules []AddressRewriteRule,
811 candidateType CandidateType,
812 expectedFirstIP string,
813 expectedSecondIP string,
814 lookupLocalIP string,
815) {
816 t.Helper()
817
818 stub := newStubNet(t)
819
820 agent, err := NewAgentWithOptions(
821 WithNet(stub),
822 WithAddressRewriteRules(rules...),
823 )
824 require.NoError(t, err)
825 t.Cleanup(func() {
826 require.NoError(t, agent.Close())
827 })
828
829 require.Len(t, agent.addressRewriteRules, len(rules))
830
831 firstRule := agent.addressRewriteRules[0]
832 require.Equal(t, candidateType, firstRule.AsCandidateType)
833 require.Equal(t, []string{expectedFirstIP}, firstRule.External)
834
835 secondRule := agent.addressRewriteRules[1]
836 require.Equal(t, candidateType, secondRule.AsCandidateType)
837 require.Equal(t, []string{expectedSecondIP}, secondRule.External)
838
839 require.NotNil(t, agent.addressRewriteMapper)
840 extIP := requireFirstExternalIP(t, agent.addressRewriteMapper, candidateType, lookupLocalIP)
841 require.Equal(t, expectedFirstIP, extIP.String())
842}
843
844func requireFirstExternalIP(
845 t *testing.T,

Callers 1

Calls 8

newStubNetFunction · 0.85
NewAgentWithOptionsFunction · 0.85
WithNetFunction · 0.85
WithAddressRewriteRulesFunction · 0.85
requireFirstExternalIPFunction · 0.85
CloseMethod · 0.65
EqualMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…