@@ -773,6 +773,55 @@ defmodule ExICE.Priv.ICEAgentTest do
773
773
assert_unauthenticated_error_response ( socket , request )
774
774
end
775
775
776
+ test "before setting remote candidates" , % {
777
+ ice_agent: ice_agent ,
778
+ remote_cand: remote_cand
779
+ } do
780
+ # 1. Receive binding request from the remote side
781
+ # 2. This will create prflx candidate, pair it with our local candidates
782
+ # 3. Timer should not be started as we don't have remote credentials
783
+ # 4. Set remote credentials
784
+ # 5. Timer should be started as we have conn checks to execute and we also have remote credentials
785
+ [ socket ] = ice_agent . sockets
786
+
787
+ request =
788
+ Message . new ( % Type { class: :request , method: :binding } , [
789
+ % Username { value: "#{ ice_agent . local_ufrag } :someufrag" } ,
790
+ % Priority { priority: 1234 } ,
791
+ % ICEControlled { tiebreaker: 1234 }
792
+ ] )
793
+ |> Message . with_integrity ( ice_agent . local_pwd )
794
+ |> Message . with_fingerprint ( )
795
+
796
+ raw_request = Message . encode ( request )
797
+
798
+ ice_agent =
799
+ ICEAgent . handle_udp (
800
+ ice_agent ,
801
+ socket ,
802
+ remote_cand . address ,
803
+ remote_cand . port ,
804
+ raw_request
805
+ )
806
+
807
+ # flush the response
808
+ Transport.Mock . recv ( socket )
809
+
810
+ # assert timer was not started
811
+ refute_receive :ta_timeout
812
+
813
+ # make sure that even if timer was started, handle_ta_timeout wouldn't try to send conn check
814
+ ice_agent = ICEAgent . handle_ta_timeout ( ice_agent )
815
+ assert nil == Transport.Mock . recv ( socket )
816
+
817
+ # set remote credentials and assert timer was started
818
+ ice_agent = ICEAgent . set_remote_credentials ( ice_agent , "remote_ufrag" , "remote_pwd" )
819
+ assert_receive :ta_timeout
820
+
821
+ # handle timer without errors
822
+ ICEAgent . handle_ta_timeout ( ice_agent )
823
+ end
824
+
776
825
defp assert_bad_request_error_response ( socket , request ) do
777
826
assert packet = Transport.Mock . recv ( socket )
778
827
assert is_binary ( packet )
0 commit comments