t0020-init.sh 1.16 KB
Newer Older
1 2 3 4 5 6 7 8
#!/bin/sh
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test init command"

9
. lib/test-lib.sh
10 11

test_expect_success "ipfs init succeeds" '
12
	export IPFS_PATH="$(pwd)/.go-ipfs" &&
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
13
	ipfs init >actual_init
14 15 16 17 18
'

test_expect_success ".go-ipfs/ has been created" '
	test -d ".go-ipfs" &&
	test -f ".go-ipfs/config" &&
19 20
	test -d ".go-ipfs/datastore" ||
	fsh ls -al .go-ipfs
21 22 23 24 25 26 27 28
'

test_expect_success "ipfs config succeeds" '
	echo leveldb >expected &&
	ipfs config Datastore.Type >actual &&
	test_cmp expected actual
'

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
29 30 31 32 33 34
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 expected actual
'
35

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
36
test_expect_success "ipfs init output looks good" '
37
	STARTHASH="QmTTFXiXoixwT53tcGPu419udsHEHYu6AHrQC8HAKdJYaZ" &&
38
	echo "initializing ipfs node at $IPFS_PATH" >expected &&
39
	echo "generating 4096-bit RSA keypair...done" >>expected &&
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
40
	echo "peer identity: $PEERID" >>expected &&
41
	printf "\\n%s\\n" "to get started, enter: ipfs cat $STARTHASH" >>expected &&
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
42 43 44 45
	test_cmp expected actual_init
'

test_done