aboutsummaryrefslogtreecommitdiff
path: root/src/gns/test_gns_multiple_record_lookup.sh
diff options
context:
space:
mode:
authorrexxnor <rexxnor+gnunet@brief.li>2020-02-03 18:26:49 +0100
committerrexxnor <rexxnor+gnunet@brief.li>2020-02-03 18:29:51 +0100
commit1bba6bc1221a64d97f593fc673b947ab5a7dfc54 (patch)
tree014cfad724260fca384d90a983aa2a73088a0fdb /src/gns/test_gns_multiple_record_lookup.sh
parente0e35fc2f34d49fb40a89f00ef639b241fc9d934 (diff)
downloadgnunet-1bba6bc1221a64d97f593fc673b947ab5a7dfc54.tar.gz
gnunet-1bba6bc1221a64d97f593fc673b947ab5a7dfc54.zip
added a test for DHT lookup between peers
Diffstat (limited to 'src/gns/test_gns_multiple_record_lookup.sh')
-rwxr-xr-xsrc/gns/test_gns_multiple_record_lookup.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/gns/test_gns_multiple_record_lookup.sh b/src/gns/test_gns_multiple_record_lookup.sh
new file mode 100755
index 000000000..fbd9a6b13
--- /dev/null
+++ b/src/gns/test_gns_multiple_record_lookup.sh
@@ -0,0 +1,68 @@
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
7LOCATION=$(which gnunet-config)
8if [ -z $LOCATION ]
9then
10 LOCATION="gnunet-config"
11fi
12$LOCATION --version 1> /dev/null
13if test $? != 0
14then
15 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
16 exit 77
17fi
18
19rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME`
20rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME`
21MY_EGO="localego"
22OTHER_EGO="remoteego"
23
24TEST_IP="127.0.0.1"
25TEST_IPV6="dead::beef"
26LABEL="fnord"
27
28gnunet-arm -s -c test_gns_lookup_peer2.conf
29PKEY=`$DO_TIMEOUT gnunet-identity -V -C $OTHER_EGO -c test_gns_lookup_peer2.conf`
30gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_gns_lookup_peer2.conf
31gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_gns_lookup_peer2.conf
32gnunet-namestore -D -z $OTHER_EGO -n $LABEL
33gnunet-arm -e -c test_gns_lookup_peer2.conf
34
35echo "Second peer"
36gnunet-arm -s -c test_gns_lookup_peer1.conf
37echo "Second peer started"
38RESP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t ANY -c test_gns_lookup_peer1.conf`
39RESP1=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t A -c test_gns_lookup_peer1.conf`
40RESP2=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t AAAA -c test_gns_lookup_peer1.conf`
41gnunet-arm -e -c test_gns_lookup_peer1.conf
42
43rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME`
44rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME`
45
46RESPONSES=($(echo $RESP | tr "\n" " " ))
47
48if [ "$RESP1" == "$TEST_IP" ]
49then
50 echo "PASS: A record resolution from DHT via separate peer"
51else
52 echo "FAIL: A record resolution from DHT via separate peer, got $RESP1, expected $TEST_IP"
53 exit 1
54fi
55if [ "$RESP2" == "$TEST_IPV6" ]
56then
57 echo "PASS: AAAA record resolution from DHT via separate peer"
58else
59 echo "FAIL: AAAA record resolution from DHT via separate peer, got $RESP2, expected $TEST_IPV6"
60 exit 1
61fi
62if [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IPV6 $TEST_IP" ]] || [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IP $TEST_IPV6" ]]
63then
64 echo "PASS: ANY record resolution from DHT via separate peer"
65else
66 echo "FAIL: ANY record resolution from DHT via separate peer, got $RESP, expected $TEST_IPV6 $TEST_IP or $TEST_IP $TEST_IPV6"
67 exit 1
68fi