Skip to content

Commit

Permalink
adder: add some additional tests for --cid-version=1
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 Mar 3, 2017
1 parent 5744bcc commit 33c65ba
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
21 changes: 16 additions & 5 deletions test/sharness/t0040-add-and-cat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ test_add_cat_5MB() {
test_cmp sha1_expected sha1_actual
'

test_expect_success "'ipfs add bigfile' succeeds" '
test_expect_success "'ipfs add $ADD_FLAGS bigfile' succeeds" '
ipfs add $ADD_FLAGS mountdir/bigfile >actual ||
test_fsh cat daemon_err
'
Expand Down Expand Up @@ -142,6 +142,9 @@ test_add_cat_raw() {
}

test_add_cat_expensive() {
ADD_FLAGS="$1"
HASH="$2"

test_expect_success EXPENSIVE "generate 100MB file using go-random" '
random 104857600 42 >mountdir/bigfile
'
Expand All @@ -152,12 +155,11 @@ test_add_cat_expensive() {
test_cmp sha1_expected sha1_actual
'

test_expect_success EXPENSIVE "ipfs add bigfile succeeds" '
ipfs add mountdir/bigfile >actual
test_expect_success EXPENSIVE "ipfs add $ADD_FLAGS bigfile succeeds" '
ipfs add $ADD_FLAGS mountdir/bigfile >actual
'

test_expect_success EXPENSIVE "ipfs add bigfile output looks good" '
HASH="QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'
Expand Down Expand Up @@ -426,11 +428,20 @@ test_add_cat_5MB "" "QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb"

test_add_cat_5MB --raw-leaves "QmbdLHCmdi48eM8T7D67oXjA1S2Puo8eMfngdHhdPukFd6"

# note: the specified hash implies that internal nodes are stored
# using CidV1 and leaves are stored using raw blocks
test_add_cat_5MB --cid-version=1 "zdj7WiiaedqVBXjX4SNqx3jfuZideDqdLYnDzCDJ66JDMK9o2"

# note: the specified hash implies that internal nodes are stored
# using CidV1 and leaves are stored using CidV1 but using the legacy
# format (i.e. not raw)
test_add_cat_5MB '--cid-version=1 --raw-leaves=false' "zdj7WfgEsj897BBZj2mcfsRLhaPZcCixPV2G7DkWgF1Wdr64P"

test_add_cat_expensive
test_add_cat_expensive "" "QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3"

# note: the specified hash implies that internal nodes are stored
# using CidV1 and leaves are stored using raw blocks
test_add_cat_expensive "--cid-version=1" "zdj7WcatQrtuE4WMkS4XsfsMixuQN2po4irkYhqxeJyW1wgCq"

test_add_named_pipe " Post http://$API_ADDR/api/v0/add?encoding=json&progress=true&r=true&stream-channels=true:"

Expand Down
16 changes: 16 additions & 0 deletions test/sharness/t0043-add-w.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ added QmYC3u5jGWuyFwvTxtvLYm2K3SpWZ31tg3NjpVVvh9cJaJ _jo7/wzvsihy
added QmQkib3f9XNX5sj6WEahLUPFpheTcwSRJwUCSvjcv8b9by _jo7
added QmNQoesMj1qp8ApE51NbtTjFYksyzkezPD4cat7V2kzbKN '

add_w_d1_v1='added zb2rhjXyHbbgwgtAUwHtpBd8iXLgK22ZjVmaiJSMNmqBTpXS3 _jo7/-s782qgs
added zb2rhi6PQqQFbS4QsvrV8sL9ue1fvFoqtLVqogNPCZri8rquN _jo7/15totauzkak-
added zb2rhjQthC6LgnNZztpsF9LcfPxznh3cJnmzUx8dnSqNqJ8Yz _jo7/galecuirrj4r
added zb2rhYh9hgDw1DpaZfLUU5MkKNezPWjPTkgGQPiTyLpZYu3jn _jo7/mzo50r-1xidf5zx
added zb2rhZK5xwEUhY4uskfj4sn979aCH27cnqseVVznYDn7NFWtt _jo7/wzvsihy
added zdj7WfNC8EZchqskczxsgrVEqwLVpksQ9B5kopf391jVbCGwv _jo7
added zdj7Wn5jf686mfYE8gUKWzY7aTjp5eAQcecD8q4ZtqLJbDNxe '

add_w_d2='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93
added QmU9Jqks8TPu4vFr6t7EKkAKQrSJuEujNj1AkzoCeTEDFJ gnz66h/1k0xpx34
added QmSLYZycXAufRw3ePMVH2brbtYWCcWsmksGLbHcT8ia9Ke gnz66h/9cwudvacx
Expand Down Expand Up @@ -133,6 +141,14 @@ test_add_w() {
test_sort_cmp expected actual
'

test_expect_success "ipfs add -w -r (dir) --cid-version=1 succeeds" '
ipfs add -r -w --cid-version=1 m/t_1wp-8a2/_jo7 >actual
'

test_expect_success "ipfs add -w -r (dir) --cid-version=1 is correct" '
echo "$add_w_d1_v1" >expected &&
test_sort_cmp expected actual
'
}

test_init_ipfs
Expand Down
11 changes: 11 additions & 0 deletions test/sharness/t0044-add-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ test_add_symlinks() {
test_cmp filehash_exp filehash_out
'

test_expect_success "ipfs add --cid-version=1 files succeeds" '
ipfs add -q -r --cid-version=1 files >filehash_all &&
tail -n 1 filehash_all >filehash_out
'

test_expect_success "output looks good" '
# note this hash implies all internal nodes are stored using CidV1
echo zdj7WZDQ2xMmr4qn6aRZTsE9fCUs2KmvPigpHdpssqUobwcWK > filehash_exp &&
test_cmp filehash_exp filehash_out
'

test_expect_success "adding a symlink adds the link itself" '
ipfs add -q files/bar/baz > goodlink_out
'
Expand Down

0 comments on commit 33c65ba

Please sign in to comment.