| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2015 Jeromy Johnson |
| 4 | # MIT Licensed; see the LICENSE file in this repository. |
| 5 | # |
| 6 | |
| 7 | test_description="test bitswap commands" |
| 8 | |
| 9 | . lib/test-lib.sh |
| 10 | |
| 11 | test_init_ipfs |
| 12 | test_launch_ipfs_daemon |
| 13 | |
| 14 | test_expect_success "'ipfs bitswap stat' succeeds" ' |
| 15 | ipfs bitswap stat >stat_out |
| 16 | ' |
| 17 | |
| 18 | test_expect_success "'ipfs bitswap stat' output looks good" ' |
| 19 | cat <<EOF | unexpand -t2 >expected && |
| 20 | bitswap status |
| 21 | blocks received: 0 |
| 22 | blocks sent: 0 |
| 23 | data received: 0 |
| 24 | data sent: 0 |
| 25 | dup blocks received: 0 |
| 26 | dup data received: 0 |
| 27 | wantlist [0 keys] |
| 28 | partners [0] |
| 29 | EOF |
| 30 | test_cmp expected stat_out |
| 31 | ' |
| 32 | |
| 33 | test_expect_success "ipfs peer id looks good" ' |
| 34 | PEERID=$(ipfs config Identity.PeerID) && |
| 35 | test_check_peerid "$PEERID" |
| 36 | ' |
| 37 | |
| 38 | test_expect_success "'ipfs bitswap wantlist -p' works" ' |
| 39 | ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out |
| 40 | ' |
| 41 | |
| 42 | test_expect_success "'ipfs bitswap wantlist -p' output looks good" ' |
| 43 | test_must_be_empty wantlist_p_out |
| 44 | ' |
| 45 | |
| 46 | test_expect_success "hash was removed from wantlist" ' |
| 47 | ipfs bitswap wantlist > wantlist_out && |
| 48 | test_must_be_empty wantlist_out |
| 49 | ' |
| 50 | |
| 51 | test_expect_success "'ipfs bitswap stat' succeeds" ' |
| 52 | ipfs bitswap stat >stat_out |
| 53 | ' |
| 54 | |
| 55 | test_expect_success "'ipfs bitswap stat' output looks good" ' |
| 56 | cat <<EOF | unexpand -t2 >expected && |
| 57 | bitswap status |
| 58 | blocks received: 0 |
| 59 | blocks sent: 0 |
| 60 | data received: 0 |
| 61 | data sent: 0 |
| 62 | dup blocks received: 0 |
| 63 | dup data received: 0 |
| 64 | wantlist [0 keys] |
| 65 | partners [0] |
| 66 | EOF |
| 67 | test_cmp expected stat_out |
| 68 | ' |
| 69 | |
| 70 | test_expect_success "'ipfs bitswap wantlist -p' works" ' |
| 71 | ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out |
| 72 | ' |
| 73 | |
| 74 | test_expect_success "'ipfs bitswap wantlist -p' output looks good" ' |
| 75 | test_cmp wantlist_out wantlist_p_out |
| 76 | ' |
| 77 | |
| 78 | test_expect_success "'ipfs bitswap stat --human' succeeds" ' |
| 79 | ipfs bitswap stat --human >stat_out_human |
| 80 | ' |
| 81 | |
| 82 | |
| 83 | test_expect_success "'ipfs bitswap stat --human' output looks good" ' |
| 84 | cat <<EOF | unexpand -t2 >expected && |
| 85 | bitswap status |
| 86 | blocks received: 0 |
| 87 | blocks sent: 0 |
| 88 | data received: 0 B |
| 89 | data sent: 0 B |
| 90 | dup blocks received: 0 |
| 91 | dup data received: 0 B |
| 92 | wantlist [0 keys] |
| 93 | partners [0] |
| 94 | EOF |
| 95 | test_cmp expected stat_out_human |
| 96 | ' |
| 97 | |
| 98 | test_kill_ipfs_daemon |
| 99 | |
| 100 | test_done |