aboutsummaryrefslogtreecommitdiff
path: root/shard/test/conn_test.exs
blob: 42f4bc609018e5207f3a548679463dd638aaaeba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
defmodule ShardTest.Conn do
  use ExUnit.Case
  doctest Shard.Application


  test "set nickname" do
    pk = Shard.Keys.get_any_identity
    pid = SApp.Identity.find_proc(pk)
    info = SApp.Identity.get_info(pid)
    new_info = %{info | nick: "test bot"}
    SApp.Identity.set_info(pid, new_info)
  end

  test "connect to other instance" do
    SNet.Manager.add_peer({:inet, {127, 0, 0, 1}, 4045})
    receive do after 100 -> nil end
  end

  test "connect to chat rooms" do
    pk = Shard.Keys.get_any_identity

    pid1 = Shard.Manager.find_or_start %SApp.Chat.Manifest{channel: "test"}
    pid2 = Shard.Manager.find_or_start %SApp.Chat.Manifest{channel: "other_test"}

    SApp.Chat.chat_send(pid1, pk, "test msg 1")
    SApp.Chat.chat_send(pid2, pk, "test msg 2")
  end

end