master
sh 87 lines 2.79 KB
Raw
1 #!/usr/bin/env bash
2
3 test_description="Tests for various fixed issues and regressions."
4
5 . lib/test-lib.sh
6
7 test_init_ipfs --empty-repo=false
8
9 test_launch_ipfs_daemon
10
11 # Tests go here
12
13 test_expect_success "commands command with flag flags works via HTTP API - #2301" '
14 curl -X POST "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
15 '
16
17 test_expect_success "ipfs refs local over HTTP API returns NDJOSN not flat - #2803" '
18 echo "Hello World" | ipfs add &&
19 curl -X POST "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err"
20 '
21
22 test_expect_success "args expecting stdin don't crash when not given" '
23 curl -X POST "$API_ADDR/api/v0/bootstrap/add" > result
24 '
25
26 test_expect_success "no panic traces on daemon" '
27 test_must_fail grep "nil pointer dereference" daemon_err
28 '
29
30 test_expect_success "metrics work" '
31 curl -X POST "$API_ADDR/debug/metrics/prometheus" > pro_data &&
32 grep "ipfs_bs_cache_boxo_blockstore_cache_total" < pro_data ||
33 test_fsh cat pro_data
34 '
35
36 test_expect_success "pin add api looks right - #3753" '
37 HASH=$(date +"%FT%T.%N%z" | ipfs add -q) &&
38 curl -X POST "http://$API_ADDR/api/v0/pin/add/$HASH" > pinadd_out &&
39 echo "{\"Pins\":[\"$HASH\"]}" > pinadd_exp &&
40 test_cmp pinadd_out pinadd_exp
41 '
42
43 test_expect_success "pin add api looks right - #3753" '
44 curl -X POST "http://$API_ADDR/api/v0/pin/rm/$HASH" > pinrm_out &&
45 echo "{\"Pins\":[\"$HASH\"]}" > pinrm_exp &&
46 test_cmp pinrm_out pinrm_exp
47 '
48
49 test_expect_success SOCAT "no daemon crash on improper file argument - #4003 ( test needs socat )" '
50 FNC=$(echo $API_ADDR | awk -F: '\''{ printf "%s:%s", $1, $2 }'\'') &&
51 printf "POST /api/v0/add?pin=true HTTP/1.1\r\nHost: $API_ADDR\r\nContent-Type: multipart/form-data; boundary=Pyw9xQLtiLPE6XcI\r\nContent-Length: 22\r\n\r\n\r\n--Pyw9xQLtiLPE6XcI\r\n" | socat STDIO tcp-connect:$FNC | grep -m1 "500 Internal Server Error"
52 '
53
54 test_kill_ipfs_daemon
55
56 test_expect_success "ipfs daemon --offline --mount fails - #2995" '
57 test_expect_code 1 ipfs daemon --offline --mount 2>daemon_err &&
58 grep "mount is not currently supported in offline mode" daemon_err ||
59 test_fsh cat daemon_err
60 '
61
62 test_launch_ipfs_daemon_without_network
63
64 test_expect_success "'ipfs name resolve' succeeds after ipfs id when daemon offline" '
65 PEERID=`ipfs key list --ipns-base=base36 -l | grep self | cut -d " " -f1` &&
66 test_check_peerid "${PEERID}" &&
67 ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out
68 '
69
70 test_expect_success "pubrmlish --quieter output looks good" '
71 echo "${PEERID}" >expected1 &&
72 test_cmp expected1 publish_out
73 '
74
75 test_expect_success "'ipfs name resolve' succeeds" '
76 ipfs name resolve "$PEERID" >output
77 '
78
79 test_expect_success "resolve output looks good" '
80 printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 &&
81 test_cmp expected2 output
82 '
83
84 test_kill_ipfs_daemon
85
86 test_done
87