Skip to content

Commit

Permalink
Enhance ipfs add --cid-base32 tests.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Jan 17, 2019
1 parent 57457af commit 727aea1
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions test/sharness/t0040-add-and-cat.sh
Expand Up @@ -276,32 +276,55 @@ test_add_cat_file() {
# --cid-base=base32

test_expect_success "ipfs add --cid-base=base32 succeeds" '
echo "Hello Worlds!" >mountdir/hello.txt &&
ipfs add --cid-base=base32 mountdir/hello.txt >actual
echo "base32 test" >mountdir/base32-test.txt &&
ipfs add --cid-base=base32 mountdir/base32-test.txt >actual
'

test_expect_success "ipfs add output looks good" '
HASH="bafybeidpq7lcjx4w5c6yr4vuthzvlav54hgxsremwk73to5ferdc2rxhai" &&
echo "added $HASH hello.txt" >expected &&
test_expect_success "ipfs add --cid-base=base32 output looks good" '
HASHb32="bafybeibyosqxljd2eptb4ebbtvk7pb4aoxzqa6ttdsflty6rsslz5y6i34" &&
echo "added $HASHb32 base32-test.txt" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs add --cid-base=base32 --only-hash succeeds" '
ipfs add --cid-base=base32 --only-hash mountdir/hello.txt > oh_actual
ipfs add --cid-base=base32 --only-hash mountdir/base32-test.txt > oh_actual
'
test_expect_success "ipfs add --cid-base=base32 --only-hash output looks good" '
test_cmp expected oh_actual
'

test_expect_success "ipfs add --only-hash output looks good" '
test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false succeeds" '
echo "base32 test" >mountdir/base32-test.txt &&
ipfs add --cid-base=base32 --force-cid-base=false mountdir/base32-test.txt >actual
'
test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false output looks good" '
HASHv0=$(cid-fmt -v 0 -b z %s "$HASHb32") &&
echo "added $HASHv0 base32-test.txt" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false --only-hash succeeds" '
ipfs add --cid-base=base32 --force-cid-base=false --only-hash mountdir/base32-test.txt > oh_actual
'
test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false --only-hash output looks good" '
test_cmp expected oh_actual
'

test_expect_success "ipfs cat succeeds" '
ipfs cat "$HASH" >actual
test_expect_success "ipfs cat with base32 hash succeeds" '
ipfs cat "$HASHb32" >actual
'
test_expect_success "ipfs cat with base32 hash output looks good" '
echo "base32 test" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs cat output looks good" '
echo "Hello Worlds!" >expected &&
test_expect_success "ipfs cat using CIDv0 hash succeeds" '
ipfs cat "$HASHv0" >actual
'
test_expect_success "ipfs cat using CIDv0 hash looks good" '
echo "base32 test" >expected &&
test_cmp expected actual
'

}

test_add_cat_5MB() {
Expand Down Expand Up @@ -343,6 +366,11 @@ test_add_cat_5MB() {
test_cmp mountdir/bigfile actual
'

test_expect_success "remove hash" '
ipfs pin rm "$EXP_HASH" &&
ipfs block rm "$EXP_HASH"
'

test_expect_success "get base32 version of CID" '
ipfs cid base32 $EXP_HASH > base32_cid &&
BASE32_HASH=`cat base32_cid`
Expand Down

0 comments on commit 727aea1

Please sign in to comment.