Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / dht / test_dht_tools.py.in
index 1c6bdea187a3e94ef40334f744a9b79989c6f658..5ceabbfada96e0d537ec92eb5d7c4b5f3bcb2284 100644 (file)
@@ -1,4 +1,16 @@
 #!@PYTHON@
+#
+# This testcase simply checks that the DHT command-line tools work.
+# It launches a single peer, stores a value "testdata" under "testkey",
+# and then gives the system 50 ms to fetch it.
+#
+# This could fail if
+# - command line tool interfaces fail
+# - DHT plugins for storage are not installed / working
+# - block plugins for verification (the test plugin) is not installed
+#
+# The code does NOT depend on DHT routing or any actual P2P functionality.
+#
 from __future__ import print_function
 import os
 import sys
@@ -8,18 +20,18 @@ import subprocess
 import time
 import tempfile
 
+os.environ["PATH"] = "@bindir@" + ":" + os.environ["PATH"];
+
 if os.name == "nt":
   tmp = os.getenv ("TEMP")
 else:
   tmp = "/tmp"
 
 if os.name == 'nt':
-  pif = 'gnunet-peerinfo.exe'
   get = './gnunet-dht-get.exe'
   put = './gnunet-dht-put.exe'
   arm = 'gnunet-arm.exe'
 else:
-  pif = 'gnunet-peerinfo'
   get = './gnunet-dht-get'
   put = './gnunet-dht-put'
   arm = 'gnunet-arm'
@@ -27,7 +39,6 @@ else:
 tf, tempcfg = tempfile.mkstemp (prefix='test_dht_api_peer1.')
 os.close (tf)
 
-run_pif = [pif, '-c', tempcfg, '-sq']
 run_get = [get, '-c', tempcfg]
 run_put = [put, '-c', tempcfg]
 run_arm = [arm, '-c', tempcfg]
@@ -69,9 +80,6 @@ def r_something (to_run, extra_args, failer = None, normal = True, **kw):
 def r_arm (extra_args, **kw):
   return r_something (run_arm, extra_args, **kw)
 
-def r_pif (extra_args, **kw):
-  return r_something (run_pif, extra_args, **kw)
-
 def r_get (extra_args, **kw):
   return r_something (run_get, extra_args, **kw)
 
@@ -98,10 +106,6 @@ def print_only_failer (command, rc, stdo, stde, normal):
 
 shutil.copyfile ('test_dht_api_peer1.conf', tempcfg)
 
-print ("TEST: Generating hostkey...", end='')
-r_pif ([], failer = print_only_failer)
-print ("PASS")
-
 print ("TEST: Starting ARM...", end='')
 r_arm (['-s'], failer = end_arm_failer, want_stdo = False, want_stde = False)
 print ("PASS")
@@ -113,7 +117,7 @@ print ("PASS")
 time.sleep (1)
 
 print ("TEST: Testing get...", end='')
-rc, stdo, stde = r_get (['-k', 'testkey', '-T', '5 ms', '-t', '8'], want_stdo = True, failer = end_arm_failer)
+rc, stdo, stde = r_get (['-k', 'testkey', '-T', '50 ms', '-t', '8'], want_stdo = True, failer = end_arm_failer)
 stdo = stdo.replace ('\r', '').splitlines ()
 expect = "Result 0, type 8:\ntestdata".splitlines()
 if len (stdo) != 2 or len (expect) != 2 or stdo[0] != expect[0] or stdo[1] != expect[1]: