2 # This file is in the public domain.
3 trap "gnunet-arm -e -c test_gns_lookup_peer1.conf" INT
4 trap "gnunet-arm -e -c test_gns_lookup_peer2.conf" INT
5 which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5"
11 LOCATION=$(which gnunet-config)
14 LOCATION="gnunet-config"
16 $LOCATION --version 1> /dev/null
19 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
23 rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME`
24 rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME`
29 TEST_IPV6="dead::beef"
32 gnunet-arm -s -c test_gns_lookup_peer2.conf
33 PKEY=`$DO_TIMEOUT gnunet-identity -V -C $OTHER_EGO -c test_gns_lookup_peer2.conf`
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.
47 gnunet-arm -c test_gns_lookup_peer2.conf -k zonemaster
48 gnunet-arm -c test_gns_lookup_peer2.conf -k zonemaster-monitor
50 gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_gns_lookup_peer2.conf
51 gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_gns_lookup_peer2.conf
52 gnunet-namestore -D -z $OTHER_EGO -n $LABEL
54 gnunet-arm -c test_gns_lookup_peer2.conf -i zonemaster
55 gnunet-arm -c test_gns_lookup_peer2.conf -i zonemaster-monitor
58 gnunet-arm -s -c test_gns_lookup_peer1.conf
61 RESP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t ANY -c test_gns_lookup_peer1.conf`
62 RESP1=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t A -c test_gns_lookup_peer1.conf`
63 RESP2=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t AAAA -c test_gns_lookup_peer1.conf`
66 gnunet-arm -e -c test_gns_lookup_peer1.conf
67 gnunet-arm -e -c test_gns_lookup_peer2.conf
69 rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME`
70 rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME`
72 RESPONSES=($(echo $RESP | tr "\n" " " ))
74 if [ "$RESP1" == "$TEST_IP" ]
76 echo "PASS: A record resolution from DHT via separate peer"
78 echo "FAIL: A record resolution from DHT via separate peer, got $RESP1, expected $TEST_IP"
81 if [ "$RESP2" == "$TEST_IPV6" ]
83 echo "PASS: AAAA record resolution from DHT via separate peer"
85 echo "FAIL: AAAA record resolution from DHT via separate peer, got $RESP2, expected $TEST_IPV6"
88 if [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IPV6 $TEST_IP" ]] || [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IP $TEST_IPV6" ]]
90 echo "PASS: ANY record resolution from DHT via separate peer"
92 echo "FAIL: ANY record resolution from DHT via separate peer, got $RESP, expected $TEST_IPV6 $TEST_IP or $TEST_IP $TEST_IPV6"