Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Jan 4, 2025
1 parent e6774bc commit 76efaa2
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions test/ex_webrtc/dtls_transport_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,36 @@ defmodule ExWebRTC.DTLSTransportTest do
assert_receive {:dtls_transport, ^dtls, {:state_change, :connected}}
end

@tag :debug
test "drops packets when packet loss is set", %{

Check failure on line 206 in test/ex_webrtc/dtls_transport_test.exs

View workflow job for this annotation

GitHub Actions / CI on OTP 27 / Elixir 1.17

test drops packets when packet loss is set (ExWebRTC.DTLSTransportTest)
dtls: dtls,
ice_transport: ice_transport,
ice_pid: ice_pid
} do
:ok = DTLSTransport.start_dtls(dtls, :active, @fingerprint)
remote_dtls = ExDTLS.init(mode: :server, dtls_srtp: true)

:ok = DTLSTransport.set_ice_connected(dtls)

assert :ok = check_handshake(dtls, ice_transport, ice_pid, remote_dtls)
assert_receive {:dtls_transport, ^dtls, {:state_change, :connecting}}
assert_receive {:dtls_transport, ^dtls, {:state_change, :connected}}

# assert we can send data
DTLSTransport.send_rtp(dtls, <<1, 2, 3>>)
assert_receive {:mock_ice, <<1, 2, 3>>}

# now set packet-loss
DTLSTransport.set_packet_loss(dtls, 100)
DTLSTransport.send_rtp(dtls, <<1, 2, 3>>)
refute_receive {:mock_ice, <<1, 2, 3>>}
end

test "stop/1", %{dtls: dtls} do
assert :ok == DTLSTransport.stop(dtls)
assert false == Process.alive?(dtls)
end

defp check_handshake(dtls, ice_transport, ice_pid, remote_dtls) do
assert_receive {:mock_ice, packets}

Expand All @@ -218,9 +248,4 @@ defmodule ExWebRTC.DTLSTransportTest do
:ok
end
end

test "stop/1", %{dtls: dtls} do
assert :ok == DTLSTransport.stop(dtls)
assert false == Process.alive?(dtls)
end
end

0 comments on commit 76efaa2

Please sign in to comment.