aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/tools/networking/croc/test-local-relay.nix
blob: bde05d6deb0aad51891f02dd7d735f0446453e9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{ stdenv, croc }:

stdenv.mkDerivation {
  name = "croc-test-local-relay";
  meta.timeout = 300;
  buildCommand = ''
          HOME=$(mktemp -d)
          # start a local relay
          ${croc}/bin/croc relay --ports 11111,11112 &
          # start sender in background
          MSG="See you later, alligator!"
          ${croc}/bin/croc --relay localhost:11111 send --code correct-horse-battery-staple --text "$MSG" &
          # wait for things to settle
          sleep 1
          # receive
          MSG2=$(${croc}/bin/croc --relay localhost:11111 --yes correct-horse-battery-staple)
          # compare
          [ "$MSG" = "$MSG2" ] && touch $out
  '';
}