aboutsummaryrefslogtreecommitdiff
path: root/test/conn_test.exs
diff options
context:
space:
mode:
Diffstat (limited to 'test/conn_test.exs')
-rw-r--r--test/conn_test.exs23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/conn_test.exs b/test/conn_test.exs
index ff746b7..d2431d7 100644
--- a/test/conn_test.exs
+++ b/test/conn_test.exs
@@ -39,4 +39,27 @@ defmodule ShardTest.Conn do
{:ok, msg} = Box.open_easy(enc, n, pk, sk)
msg
end
+
+
+ test "set nickname" do
+ Shard.Identity.set_nickname "test bot"
+ end
+
+ test "connect to other instance" do
+ Shard.Manager.add_peer({127, 0, 0, 1}, 4045)
+ receive do after 100 -> nil end
+ end
+
+ test "connect to chat rooms" do
+ {:ok, pid1} = DynamicSupervisor.start_child(Shard.DynamicSupervisor, {SApp.Chat, "test"})
+ {:ok, pid2} = DynamicSupervisor.start_child(Shard.DynamicSupervisor, {SApp.Chat, "other_test"})
+ GenServer.cast(pid1, {:chat_send, "test msg 1"})
+ GenServer.cast(pid2, {:chat_send, "test msg 2"})
+
+ receive do after 100 -> nil end
+ {:ok, pid3} = DynamicSupervisor.start_child(Shard.DynamicSupervisor, {SApp.Chat, "test"})
+ receive do after 100 -> nil end
+ assert not Process.alive?(pid3)
+ end
+
end