@cryptotaxi247 / kubo / commits / 9a98158be

test(sharness): test address filtering

tests #6995

Steven Allen committed Mar 13, 2020 at 16:45 UTC 9a98158bed7cb2f8206ad4aef7f9d37f929c4a9b
1 file changed +61
test/sharness/t0142-testfilter.sh new
+61
@@ -0,0 +1,61 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Copyright (c) 2020 Protocol Labs
4 +# MIT/Apache-2.0 Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test swarm filters are effective"
8 +
9 +AF="/ip4/127.0.0.0/ipcidr/24"
10 +
11 +. lib/test-lib.sh
12 +
13 +NUM_NODES=3
14 +
15 +test_expect_success "set up testbed" '
16 + iptb testbed create -type localipfs -count $NUM_NODES -force -init
17 +'
18 +
19 +test_expect_success 'filter 127.0.0.0/24 on node 1' '
20 + ipfsi 1 config --json Swarm.AddrFilters "[\"$AF\"]"
21 +'
22 +
23 +for i in $(seq 0 $(( NUM_NODES - 1 ))); do
24 + test_expect_success 'enable quic for node $i' '
25 + echo "$i"
26 + ipfsi $i config --json Experimental.QUIC true
27 + '
28 +
29 + test_expect_success "change IP for node $i" '
30 + ipfsi $i config --json "Addresses.Swarm" \
31 + "[\"/ip4/127.0.$i.1/tcp/0\",\"/ip4/127.0.$i.1/udp/0/quic\",\"/ip4/127.0.$i.1/tcp/0/ws\"]"
32 + '
33 +done
34 +
35 +test_expect_success 'start cluster' '
36 + iptb start --wait
37 +'
38 +
39 +test_expect_success 'connecting 1 to 0 fails' '
40 + test_must_fail iptb connect 1 0
41 +'
42 +
43 +test_expect_success 'connecting 0 to 1 fails' '
44 + test_must_fail iptb connect 1 0
45 +'
46 +
47 +test_expect_success 'connecting 2 to 0 succeeds' '
48 + iptb connect 2 0
49 +'
50 +
51 +test_expect_success 'connecting 1 to 0 with dns addrs fails' '
52 + ipfsi 0 id -f "<addrs>" | sed "s|^/ip4/127.0.0.1/|/dns4/localhost/|" > addrs &&
53 + test_must_fail ipfsi 1 swarm connect $(cat addrs)
54 +'
55 +
56 +
57 +test_expect_success 'stopping cluster' '
58 + iptb stop
59 +'
60 +
61 +test_done