t0101-iptb-name.sh 1.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/sh
#
# Copyright (c) 2014 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test ipfs repo operations"

. lib/test-lib.sh

export IPTB_ROOT="`pwd`/.iptb"

13

14
test_expect_success "set up an iptb cluster" '
15 16
	IPTB_PORT=$((RANDOM % 10000 + 22000)) &&
	iptb -n=4 "-p=$IPTB_PORT" init &&
17 18 19 20
	iptb -wait start
'

test_expect_success "add an obect on one node" '
Jeromy's avatar
Jeromy committed
21
	export IPFS_PATH="$IPTB_ROOT/1" &&
22 23 24 25 26 27 28 29 30
	echo "ipns is super fun" > file &&
	HASH_FILE=`ipfs add -q file`
'

test_expect_success "publish that object as an ipns entry" '
	ipfs name publish $HASH_FILE
'

test_expect_success "add an entry on another node pointing to that one" '
Jeromy's avatar
Jeromy committed
31
	export IPFS_PATH="$IPTB_ROOT/2" &&
32 33 34 35 36
	NODE1_ID=`iptb get id 1` &&
	ipfs name publish /ipns/$NODE1_ID
'

test_expect_success "cat that entry on a third node" '
Jeromy's avatar
Jeromy committed
37
	export IPFS_PATH="$IPTB_ROOT/3" &&
38 39 40 41 42 43 44 45 46 47 48 49 50
	NODE2_ID=`iptb get id 2` &&
	ipfs cat /ipns/$NODE2_ID > output
'

test_expect_success "ensure output was the same" '
	test_cmp file output
'

test_expect_success "shut down iptb" '
	iptb stop
'

test_done