added adaptive step-intervals
[oweals/gnunet.git] / src / gns / test_gns_pseu_shorten.sh
1 #!/bin/bash
2 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
3 which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
4
5 rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f`
6 TEST_IP="127.0.0.1"
7 TEST_PSEU="alice"
8 TEST_NAME="www.mybestfriendalice.gnu"
9 TEST_NAME_SHORT="www.alice.short.gnu"
10 gnunet-arm -s -c test_gns_lookup.conf
11 DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}')
12 gnunet-identity -c test_gns_lookup.conf -d
13 gnunet-identity -C short-zone -c test_gns_lookup.conf
14 gnunet-identity -C delegatedego -c test_gns_lookup.conf
15 gnunet-identity -e short-zone -s gns-short -c test_gns_lookup.conf
16 gnunet-identity -C testego -c test_gns_lookup.conf -c test_gns_lookup.conf
17 DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}')
18 SHORT=$(gnunet-identity -c test_gns_lookup.conf -d | grep short-zone | awk '{print $3}')
19 gnunet-namestore -p -z testego -a -n mybestfriendalice -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
20 gnunet-namestore -p -z testego -a -n short -t PKEY -V $SHORT -e never -c test_gns_lookup.conf
21 gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
22 gnunet-namestore -p -z delegatedego -a -n "+" -t PSEU -V $TEST_PSEU -e never -c test_gns_lookup.conf
23 # Force start of GNS
24 gnunet-arm -c test_gns_lookup.conf -i gns
25 # need to sleep here, to give PSEU record chance to be copied to DHT
26 sleep 1
27 RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_NAME -t A -c test_gns_lookup.conf`
28 # need to sleep here, as shortening happens asynchronously...
29 sleep 1
30 RES_IP_PSEU=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.alice.short.gnu -t A -c test_gns_lookup.conf`
31 gnunet-namestore -z testego -d -n mybestfriendalice -t PKEY -V $DELEGATED_PKEY  -e never -c test_gns_lookup.conf
32 gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP  -e never -c test_gns_lookup.conf
33 gnunet-arm -e -c test_gns_lookup.conf
34
35 if [ "$RES_IP" == "$TEST_IP" ]
36 then
37   echo "PASS: Resolved $TEST_NAME properly to $RES_IP."
38 else
39   echo "FAIL: Could not resolve $TEST_NAME to proper IP, got $RES_IP."
40   exit 1
41 fi
42
43 if [ "$RES_IP_PSEU" == "$TEST_IP" ]
44 then
45   echo "PASS: Resolved $TEST_NAME_SHORT properly to $RES_IP."
46   exit 0
47 else
48   echo "FAIL: Could not resolve $TEST_NAME_SHORT to proper IP, got $RES_IP_PSEU."
49   exit 1
50 fi