diff options
author | rexxnor <rexxnor+gnunet@brief.li> | 2020-02-03 18:26:49 +0100 |
---|---|---|
committer | rexxnor <rexxnor+gnunet@brief.li> | 2020-02-03 18:29:51 +0100 |
commit | 1bba6bc1221a64d97f593fc673b947ab5a7dfc54 (patch) | |
tree | 014cfad724260fca384d90a983aa2a73088a0fdb /src/gns/test_gns_multiple_record_lookup.sh | |
parent | e0e35fc2f34d49fb40a89f00ef639b241fc9d934 (diff) | |
download | gnunet-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-x | src/gns/test_gns_multiple_record_lookup.sh | 68 |
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. | ||
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" | ||
6 | |||
7 | LOCATION=$(which gnunet-config) | ||
8 | if [ -z $LOCATION ] | ||
9 | then | ||
10 | LOCATION="gnunet-config" | ||
11 | fi | ||
12 | $LOCATION --version 1> /dev/null | ||
13 | if test $? != 0 | ||
14 | then | ||
15 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
16 | exit 77 | ||
17 | fi | ||
18 | |||
19 | rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME` | ||
20 | rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME` | ||
21 | MY_EGO="localego" | ||
22 | OTHER_EGO="remoteego" | ||
23 | |||
24 | TEST_IP="127.0.0.1" | ||
25 | TEST_IPV6="dead::beef" | ||
26 | LABEL="fnord" | ||
27 | |||
28 | gnunet-arm -s -c test_gns_lookup_peer2.conf | ||
29 | PKEY=`$DO_TIMEOUT gnunet-identity -V -C $OTHER_EGO -c test_gns_lookup_peer2.conf` | ||
30 | gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_gns_lookup_peer2.conf | ||
31 | gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_gns_lookup_peer2.conf | ||
32 | gnunet-namestore -D -z $OTHER_EGO -n $LABEL | ||
33 | gnunet-arm -e -c test_gns_lookup_peer2.conf | ||
34 | |||
35 | echo "Second peer" | ||
36 | gnunet-arm -s -c test_gns_lookup_peer1.conf | ||
37 | echo "Second peer started" | ||
38 | RESP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t ANY -c test_gns_lookup_peer1.conf` | ||
39 | RESP1=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t A -c test_gns_lookup_peer1.conf` | ||
40 | RESP2=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t AAAA -c test_gns_lookup_peer1.conf` | ||
41 | gnunet-arm -e -c test_gns_lookup_peer1.conf | ||
42 | |||
43 | rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME` | ||
44 | rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME` | ||
45 | |||
46 | RESPONSES=($(echo $RESP | tr "\n" " " )) | ||
47 | |||
48 | if [ "$RESP1" == "$TEST_IP" ] | ||
49 | then | ||
50 | echo "PASS: A record resolution from DHT via separate peer" | ||
51 | else | ||
52 | echo "FAIL: A record resolution from DHT via separate peer, got $RESP1, expected $TEST_IP" | ||
53 | exit 1 | ||
54 | fi | ||
55 | if [ "$RESP2" == "$TEST_IPV6" ] | ||
56 | then | ||
57 | echo "PASS: AAAA record resolution from DHT via separate peer" | ||
58 | else | ||
59 | echo "FAIL: AAAA record resolution from DHT via separate peer, got $RESP2, expected $TEST_IPV6" | ||
60 | exit 1 | ||
61 | fi | ||
62 | if [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IPV6 $TEST_IP" ]] || [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IP $TEST_IPV6" ]] | ||
63 | then | ||
64 | echo "PASS: ANY record resolution from DHT via separate peer" | ||
65 | else | ||
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 | ||
68 | fi | ||