| 
									
										
										
										
											2016-11-26 20:07:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | import ./make-test.nix ({ pkgs, ...} : { | 
					
						
							|  |  |  |   name = "ipfs"; | 
					
						
							|  |  |  |   meta = with pkgs.stdenv.lib.maintainers; { | 
					
						
							|  |  |  |     maintainers = [ mguentner ]; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   nodes = { | 
					
						
							|  |  |  |     adder = | 
					
						
							|  |  |  |       { config, pkgs, ... }: | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         services.ipfs = { | 
					
						
							|  |  |  |           enable = true; | 
					
						
							| 
									
										
										
										
											2017-08-30 15:20:10 +02:00
										 |  |  |           defaultMode = "norouting"; | 
					
						
							| 
									
										
										
										
											2016-11-26 20:07:01 +01:00
										 |  |  |           gatewayAddress = "/ip4/127.0.0.1/tcp/2323"; | 
					
						
							|  |  |  |           apiAddress = "/ip4/127.0.0.1/tcp/2324"; | 
					
						
							|  |  |  |         }; | 
					
						
							| 
									
										
										
										
											2017-08-30 15:20:10 +02:00
										 |  |  |         networking.firewall.allowedTCPPorts = [ 4001 ]; | 
					
						
							| 
									
										
										
										
											2016-11-26 20:07:01 +01:00
										 |  |  |       }; | 
					
						
							|  |  |  |     getter = | 
					
						
							|  |  |  |       { config, pkgs, ... }: | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2017-08-30 15:20:10 +02:00
										 |  |  |         services.ipfs = { | 
					
						
							|  |  |  |           enable = true; | 
					
						
							|  |  |  |           defaultMode = "norouting"; | 
					
						
							| 
									
										
										
										
											2017-09-18 02:42:19 +02:00
										 |  |  |           autoMount = true; | 
					
						
							| 
									
										
										
										
											2017-08-30 15:20:10 +02:00
										 |  |  |         }; | 
					
						
							|  |  |  |         networking.firewall.allowedTCPPorts = [ 4001 ]; | 
					
						
							| 
									
										
										
										
											2016-11-26 20:07:01 +01:00
										 |  |  |       }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   testScript = ''
 | 
					
						
							|  |  |  |     startAll; | 
					
						
							| 
									
										
										
										
											2017-08-30 15:20:10 +02:00
										 |  |  |     $adder->waitForUnit("ipfs-norouting"); | 
					
						
							|  |  |  |     $getter->waitForUnit("ipfs-norouting"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # wait until api is available | 
					
						
							| 
									
										
										
										
											2016-11-26 20:07:01 +01:00
										 |  |  |     $adder->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/2324 id"); | 
					
						
							| 
									
										
										
										
											2017-08-30 15:20:10 +02:00
										 |  |  |     my $addrId = $adder->succeed("ipfs --api /ip4/127.0.0.1/tcp/2324 id -f=\"<id>\""); | 
					
						
							|  |  |  |     my $addrIp = (split /[ \/]+/, $adder->succeed("ip -o -4 addr show dev eth1"))[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $adder->mustSucceed("[ -n \"\$(ipfs --api /ip4/127.0.0.1/tcp/2324 config Addresses.Gateway | grep /ip4/127.0.0.1/tcp/2323)\" ]"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # wait until api is available | 
					
						
							|  |  |  |     $getter->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/5001 id"); | 
					
						
							|  |  |  |     my $ipfsHash = $adder->mustSucceed("echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | cut -d' ' -f2"); | 
					
						
							|  |  |  |     chomp($ipfsHash); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $adder->mustSucceed("[ -n \"\$(echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | grep added)\" ]"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $getter->mustSucceed("ipfs --api /ip4/127.0.0.1/tcp/5001 swarm connect /ip4/$addrIp/tcp/4001/ipfs/$addrId"); | 
					
						
							|  |  |  |     $getter->mustSucceed("[ -n \"\$(ipfs --api /ip4/127.0.0.1/tcp/5001 cat /ipfs/$ipfsHash | grep fnord)\" ]"); | 
					
						
							| 
									
										
										
										
											2017-09-18 02:42:19 +02:00
										 |  |  |     $getter->mustSucceed("[ -n \"$(cat /ipfs/$ipfsHash | grep fnord)\" ]"); | 
					
						
							| 
									
										
										
										
											2016-11-26 20:07:01 +01:00
										 |  |  |     '';
 | 
					
						
							|  |  |  | }) |