Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- run: mix deps.get
- run: mix coveralls.json
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- run: mix test test/integration/p2p_test.exs:10
# - run: mix coveralls.json
# - uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 1 addition & 4 deletions lib/ex_ice/priv/checklist.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ defmodule ExICE.Priv.Checklist do
def get_valid_pair(checklist) do
checklist
|> Stream.map(fn {_id, pair} -> pair end)
# pair might have been marked as failed if the associated
# local candidate has been closed
|> Stream.filter(fn pair -> pair.state == :succeeded end)
|> Stream.filter(fn pair -> pair.valid? end)
|> Enum.sort_by(fn pair -> pair.priority end, :desc)
|> Enum.at(0)
Expand Down Expand Up @@ -89,7 +86,7 @@ defmodule ExICE.Priv.Checklist do
def close_candidate(checklist, local_cand) do
Enum.reduce(checklist, {[], checklist}, fn {pair_id, pair}, {failed_pair_ids, checklist} ->
if pair.local_cand_id == local_cand.base.id and pair.state != :failed do
checklist = Map.put(checklist, pair_id, %{pair | state: :failed})
checklist = Map.put(checklist, pair_id, %{pair | state: :failed, valid?: false})
{[pair_id | failed_pair_ids], checklist}
else
{failed_pair_ids, checklist}
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_ice/priv/ice_agent.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ defmodule ExICE.Priv.ICEAgent do
""")

ice_agent = put_in(ice_agent.local_cands[local_cand.base.id], local_cand)
ice_agent = close_candidate(ice_agent, local_cand)

{:error, ice_agent}
end
end
Expand Down
20 changes: 14 additions & 6 deletions test/priv/ice_agent_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2492,8 +2492,8 @@ defmodule ExICE.Priv.ICEAgentTest do
test "candidate fails to send data when ice is connected" do
# 1. make ice agent connected
# 2. replace candidate with the mock one that always fails to send data
# 3. assert that after unsuccessful data sending, ice_agent moves to the failed state
# as there are no other pairs
# 3. assert that after unsuccessful data sending, ice_agent doesn't move to the failed state
# even when there is only one pair

ice_agent =
ICEAgent.new(
Expand All @@ -2519,10 +2519,18 @@ defmodule ExICE.Priv.ICEAgentTest do
# try to send some data
ice_agent = ICEAgent.send_data(ice_agent, "somedata")

# assert that local cand has been closed and the agent moved to the failed state
assert [%{base: %{closed?: true}}] = Map.values(ice_agent.local_cands)
assert ice_agent.state == :failed
assert [%{state: :failed}] = Map.values(ice_agent.checklist)
# assert that the local candidate hasn't been closed and that the agent hasn't moved to a failed state
assert [%{base: %{closed?: false}}] = Map.values(ice_agent.local_cands)
assert ice_agent.state == :connected

# assert that the local candidate's state was updated after the packet was discarded
assert [
%{
state: :succeeded,
packets_discarded_on_send: 1,
bytes_discarded_on_send: 8
}
] = Map.values(ice_agent.checklist)
end

test "relay connection" do
Expand Down
Loading