Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs/kubo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 979bcc810857
Choose a base ref
...
head repository: ipfs/kubo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d4938c9b0cd5
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Oct 3, 2015

  1. Move test add cat offline into t0040

    License: MIT
    Signed-off-by: rht <rhtbot@gmail.com>
    rht committed Oct 3, 2015
    Copy the full SHA
    220b9d2 View commit details
  2. sharness: add trickle and chunker test

    License: MIT
    Signed-off-by: rht <rhtbot@gmail.com>
    rht committed Oct 3, 2015
    Copy the full SHA
    32d9bd7 View commit details
  3. Merge pull request #1777 from rht/test/add

    Add trickle and chunker test
    jbenet committed Oct 3, 2015
    Copy the full SHA
    d4938c9 View commit details
Showing with 176 additions and 187 deletions.
  1. +176 −112 test/sharness/t0040-add-and-cat.sh
  2. +0 −75 test/sharness/t0041-add-cat-offline.sh
288 changes: 176 additions & 112 deletions test/sharness/t0040-add-and-cat.sh
Original file line number Diff line number Diff line change
@@ -12,6 +12,166 @@ client_err() {
printf "$@\n\nUse 'ipfs add --help' for information about this command\n"
}

test_add_cat_file() {
test_expect_success "ipfs add succeeds" '
echo "Hello Worlds!" >mountdir/hello.txt &&
ipfs add mountdir/hello.txt >actual
'

test_expect_success "ipfs add output looks good" '
HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
echo "added $HASH hello.txt" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs add --only-hash succeeds" '
ipfs add --only-hash mountdir/hello.txt > oh_actual
'

test_expect_success "ipfs add --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 output looks good" '
echo "Hello Worlds!" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs cat /ipfs/file succeeds" '
ipfs cat /ipfs/$HASH >actual
'

test_expect_success "output looks good" '
test_cmp expected actual
'

test_expect_success "ipfs add -t succeeds" '
ipfs add -t mountdir/hello.txt >actual
'

test_expect_success "ipfs add -t output looks good" '
HASH="QmUkUQgxXeggyaD5Ckv8ZqfW8wHBX6cYyeiyqvVZYzq5Bi" &&
echo "added $HASH hello.txt" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs add --chunker size-32 succeeds" '
ipfs add --chunker rabin mountdir/hello.txt >actual
'

test_expect_success "ipfs add --chunker size-32 output looks good" '
HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
echo "added $HASH hello.txt" >expected &&
test_cmp expected actual
'
}

test_add_cat_5MB() {
test_expect_success "generate 5MB file using go-random" '
random 5242880 41 >mountdir/bigfile
'

test_expect_success "sha1 of the file looks ok" '
echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'

test_expect_success "'ipfs add bigfile' succeeds" '
ipfs add mountdir/bigfile >actual
'

test_expect_success "'ipfs add bigfile' output looks good" '
HASH="QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'
test_expect_success "'ipfs cat' succeeds" '
ipfs cat "$HASH" >actual
'

test_expect_success "'ipfs cat' output looks good" '
test_cmp mountdir/bigfile actual
'

test_expect_success FUSE "cat ipfs/bigfile succeeds" '
cat "ipfs/$HASH" >actual
'

test_expect_success FUSE "cat ipfs/bigfile looks good" '
test_cmp mountdir/bigfile actual
'
}

test_add_cat_expensive() {
test_expect_success EXPENSIVE "generate 100MB file using go-random" '
random 104857600 42 >mountdir/bigfile
'

test_expect_success EXPENSIVE "sha1 of the file looks ok" '
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
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 bigfile output looks good" '
HASH="QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'

test_expect_success EXPENSIVE "ipfs cat succeeds" '
ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'

test_expect_success EXPENSIVE "ipfs cat output looks good" '
ipfs cat "$HASH" >actual &&
test_cmp mountdir/bigfile actual
'

test_expect_success EXPENSIVE "ipfs cat output hashed looks good" '
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
test_cmp sha1_expected sha1_actual
'

test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile succeeds" '
cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'

test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile looks good" '
test_cmp sha1_expected sha1_actual
'
}

test_add_named_pipe() {
err_prefix=$1
test_expect_success "useful error message when adding a named pipe" '
mkfifo named-pipe &&
test_expect_code 1 ipfs add named-pipe 2>actual &&
client_err "Error: Unrecognized file type for named-pipe: $(generic_stat named-pipe)" >expected &&
rm named-pipe &&
test_cmp expected actual
'

test_expect_success "useful error message when recursively adding a named pipe" '
mkdir -p named-pipe-dir &&
mkfifo named-pipe-dir/named-pipe &&
test_expect_code 1 ipfs add -r named-pipe-dir 2>actual &&
printf "Error:$err_prefix Unrecognized file type for named-pipe-dir/named-pipe: $(generic_stat named-pipe-dir/named-pipe)\n" >expected &&
rm named-pipe-dir/named-pipe &&
rmdir named-pipe-dir &&
test_cmp expected actual
'
}

