fix dht tests

we no longer allow putting values with arbitrary keys.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
Steven Allen 2018-01-25 21:06:08 -08:00
parent 1159abd83e
commit 97cb6a0fbe

View File

@ -4,6 +4,9 @@ test_description="Test dht command"
. lib/test-lib.sh
TEST_DHT_VALUE="CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8hSwYY1FXqjT5M36O/Q5fBeDhXE5ePvGAeN3MIibfChqQpgqBbXQi1gAp4TQypSTKl/AMy7hfzsKauieim7jHMgIYAB4pLoBQD1qGVn/n7CqzAR3gDg9umIGuAy15oT0uaqMDqSepfnyxEyPDqfDklgvmS/MAwfBHjH2IPcMIaFgZ6d6gVlhmwuH8WVQ/geumDqyKuU9Jy+SUozmxEu2Baylg4fuqxaxoqOiPFZeWKSCFAngFj3NPmLApE0Fy48/eEZ+t7iP6s/raupP4+Jk/AFNDJNos4VxUnLJpZ1g6W5vYkkt1kXbMTaqxFVryCdCW2UEOwEzjGPGkcIE4RJrHAgMBAAE="
TEST_DHT_PATH="/pk/QmepgFW7BHEtU4pZJdxaNiv75mKLLRQnPi1KaaXmQN4V1a"
# start iptb + wait for peering
NUM_NODES=5
test_expect_success 'init iptb' '
@ -25,12 +28,30 @@ test_expect_success 'findpeer' '
'
# ipfs dht put <key> <value>
test_expect_success 'put' '
ipfsi 1 dht put planet pluto | sort >putted &&
test_expect_success 'put with good keys' '
echo "$TEST_DHT_VALUE" | base64 -d | ipfsi 0 dht put "$TEST_DHT_PATH" | sort >putted &&
[ -s putted ] ||
test_fsh cat putted
'
# ipfs dht get <key>
test_expect_success 'get with good keys' '
HASH="$(echo "hello world" | ipfsi 2 add -q)" &&
ipfsi 2 name publish "/ipfs/$HASH" &&
ipfsi 1 dht get "/ipns/$PEERID_2" | grep -aq "/ipfs/$HASH"
'
test_expect_failure 'put with bad keys' '
! ipfsi 0 dht put "foo" "bar" &&
! ipfsi 0 dht put "/pk/foo" "bar" &&
! ipfsi 0 dht put "/ipns/foo" "bar"
'
test_expect_failure 'get with bad keys' '
! ipfsi 0 dht get "foo" &&
! ipfsi 0 dht get "/pk/foo"
'
test_expect_success "add a ref so we can find providers for it" '
echo "some stuff" > afile &&
HASH=$(ipfsi 3 add -q afile)
@ -43,13 +64,6 @@ test_expect_success 'findprovs' '
test_cmp provs expected
'
# ipfs dht get <key>
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 <peerID>
## We query 3 different keys, to statisically lower the chance that the queryer