@@ -2635,64 +2635,29 @@ defmodule ExICE.Priv.ICEAgentTest do
26352635 alias ExICE.Priv.Candidate
26362636
26372637 @ ipv4 { 10 , 10 , 10 , 10 }
2638- @ ipv6 { 64_512 , 0 , 0 , 0 , 0 , 0 , 0 , 1 }
2639- @ invalid_ip :invalid_ip
26402638
26412639 test "adds srflx candidate" do
2642- ice_agent = spawn_ice_agent ( IfDiscovery.MockSingle , fn _ip -> @ ipv4 end )
2643-
2644- assert [ % Candidate.Srflx { base: % { address: @ ipv4 } } ] = srflx_candidates ( ice_agent )
2645-
2646- assert_receive { :ex_ice , _pid , { :new_candidate , host_cand } }
2647- assert_receive { :ex_ice , _pid , { :new_candidate , srflx_cand } }
2648-
2649- assert host_cand =~ "typ host"
2650- assert srflx_cand =~ "typ srflx"
2651- end
2652-
2653- test "creates only one candidate if external ip is repeated" do
2654- ice_agent = spawn_ice_agent ( IfDiscovery.MockMulti , fn _ip -> @ ipv4 end )
2640+ ice_agent =
2641+ % ICEAgent { gathering_state: :complete } =
2642+ ICEAgent . new (
2643+ controlling_process: self ( ) ,
2644+ role: :controlled ,
2645+ transport_module: Transport.Mock ,
2646+ if_discovery_module: IfDiscovery.MockSingle ,
2647+ host_to_srflx_ip_mapper: fn _ip -> @ ipv4 end
2648+ )
2649+ |> ICEAgent . set_remote_credentials ( "remoteufrag" , "remotepwd" )
2650+ |> ICEAgent . gather_candidates ( )
26552651
26562652 assert [ % Candidate.Srflx { base: % { address: @ ipv4 } } ] = srflx_candidates ( ice_agent )
26572653
26582654 assert_receive { :ex_ice , _pid , { :new_candidate , host_cand } }
2659- assert_receive { :ex_ice , _pid , { :new_candidate , host_cand_2 } }
26602655 assert_receive { :ex_ice , _pid , { :new_candidate , srflx_cand } }
26612656
26622657 assert host_cand =~ "typ host"
2663- assert host_cand_2 =~ "typ host"
26642658 assert srflx_cand =~ "typ srflx"
26652659 end
26662660
2667- test "ignores one to one mapping" do
2668- ice_agent = spawn_ice_agent ( IfDiscovery.MockSingle , fn ip -> ip end )
2669-
2670- assert [ ] == srflx_candidates ( ice_agent )
2671-
2672- assert_receive { :ex_ice , _pid , { :new_candidate , host_cand } }
2673- refute_receive { :ex_ice , _pid , { :new_candidate , _srflx_cand } }
2674-
2675- assert host_cand =~ "typ host"
2676- end
2677-
2678- test "ignores if ip types is not the same" do
2679- ice_agent = spawn_ice_agent ( IfDiscovery.MockSingle , fn _ip -> @ ipv6 end )
2680-
2681- assert [ ] == srflx_candidates ( ice_agent )
2682- end
2683-
2684- test "ignores when function returns nil value" do
2685- ice_agent = spawn_ice_agent ( IfDiscovery.MockSingle , fn _ip -> nil end )
2686-
2687- assert [ ] == srflx_candidates ( ice_agent )
2688- end
2689-
2690- test "ignores when function returns invalid value" do
2691- ice_agent = spawn_ice_agent ( IfDiscovery.MockSingle , fn _ip -> @ invalid_ip end )
2692-
2693- assert [ ] == srflx_candidates ( ice_agent )
2694- end
2695-
26962661 test "works with STUN enabled" do
26972662 ice_agent =
26982663 ICEAgent . new (
@@ -2732,19 +2697,6 @@ defmodule ExICE.Priv.ICEAgentTest do
27322697 assert [ % Candidate.Srflx { } ] = srflx_candidates ( ice_agent )
27332698 end
27342699
2735- defp spawn_ice_agent ( discovery_module , host_to_srflx_ip_mapper ) do
2736- % ICEAgent { gathering_state: :complete } =
2737- ICEAgent . new (
2738- controlling_process: self ( ) ,
2739- role: :controlled ,
2740- transport_module: Transport.Mock ,
2741- if_discovery_module: discovery_module ,
2742- host_to_srflx_ip_mapper: host_to_srflx_ip_mapper
2743- )
2744- |> ICEAgent . set_remote_credentials ( "remoteufrag" , "remotepwd" )
2745- |> ICEAgent . gather_candidates ( )
2746- end
2747-
27482700 defp srflx_candidates ( ice_agent ) do
27492701 ice_agent . local_cands
27502702 |> Map . values ( )
0 commit comments