@cryptotaxi247 / kubo / commits / 5fbf0d35f

test(sharness): fix dht tests

Steven Allen committed Nov 15, 2019 at 09:15 UTC 5fbf0d35fb633773d481bd5cb1e40bec52fa82db
1 file changed +19 -25
test/sharness/t0170-dht.sh
+19 -25
@@ -4,9 +4,6 @@ test_description="Test dht command"
4
5 . lib/test-lib.sh
6
7 -TEST_DHT_VALUE="foobar"
8 -TEST_DHT_PATH="/pk/QmbWTwYGcmdyK9CYfNBcfs9nhZs17a6FQ4Y8oea278xx41"
9 -
7 test_dht() {
8 NUM_NODES=5
9
@@ -29,38 +26,35 @@ test_dht() {
26 test_cmp actual expected
27 '
28
32 - # ipfs dht put <key> <value>
33 - test_expect_failure 'put with good keys (#3124)' '
34 - ipfsi 0 dht put "$TEST_DHT_PATH" "$TEST_DHT_VALUE" | sort >putted &&
35 - [ -s putted ] ||
36 - test_fsh cat putted
37 - '
38 -
39 - test_expect_failure 'put round trips (#3124)' '
40 - echo -n "$TEST_DHT_VALUE" >expected &&
41 - ipfsi 0 dht get "$TEST_DHT_PATH" >actual &&
42 - test_cmp actual expected
43 - '
44 -
29 # ipfs dht get <key>
46 - test_expect_success 'get with good keys' '
30 + test_expect_success 'get with good keys works' '
31 HASH="$(echo "hello world" | ipfsi 2 add -q)" &&
32 ipfsi 2 name publish "/ipfs/$HASH" &&
49 - ipfsi 1 dht get "/ipns/$PEERID_2" | grep -aq "/ipfs/$HASH"
33 + ipfsi 1 dht get "/ipns/$PEERID_2" >get_result
34 + '
35 +
36 + test_expect_success 'get with good keys contains the right value' '
37 + cat get_result | grep -aq "/ipfs/$HASH"
38 + '
39 +
40 + test_expect_success 'put round trips (#3124)' '
41 + ipfsi 0 dht put "/ipns/$PEERID_2" get_result | sort >putted &&
42 + [ -s putted ] ||
43 + test_fsh cat putted
44 '
45
46 test_expect_success 'put with bad keys fails (issue #5113)' '
53 - ipfsi 0 dht put "foo" "bar" >putted
54 - ipfsi 0 dht put "/pk/foo" "bar" >>putted
55 - ipfsi 0 dht put "/ipns/foo" "bar" >>putted
47 + ipfsi 0 dht put "foo" <<<bar >putted
48 + ipfsi 0 dht put "/pk/foo" <<<bar >>putted
49 + ipfsi 0 dht put "/ipns/foo" <<<bar >>putted
50 [ ! -s putted ] ||
51 test_fsh cat putted
52 '
53
54 test_expect_success 'put with bad keys returns error (issue #4611)' '
61 - test_must_fail ipfsi 0 dht put "foo" "bar" &&
62 - test_must_fail ipfsi 0 dht put "/pk/foo" "bar" &&
63 - test_must_fail ipfsi 0 dht put "/ipns/foo" "bar"
55 + test_must_fail ipfsi 0 dht put "foo" <<<bar &&
56 + test_must_fail ipfsi 0 dht put "/pk/foo" <<<bar &&
57 + test_must_fail ipfsi 0 dht put "/ipns/foo" <<<bar
58 '
59
60 test_expect_success 'get with bad keys (issue #4611)' '
@@ -101,7 +95,7 @@ test_dht() {
95 test_expect_success "dht commands fail when offline" '
96 test_must_fail ipfsi 0 dht findprovs "$HASH" 2>err_findprovs &&
97 test_must_fail ipfsi 0 dht findpeer "$HASH" 2>err_findpeer &&
104 - test_must_fail ipfsi 0 dht put "$TEST_DHT_PATH" "$TEST_DHT_VALUE" 2>err_put &&
98 + test_must_fail ipfsi 0 dht put "/ipns/$PEERID_2" "get_result" 2>err_put &&
99 test_should_contain "this command must be run in online mode" err_findprovs &&
100 test_should_contain "this command must be run in online mode" err_findpeer &&
101 test_should_contain "this command must be run in online mode" err_put