Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1a00813

Browse files
committedAug 27, 2015
Add test cases for ipfs api check
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
1 parent 5040fee commit 1a00813

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed
 

‎test/sharness/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ For example:
7171
test_expect_success ".ipfs/ has been created" '
7272
test -d ".ipfs" &&
7373
test -f ".ipfs/config" &&
74-
test -d ".ipfs/datastore" ||
74+
test -f ".ipfs/api" &&
75+
test -d ".ipfs/datastore" &&
76+
test -d ".ipfs/blocks" ||
7577
test_fsh ls -al .ipfs
7678
'
7779
```

‎test/sharness/t0020-init.sh

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ test_expect_success "ipfs init succeeds" '
4747
test_expect_success ".ipfs/ has been created" '
4848
test -d ".ipfs" &&
4949
test -f ".ipfs/config" &&
50+
test -f ".ipfs/api" &&
5051
test -d ".ipfs/datastore" &&
5152
test -d ".ipfs/blocks" ||
5253
test_fsh ls -al .ipfs

‎test/sharness/t0060-daemon.sh

+17-3
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ test_expect_success "ipfs daemon output looks good" '
7575
test_expect_success ".ipfs/ has been created" '
7676
test -d ".ipfs" &&
7777
test -f ".ipfs/config" &&
78-
test -d ".ipfs/datastore" ||
79-
test_fsh ls .ipfs
78+
test -f ".ipfs/api" &&
79+
test -d ".ipfs/datastore" &&
80+
test -d ".ipfs/blocks" ||
81+
test_fsh ls -al .ipfs
8082
'
8183

8284
# begin same as in t0010
@@ -102,13 +104,20 @@ test_expect_success "ipfs help output looks good" '
102104

103105
# check transport is encrypted
104106

105-
test_expect_success 'transport should be encrypted' '
107+
test_expect_success "transport should be encrypted" '
106108
nc -w 5 localhost 4001 >swarmnc &&
107109
grep -q "AES-256,AES-128" swarmnc &&
108110
test_must_fail grep -q "/ipfs/identify" swarmnc ||
109111
test_fsh cat swarmnc
110112
'
111113

114+
test_expect_success "client should err if api is off but daemon is on" '
115+
echo "Error: api not running" >expected &&
116+
echo "off" > $IPFS_PATH/api &&
117+
test_must_fail ipfs --api "/ip4/127.0.0.1/tcp/5001" id 2>actual &&
118+
test_cmp expected actual
119+
'
120+
112121
# end same as in t0010
113122

114123
test_expect_success "daemon is still running" '
@@ -119,6 +128,11 @@ test_expect_success "'ipfs daemon' can be killed" '
119128
test_kill_repeat_10_sec $IPFS_PID
120129
'
121130

131+
test_expect_success "client should work if api is on but daemon is off" '
132+
echo "/ip4/127.0.0.1/tcp/5003" > $IPFS_PATH/api &&
133+
ipfs --api "/ip4/127.0.0.1/tcp/5003" id
134+
'
135+
122136
test_expect_success "'ipfs daemon' should be able to run with a pipe attached to stdin (issue #861)" '
123137
yes | ipfs daemon --init >stdin_daemon_out 2>stdin_daemon_err &
124138
pollEndpoint -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr &&

0 commit comments

Comments
 (0)
Please sign in to comment.