@cryptotaxi247 / kubo / commits / 727aea1f2

Enhance ipfs add --cid-base32 tests.

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Jan 7, 2019 at 17:28 UTC 727aea1f2024f4e7956f2aac2cdd212b586ad29e
1 file changed +40 -12
test/sharness/t0040-add-and-cat.sh
+40 -12
@@ -276,32 +276,55 @@ test_add_cat_file() {
276 # --cid-base=base32
277
278 test_expect_success "ipfs add --cid-base=base32 succeeds" '
279 - echo "Hello Worlds!" >mountdir/hello.txt &&
280 - ipfs add --cid-base=base32 mountdir/hello.txt >actual
279 + echo "base32 test" >mountdir/base32-test.txt &&
280 + ipfs add --cid-base=base32 mountdir/base32-test.txt >actual
281 '
282 -
283 - test_expect_success "ipfs add output looks good" '
284 - HASH="bafybeidpq7lcjx4w5c6yr4vuthzvlav54hgxsremwk73to5ferdc2rxhai" &&
285 - echo "added $HASH hello.txt" >expected &&
282 + test_expect_success "ipfs add --cid-base=base32 output looks good" '
283 + HASHb32="bafybeibyosqxljd2eptb4ebbtvk7pb4aoxzqa6ttdsflty6rsslz5y6i34" &&
284 + echo "added $HASHb32 base32-test.txt" >expected &&
285 test_cmp expected actual
286 '
287
288 test_expect_success "ipfs add --cid-base=base32 --only-hash succeeds" '
290 - ipfs add --cid-base=base32 --only-hash mountdir/hello.txt > oh_actual
289 + ipfs add --cid-base=base32 --only-hash mountdir/base32-test.txt > oh_actual
290 + '
291 + test_expect_success "ipfs add --cid-base=base32 --only-hash output looks good" '
292 + test_cmp expected oh_actual
293 '
294
293 - test_expect_success "ipfs add --only-hash output looks good" '
295 + test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false succeeds" '
296 + echo "base32 test" >mountdir/base32-test.txt &&
297 + ipfs add --cid-base=base32 --force-cid-base=false mountdir/base32-test.txt >actual
298 + '
299 + test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false output looks good" '
300 + HASHv0=$(cid-fmt -v 0 -b z %s "$HASHb32") &&
301 + echo "added $HASHv0 base32-test.txt" >expected &&
302 + test_cmp expected actual
303 + '
304 +
305 + test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false --only-hash succeeds" '
306 + ipfs add --cid-base=base32 --force-cid-base=false --only-hash mountdir/base32-test.txt > oh_actual
307 + '
308 + test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false --only-hash output looks good" '
309 test_cmp expected oh_actual
310 '
311
297 - test_expect_success "ipfs cat succeeds" '
298 - ipfs cat "$HASH" >actual
312 + test_expect_success "ipfs cat with base32 hash succeeds" '
313 + ipfs cat "$HASHb32" >actual
314 + '
315 + test_expect_success "ipfs cat with base32 hash output looks good" '
316 + echo "base32 test" >expected &&
317 + test_cmp expected actual
318 '
319
301 - test_expect_success "ipfs cat output looks good" '
302 - echo "Hello Worlds!" >expected &&
320 + test_expect_success "ipfs cat using CIDv0 hash succeeds" '
321 + ipfs cat "$HASHv0" >actual
322 + '
323 + test_expect_success "ipfs cat using CIDv0 hash looks good" '
324 + echo "base32 test" >expected &&
325 test_cmp expected actual
326 '
327 +
328 }
329
330 test_add_cat_5MB() {
@@ -343,6 +366,11 @@ test_add_cat_5MB() {
366 test_cmp mountdir/bigfile actual
367 '
368
369 + test_expect_success "remove hash" '
370 + ipfs pin rm "$EXP_HASH" &&
371 + ipfs block rm "$EXP_HASH"
372 + '
373 +
374 test_expect_success "get base32 version of CID" '
375 ipfs cid base32 $EXP_HASH > base32_cid &&
376 BASE32_HASH=`cat base32_cid`