test_launch_ipfs_daemon_and_mount

test_expect_success "'ipfs add --help' succeeds" '
@@ -32,39 +192,14 @@ test_expect_success "'ipfs cat --help' output looks good" '
test_fsh cat actual
'

test_expect_success "ipfs add succeeds" '
echo "Hello Worlds!" >mountdir/hello.txt &&
ipfs add mountdir/hello.txt >actual
'

test_expect_success "ipfs add output looks good" '
HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
echo "added $HASH hello.txt" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs add --only-hash succeeds" '
ipfs add --only-hash mountdir/hello.txt > oh_actual
'

test_expect_success "ipfs add --only-hash output looks good" '
ipfs add --only-hash mountdir/hello.txt > oh_actual
'

test_expect_success "ipfs cat succeeds" '
ipfs cat "$HASH" >actual
'

test_expect_success "ipfs cat output looks good" '
echo "Hello Worlds!" >expected &&
test_cmp expected actual
'
test_add_cat_file

test_expect_success "ipfs cat succeeds with stdin opened (issue #1141)" '
cat mountdir/hello.txt | while read line; do ipfs cat "$HASH" >actual || exit; done
'

test_expect_success "ipfs cat output looks good" '
cat mountdir/hello.txt >expected &&
test_cmp expected actual
'

@@ -186,101 +321,30 @@ test_expect_success "ipfs cat output looks good" '
'

test_expect_success "go-random is installed" '
type random
'

test_expect_success "generate 5MB file using go-random" '
random 5242880 41 >mountdir/bigfile
'

test_expect_success "sha1 of the file looks ok" '
echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'

test_expect_success "'ipfs add bigfile' succeeds" '
ipfs add mountdir/bigfile >actual
'
type random
'

test_expect_success "'ipfs add bigfile' output looks good" '
HASH="QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'
test_expect_success "'ipfs cat' succeeds" '
ipfs cat "$HASH" >actual
'

test_expect_success "'ipfs cat' output looks good" '
test_cmp mountdir/bigfile actual
'

test_expect_success FUSE "cat ipfs/bigfile succeeds" '
cat "ipfs/$HASH" >actual
'

test_expect_success FUSE "cat ipfs/bigfile looks good" '
test_cmp mountdir/bigfile actual
'
test_add_cat_5MB

test_expect_success EXPENSIVE "generate 100MB file using go-random" '
random 104857600 42 >mountdir/bigfile
'

test_expect_success EXPENSIVE "sha1 of the file looks ok" '
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'
test_add_cat_expensive

test_expect_success EXPENSIVE "ipfs add bigfile succeeds" '
ipfs add mountdir/bigfile >actual
'
test_add_named_pipe " Post http://127.0.0.1:$PORT_API/api/v0/add?encoding=json&progress=true&r=true&stream-channels=true:"

test_expect_success EXPENSIVE "ipfs add bigfile output looks good" '
HASH="QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'

test_expect_success EXPENSIVE "ipfs cat succeeds" '
ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'

test_expect_success EXPENSIVE "ipfs cat output looks good" '
ipfs cat "$HASH" >actual &&
test_cmp mountdir/bigfile actual
'

test_expect_success EXPENSIVE "ipfs cat output hashed looks good" '
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
test_cmp sha1_expected sha1_actual
'
test_kill_ipfs_daemon

test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile succeeds" '
cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'
# should work offline

test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile looks good" '
test_cmp sha1_expected sha1_actual
'
test_add_cat_file

test_expect_success "useful error message when adding a named pipe" '
mkfifo named-pipe &&
test_expect_code 1 ipfs add named-pipe 2>actual &&
client_err "Error: Unrecognized file type for named-pipe: $(generic_stat named-pipe)" >expected &&
test_cmp expected actual
test_expect_success "ipfs add --only-hash succeeds" '
echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash
'

test_expect_success "useful error message when recursively adding a named pipe" '
mkdir named-pipe-dir &&
mkfifo named-pipe-dir/named-pipe &&
test_expect_code 1 ipfs add -r named-pipe-dir 2>actual &&
printf "Error: Post http://127.0.0.1:$PORT_API/api/v0/add?encoding=json&progress=true&r=true&stream-channels=true: Unrecognized file type for named-pipe-dir/named-pipe: $(generic_stat named-pipe-dir/named-pipe)\n" >expected &&
test_cmp expected actual
#TODO: this doesn't work when online hence separated out from test_add_cat_file
test_expect_success "ipfs cat file fails" '
test_must_fail ipfs cat $(cat oh_hash)
'

test_kill_ipfs_daemon
test_add_named_pipe ""

test_done
75 changes: 0 additions & 75 deletions test/sharness/t0041-add-cat-offline.sh

This file was deleted.