Skip to content

Commit 3010266

Browse files
committed
Add conn check eperm test
1 parent 3a81786 commit 3010266

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/priv/ice_agent_test.exs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ defmodule ExICE.Priv.ICEAgentTest do
12451245
end
12461246
end
12471247

1248+
@conn_check_byte_size 92
1249+
12481250
describe "connectivity check" do
12491251
setup do
12501252
ice_agent =
@@ -1563,6 +1565,50 @@ defmodule ExICE.Priv.ICEAgentTest do
15631565

15641566
assert ice_agent.state == :completed
15651567
end
1568+
1569+
test "candidate fails to send conn check" do
1570+
# 1. replace candidate with the mock one that always fails to send data
1571+
# 2. assert that after unsuccessful conn check sending, ice_agent move conn pair to the failed state
1572+
1573+
ice_agent =
1574+
ICEAgent.new(
1575+
controlling_process: self(),
1576+
role: :controlling,
1577+
if_discovery_module: IfDiscovery.Mock,
1578+
transport_module: Transport.Mock
1579+
)
1580+
|> ICEAgent.set_remote_credentials("someufrag", "somepwd")
1581+
|> ICEAgent.gather_candidates()
1582+
|> ICEAgent.add_remote_candidate(@remote_cand)
1583+
|> ICEAgent.end_of_candidates()
1584+
1585+
assert ice_agent.gathering_state == :complete
1586+
1587+
# replace candidate with the mock one
1588+
[local_cand] = Map.values(ice_agent.local_cands)
1589+
mock_cand = %Candidate.Mock{base: local_cand.base}
1590+
ice_agent = %{ice_agent | local_cands: %{mock_cand.base.id => mock_cand}}
1591+
1592+
# try to send conn check
1593+
ice_agent = ICEAgent.handle_ta_timeout(ice_agent)
1594+
1595+
assert ice_agent.state == :checking
1596+
1597+
# assert that the candidate pair has moved to a failed state
1598+
# and that the state was updated after the packet was discarded
1599+
assert [
1600+
%{
1601+
state: :failed,
1602+
valid?: false,
1603+
packets_discarded_on_send: 1,
1604+
bytes_discarded_on_send: @conn_check_byte_size
1605+
}
1606+
] = Map.values(ice_agent.checklist)
1607+
1608+
ice_agent = ICEAgent.handle_ta_timeout(ice_agent)
1609+
1610+
assert ice_agent.state == :failed
1611+
end
15661612
end
15671613

15681614
describe "connectivity check with aggressive nomination" do

0 commit comments

Comments
 (0)