t0130-multinode.sh 803 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/sh
#
# Copyright (c) 2015 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test multiple ipfs nodes"

. lib/test-lib.sh

export IPTB_ROOT="`pwd`/.iptb"

test_expect_success "set up a few nodes" '
14 15
	IPTB_PORT=$((RANDOM % 10000 + 22000)) &&
	iptb -n=3 "-p=$IPTB_PORT" init &&
16 17 18 19
	iptb -wait start
'

test_expect_success "add a file on node1" '
Christian Couder's avatar
Christian Couder committed
20
	export IPFS_PATH="$IPTB_ROOT/1" &&
21
	random 1000000 > filea &&
Christian Couder's avatar
Christian Couder committed
22
	FILEA_HASH=$(ipfs add -q filea)
23 24 25
'

test_expect_success "cat that file on node2" '
Christian Couder's avatar
Christian Couder committed
26 27
	export IPFS_PATH="$IPTB_ROOT/2" &&
	ipfs cat $FILEA_HASH >fileb
28 29 30 31
'

test_expect_success "verify files match" '
	multihash filea > expected1 &&
Christian Couder's avatar
Christian Couder committed
32
	multihash fileb > actual1 &&
33 34 35 36 37 38 39 40
	test_cmp actual1 expected1
'

test_expect_success "shut down nodes" '
	iptb stop
'

test_done