#!/bin/sh test_description="Test dht command" . lib/test-lib.sh # start iptb + wait for peering NUM_NODES=5 test_expect_success 'init iptb' ' iptb init -n $NUM_NODES --bootstrap=none --port=0 ' startup_cluster $NUM_NODES test_expect_success 'peer ids' ' PEERID_0=$(iptb get id 0) && PEERID_2=$(iptb get id 2) ' # ipfs dht findpeer test_expect_success 'findpeer' ' ipfsi 1 dht findpeer $PEERID_0 | sort >actual && ipfsi 0 id -f "" | cut -d / -f 1-5 | sort >expected && test_cmp actual expected ' # ipfs dht put test_expect_success 'put' ' ipfsi 1 dht put planet pluto | sort >putted && [ -s putted ] || test_fsh cat putted ' # ipfs dht findprovs test_expect_success 'findprovs' ' ipfsi 4 dht findprovs planet | sort >provs && sort provs putted | uniq -d >actual && [ -s actual ] || test_fsh cat actual ' # ipfs dht get test_expect_success 'get' ' ipfsi 0 dht put bar foo >actual && ipfsi 4 dht get -v bar >actual && egrep "error: record key does not have selectorfunc" actual > /dev//null || test_fsh cat actual ' # ipfs dht query ## We query 3 different keys, to statisically lower the chance that the queryer ## turns out to be the closest to what a key hashes to. test_expect_success 'query' ' ipfsi 3 dht query banana >actual && ipfsi 3 dht query apple >>actual && ipfsi 3 dht query pear >>actual && PEERS=$(wc -l actual | cut -d '"'"' '"'"' -f 1) && [ -s actual ] || test_fsh cat actual ' test_expect_success 'stop iptb' ' iptb stop ' test_done