Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
3e96f481
Commit
3e96f481
authored
Nov 18, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: added daemon --init test
parent
a7d1fd42
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
test/lib/test-lib.sh
test/lib/test-lib.sh
+12
-0
test/t0060-daemon.sh
test/t0060-daemon.sh
+56
-0
No files found.
test/lib/test-lib.sh
View file @
3e96f481
...
...
@@ -39,6 +39,18 @@ test_cmp_repeat_10_sec() {
test_cmp
"
$1
"
"
$2
"
}
test_wait_output_n_lines_20_sec
()
{
echo
"
$2
"
>
expected_waitn
for
i
in
1 2 3 4 5 6 7 8 9 10
do
cat
"
$1
"
|
wc
-l
|
tr
-d
" "
>
actual_waitn
test_cmp
"expected_waitn"
"actual_waitn"
&&
return
sleep
2
done
cat
"
$1
"
|
wc
-l
|
tr
-d
" "
>
actual_waitn
test_cmp
"expected_waitn"
"actual_waitn"
}
test_launch_ipfs_mount
()
{
test_expect_success
"ipfs init succeeds"
'
...
...
test/t0060-daemon.sh
0 → 100755
View file @
3e96f481
#!/bin/sh
#
# Copyright (c) 2014 Juan Batiz-Benet
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test daemon command"
.
lib/test-lib.sh
test_expect_success
"ipfs daemon --init launches"
'
export IPFS_DIR="$(pwd)/.go-ipfs" &&
ipfs daemon --init 2>&1 >actual_init &
'
# this is because we have no way of knowing the daemon is done except look at
# output. but we can't yet compare it because we dont have the peer ID (config)
test_expect_success
"initialization ended"
'
IPFS_PID=$! &&
test_wait_output_n_lines_20_sec actual_init 6
'
# this is lifted straight from t0020-init.sh
test_expect_success
"ipfs peer id looks good"
'
PEERID=$(ipfs config Identity.PeerID) &&
echo $PEERID | tr -dC "[:alnum:]" | wc -c | tr -d " " >actual &&
echo "46" >expected &&
test_cmp_repeat_10_sec expected actual
'
# note this is almost the same as t0020-init.sh "ipfs init output looks good"
test_expect_success
"ipfs daemon output looks good"
'
STARTHASH="QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB" &&
echo "initializing ipfs node at $IPFS_DIR" >expected &&
echo "generating key pair...done" >>expected &&
echo "peer identity: $PEERID" >>expected &&
echo "\nto get started, enter: ipfs cat $STARTHASH" >>expected &&
echo "daemon listening on /ip4/127.0.0.1/tcp/5001" >>expected &&
test_cmp_repeat_10_sec expected actual_init
'
test_expect_success
".go-ipfs/ has been created"
'
test -d ".go-ipfs" &&
test -f ".go-ipfs/config" &&
test -d ".go-ipfs/datastore"
'
test_expect_success
"daemon is still running"
'
kill -0 $IPFS_PID
'
test_expect_success
"'ipfs daemon' can be killed"
'
test_kill_repeat_10_sec $IPFS_PID
'
test_done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment