diff --git a/pkgs/tools/networking/croc/default.nix b/pkgs/tools/networking/croc/default.nix index f11379041871..36fc5583439f 100644 --- a/pkgs/tools/networking/croc/default.nix +++ b/pkgs/tools/networking/croc/default.nix @@ -1,4 +1,4 @@ -{ stdenv, buildGoModule, fetchFromGitHub }: +{ stdenv, buildGoModule, fetchFromGitHub, callPackage}: buildGoModule rec { pname = "croc"; @@ -17,6 +17,11 @@ buildGoModule rec { subPackages = [ "." ]; + passthru = { + tests = { + local-relay = callPackage ./test-local-relay.nix {}; + }; + }; meta = with stdenv.lib; { description = "Easily and securely send things from one computer to another"; diff --git a/pkgs/tools/networking/croc/test-local-relay.nix b/pkgs/tools/networking/croc/test-local-relay.nix new file mode 100644 index 000000000000..bde05d6deb0a --- /dev/null +++ b/pkgs/tools/networking/croc/test-local-relay.nix @@ -0,0 +1,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 + ''; +}