aboutsummaryrefslogtreecommitdiff
path: root/src/cli/gns/test_gns_multiple_record_lookup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/gns/test_gns_multiple_record_lookup.sh')
-rwxr-xr-xsrc/cli/gns/test_gns_multiple_record_lookup.sh94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/cli/gns/test_gns_multiple_record_lookup.sh b/src/cli/gns/test_gns_multiple_record_lookup.sh
new file mode 100755
index 000000000..2d00945d6
--- /dev/null
+++ b/src/cli/gns/test_gns_multiple_record_lookup.sh
@@ -0,0 +1,94 @@
1#!/bin/bash
2# This file is in the public domain.
3trap "gnunet-arm -e -c test_gns_lookup_peer1.conf" INT
4trap "gnunet-arm -e -c test_gns_lookup_peer2.conf" INT
5which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5"
6
7unset XDG_DATA_HOME
8unset XDG_CONFIG_HOME
9unset XDG_CACHE_HOME
10
11LOCATION=$(which gnunet-config)
12if [ -z $LOCATION ]
13then
14 LOCATION="gnunet-config"
15fi
16$LOCATION --version 1> /dev/null
17if test $? != 0
18then
19 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
20 exit 77
21fi
22
23rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME`
24rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME`
25MY_EGO="localego"
26OTHER_EGO="remoteego"
27
28TEST_IP="127.0.0.1"
29TEST_IPV6="dead::beef"
30LABEL="fnord"
31
32gnunet-arm -s -c test_gns_lookup_peer2.conf
33PKEY=`$DO_TIMEOUT gnunet-identity -V -C $OTHER_EGO -c test_gns_lookup_peer2.conf`
34
35# Note: if zonemaster is kept running, it MAY publish the "A" record in the
36# DHT immediately and then _LATER_ also the "AAAA" record. But as then there
37# will be TWO valid blocks in the DHT (one with only A and one with A and
38# AAAA), the subsequent GET for both may fail and only return the result with
39# just the "A" record).
40# If we _waited_ until the original block with just "A" expired, everything
41# would be fine, but we don't want to do that for the test, so we
42# simply pause publishing to the DHT until all records are defined.
43# In the future, it would be good to have an enhanced gnunet-namestore command
44# that would read a series of changes to be made to a record set from
45# stdin and do them _all_ *atomically*. Then we would not need to do this.
46
47gnunet-arm -c test_gns_lookup_peer2.conf -k zonemaster
48gnunet-arm -c test_gns_lookup_peer2.conf -k zonemaster-monitor
49
50gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_gns_lookup_peer2.conf
51gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_gns_lookup_peer2.conf
52gnunet-namestore -D -z $OTHER_EGO -n $LABEL
53
54gnunet-arm -c test_gns_lookup_peer2.conf -i zonemaster
55gnunet-arm -c test_gns_lookup_peer2.conf -i zonemaster-monitor
56
57
58gnunet-arm -s -c test_gns_lookup_peer1.conf
59
60
61RESP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t ANY -c test_gns_lookup_peer1.conf`
62RESP1=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t A -c test_gns_lookup_peer1.conf`
63RESP2=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t AAAA -c test_gns_lookup_peer1.conf`
64
65
66gnunet-arm -e -c test_gns_lookup_peer1.conf
67gnunet-arm -e -c test_gns_lookup_peer2.conf
68
69rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME`
70rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME`
71
72RESPONSES=($(echo $RESP | tr "\n" " " ))
73
74if [ "$RESP1" == "$TEST_IP" ]
75then
76 echo "PASS: A record resolution from DHT via separate peer"
77else
78 echo "FAIL: A record resolution from DHT via separate peer, got $RESP1, expected $TEST_IP"
79 exit 1
80fi
81if [ "$RESP2" == "$TEST_IPV6" ]
82then
83 echo "PASS: AAAA record resolution from DHT via separate peer"
84else
85 echo "FAIL: AAAA record resolution from DHT via separate peer, got $RESP2, expected $TEST_IPV6"
86 exit 1
87fi
88if [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IPV6 $TEST_IP" ]] || [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IP $TEST_IPV6" ]]
89then
90 echo "PASS: ANY record resolution from DHT via separate peer"
91else
92 echo "FAIL: ANY record resolution from DHT via separate peer, got $RESP, expected $TEST_IPV6 $TEST_IP or $TEST_IP $TEST_IPV6"
93 exit 1
94fi