@cryptotaxi247 / kubo / commits / 97cb6a0fb

fix dht tests

we no longer allow putting values with arbitrary keys. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Jan 25, 2018 at 21:06 UTC 97cb6a0fbe0bdd197f9caa1eb6587fdc3c3d7037
1 file changed +23 -9
test/sharness/t0170-dht.sh
+23 -9
@@ -4,6 +4,9 @@ test_description="Test dht command"
4
5 . lib/test-lib.sh
6
7 +TEST_DHT_VALUE="CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8hSwYY1FXqjT5M36O/Q5fBeDhXE5ePvGAeN3MIibfChqQpgqBbXQi1gAp4TQypSTKl/AMy7hfzsKauieim7jHMgIYAB4pLoBQD1qGVn/n7CqzAR3gDg9umIGuAy15oT0uaqMDqSepfnyxEyPDqfDklgvmS/MAwfBHjH2IPcMIaFgZ6d6gVlhmwuH8WVQ/geumDqyKuU9Jy+SUozmxEu2Baylg4fuqxaxoqOiPFZeWKSCFAngFj3NPmLApE0Fy48/eEZ+t7iP6s/raupP4+Jk/AFNDJNos4VxUnLJpZ1g6W5vYkkt1kXbMTaqxFVryCdCW2UEOwEzjGPGkcIE4RJrHAgMBAAE="
8 +TEST_DHT_PATH="/pk/QmepgFW7BHEtU4pZJdxaNiv75mKLLRQnPi1KaaXmQN4V1a"
9 +
10 # start iptb + wait for peering
11 NUM_NODES=5
12 test_expect_success 'init iptb' '
@@ -25,12 +28,30 @@ test_expect_success 'findpeer' '
28 '
29
30 # ipfs dht put <key> <value>
28 -test_expect_success 'put' '
29 - ipfsi 1 dht put planet pluto | sort >putted &&
31 +test_expect_success 'put with good keys' '
32 + echo "$TEST_DHT_VALUE" | base64 -d | ipfsi 0 dht put "$TEST_DHT_PATH" | sort >putted &&
33 [ -s putted ] ||
34 test_fsh cat putted
35 '
36
37 +# ipfs dht get <key>
38 +test_expect_success 'get with good keys' '
39 + HASH="$(echo "hello world" | ipfsi 2 add -q)" &&
40 + ipfsi 2 name publish "/ipfs/$HASH" &&
41 + ipfsi 1 dht get "/ipns/$PEERID_2" | grep -aq "/ipfs/$HASH"
42 +'
43 +
44 +test_expect_failure 'put with bad keys' '
45 + ! ipfsi 0 dht put "foo" "bar" &&
46 + ! ipfsi 0 dht put "/pk/foo" "bar" &&
47 + ! ipfsi 0 dht put "/ipns/foo" "bar"
48 +'
49 +
50 +test_expect_failure 'get with bad keys' '
51 + ! ipfsi 0 dht get "foo" &&
52 + ! ipfsi 0 dht get "/pk/foo"
53 +'
54 +
55 test_expect_success "add a ref so we can find providers for it" '
56 echo "some stuff" > afile &&
57 HASH=$(ipfsi 3 add -q afile)
@@ -43,13 +64,6 @@ test_expect_success 'findprovs' '
64 test_cmp provs expected
65 '
66
46 -# ipfs dht get <key>
47 -test_expect_success 'get' '
48 - ipfsi 0 dht put bar foo >actual &&
49 - ipfsi 4 dht get -v bar >actual &&
50 - egrep "error: record key does not have selectorfunc" actual > /dev//null ||
51 - test_fsh cat actual
52 -'
67
68 # ipfs dht query <peerID>
69 ## We query 3 different keys, to statisically lower the chance that the queryer