at 17.09-beta 2.0 kB view raw
1 2import ./make-test.nix ({ pkgs, ...} : { 3 name = "ipfs"; 4 meta = with pkgs.stdenv.lib.maintainers; { 5 maintainers = [ mguentner ]; 6 }; 7 8 nodes = { 9 adder = 10 { config, pkgs, ... }: 11 { 12 services.ipfs = { 13 enable = true; 14 defaultMode = "norouting"; 15 gatewayAddress = "/ip4/127.0.0.1/tcp/2323"; 16 apiAddress = "/ip4/127.0.0.1/tcp/2324"; 17 }; 18 networking.firewall.allowedTCPPorts = [ 4001 ]; 19 }; 20 getter = 21 { config, pkgs, ... }: 22 { 23 services.ipfs = { 24 enable = true; 25 defaultMode = "norouting"; 26 # not yet. See #28621 27 #autoMount = true; 28 }; 29 networking.firewall.allowedTCPPorts = [ 4001 ]; 30 }; 31 }; 32 33 testScript = '' 34 startAll; 35 $adder->waitForUnit("ipfs-norouting"); 36 $getter->waitForUnit("ipfs-norouting"); 37 38 # wait until api is available 39 $adder->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/2324 id"); 40 my $addrId = $adder->succeed("ipfs --api /ip4/127.0.0.1/tcp/2324 id -f=\"<id>\""); 41 my $addrIp = (split /[ \/]+/, $adder->succeed("ip -o -4 addr show dev eth1"))[3]; 42 43 $adder->mustSucceed("[ -n \"\$(ipfs --api /ip4/127.0.0.1/tcp/2324 config Addresses.Gateway | grep /ip4/127.0.0.1/tcp/2323)\" ]"); 44 45 # wait until api is available 46 $getter->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/5001 id"); 47 my $ipfsHash = $adder->mustSucceed("echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | cut -d' ' -f2"); 48 chomp($ipfsHash); 49 50 $adder->mustSucceed("[ -n \"\$(echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | grep added)\" ]"); 51 52 $getter->mustSucceed("ipfs --api /ip4/127.0.0.1/tcp/5001 swarm connect /ip4/$addrIp/tcp/4001/ipfs/$addrId"); 53 $getter->mustSucceed("[ -n \"\$(ipfs --api /ip4/127.0.0.1/tcp/5001 cat /ipfs/$ipfsHash | grep fnord)\" ]"); 54 # not yet. See #28621 55 # $getter->mustSucceed("[ -n \"$(cat /ipfs/$ipfsHash | grep fnord)\" ]"); 56 ''; 57})