test_gns_zkey_lookup.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. # This file is in the public domain.
  3. trap "gnunet-arm -e -c test_gns_lookup.conf" INT
  4. which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5"
  5. LOCATION=$(which gnunet-config)
  6. if [ -z $LOCATION ]
  7. then
  8. LOCATION="gnunet-config"
  9. fi
  10. $LOCATION --version 1> /dev/null
  11. if test $? != 0
  12. then
  13. echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
  14. exit 77
  15. fi
  16. rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
  17. TEST_IP="127.0.0.1"
  18. gnunet-arm -s -c test_gns_lookup.conf
  19. gnunet-identity -C delegatedego -c test_gns_lookup.conf
  20. DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}')
  21. gnunet-identity -C testego -c test_gns_lookup.conf
  22. gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
  23. gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
  24. RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.${DELEGATED_PKEY} -t A -c test_gns_lookup.conf`
  25. gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
  26. gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
  27. gnunet-arm -e -c test_gns_lookup.conf
  28. rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
  29. if [ "$RES_IP" = "$TEST_IP" ]
  30. then
  31. exit 0
  32. else
  33. echo "Failed to resolve to proper IP, got $RES_IP, wanted $TEST_IP."
  34. exit 1
  35. fi