More API function tests...
[oweals/gnunet.git] / src / gns / test_gns_reverse_lookup.sh
1 #!/bin/bash
2 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
3 which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
4
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
17 TEST_NAME="dave.bob.alice.gnu"
18 gnunet-arm -s -c test_gns_lookup.conf
19 gnunet-identity -C bob -c test_gns_lookup.conf
20 BOB_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep bob | awk '{print $3}')
21 gnunet-identity -C daveego -c test_gns_lookup.conf
22 DAVE_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep dave | awk '{print $3}')
23 gnunet-identity -C aliceego -c test_gns_lookup.conf
24 ALICE_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep alice | awk '{print $3}')
25 gnunet-identity -C testego -c test_gns_lookup.conf
26 ROOT_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep testego | awk '{print $3}')
27
28 gnunet-identity -s gns-reverse -e bob -c test_gns_lookup.conf
29
30 gnunet-namestore -p -z testego -a -n alice -t PKEY -V $ALICE_PKEY -e never -c test_gns_lookup.conf
31 gnunet-namestore -p -z aliceego -a -n bob -t PKEY -V $BOB_PKEY -e never -c test_gns_lookup.conf
32 gnunet-namestore -p -z aliceego -a -n + -t REVERSE -V "alice $ROOT_PKEY 0" -e never -c test_gns_lookup.conf
33 gnunet-namestore -p -z bob -a -n dave -t PKEY -V $DAVE_PKEY -e never -c test_gns_lookup.conf
34 gnunet-namestore -p -z bob -a -n alice -t PKEY -V $ALICE_PKEY -e never -c test_gns_lookup.conf
35 #gnunet-namestore -p -z bob -a -n + -t REVERSE -V "bob $ALICE_PKEY 0" -e never -c test_gns_lookup.conf
36 gnunet-namestore -p -z daveego -a -n + -t REVERSE -V "dave $BOB_PKEY 0" -e never -c test_gns_lookup.conf
37 gnunet-namestore -p -z daveego -a -n bob -t PKEY -V $BOB_PKEY -e never -c test_gns_lookup.conf
38 gnunet-arm -i gns -c test_gns_lookup.conf
39 sleep 10
40 RES_NAME=`$DO_TIMEOUT gnunet-gns --raw -z testego -R $DAVE_PKEY -c test_gns_lookup.conf`
41 gnunet-arm -e -c test_gns_lookup.conf
42 rm -rf /tmp/test-gnunet-gns-peer-1/
43
44 if [ "$RES_NAME" == "$TEST_NAME" ]
45 then
46   exit 0
47 else
48   echo "Failed to resolve to proper IP, got $RES_IP."
49   exit 1
50 fi