Skip to content

Commit

Permalink
Add simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
LVala committed Oct 30, 2023
1 parent 5cc7328 commit 35a0acb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ex_webrtc/peer_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ defmodule ExWebRTC.PeerConnection do
}
end

defp set_description(:local, other, sdp, state) when other in [:answer, :pranswer] do
defp set_description(:local, other, sdp, state) when other in [:offer, :pranswer] do
%{state | pending_local_desc: {other, sdp}}
end

Expand Down
14 changes: 14 additions & 0 deletions test/peer_connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ defmodule ExWebRTC.PeerConnectionTest do
refute_receive {:ex_webrtc, ^pc, {:track, %MediaStreamTrack{}}}
end

test "offer/answer exchange" do
{:ok, pc1} = PeerConnection.start_link()
{:ok, _} = PeerConnection.add_transceiver(pc1, :audio)
{:ok, offer} = PeerConnection.create_offer(pc1)
:ok = PeerConnection.set_local_description(pc1, offer)

{:ok, pc2} = PeerConnection.start_link()
:ok = PeerConnection.set_remote_description(pc2, offer)
{:ok, answer} = PeerConnection.create_answer(pc2)
:ok = PeerConnection.set_local_description(pc2, answer)

:ok = PeerConnection.set_remote_description(pc1, answer)
end

describe "set_remote_description/2" do
test "MID" do
{:ok, pc} = PeerConnection.start_link()
Expand Down

0 comments on commit 35a0acb

Please sign in to comment.