2db66c4c1dfef90e0187eb8dae1305fe6bbe1527
[oweals/gnunet.git] / src / gns / test_gns_rel_expiration.sh
1 #!/bin/bash
2 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
3
4 LOCATION=$(which gnunet-config)
5 if [ -z $LOCATION ]
6 then
7         echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 
8         exit 1
9 fi
10
11 rm -r `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f`
12 which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
13 TEST_IP="127.0.0.1"
14 gnunet-arm -s -c test_gns_lookup.conf
15 gnunet-identity -C testego -c test_gns_lookup.conf
16 gnunet-identity -C delegatedego -c test_gns_lookup.conf
17 DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}')
18 gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
19 gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf
20 gnunet-arm -i gns -c test_gns_lookup.conf
21 sleep 7
22 gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP  -e '5 s' -c test_gns_lookup.conf
23 sleep 1
24 RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf`
25 sleep 6
26 RES_IP_EXP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf`
27 gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY  -e never -c test_gns_lookup.conf
28 gnunet-identity -D testego -c test_gns_lookup.conf
29 gnunet-identity -D delegatedego -c test_gns_lookup.conf
30 gnunet-arm -e -c test_gns_lookup.conf
31
32 if [ "$RES_IP_EXP" == "$TEST_IP" ]
33 then
34   echo "Failed to properly expire IP, got $RES_IP_EXP."
35   exit 1
36 fi
37
38 if [ "$RES_IP" == "$TEST_IP" ]
39 then
40   exit 0
41 else
42   echo "Failed to properly resolve IP, got $RES_IP."
43   exit 1
44 fi