summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/cr/croc/test-local-relay.nix
blob: f0a66fcaba82bccdb10285df2d7398c00f24c0f7 (plain)
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
30
31
32
33
{ stdenv, croc }:

stdenv.mkDerivation {
  name = "croc-test-local-relay";

  nativeBuildInputs = [ croc ];

  buildCommand = ''
    HOME="$(mktemp -d)"
    # start a local relay
    croc relay --ports 11111,11112 &

    export CROC_SECRET="sN3nx4hGLeihmn8G"

    # start sender in background
    MSG="See you later, alligator!"
    croc --relay localhost:11111 send --code correct-horse-battery-staple --text "$MSG" &

    # wait for things to settle
    sleep 1
    MSG2=$(croc --relay localhost:11111 --yes correct-horse-battery-staple)

    # compare
    [ "$MSG" = "$MSG2" ] && touch $out
  '';

  __darwinAllowLocalNetworking = true;

  meta = {
    timeout = 300;
    broken = stdenv.hostPlatform.isDarwin;
  };
}