diff --git a/test/sharness/t0031-mount-publish.sh b/test/sharness/t0031-mount-publish.sh index a258b6016..309dc7801 100755 --- a/test/sharness/t0031-mount-publish.sh +++ b/test/sharness/t0031-mount-publish.sh @@ -1,10 +1,8 @@ #!/bin/sh -# -# MIT Licensed; see the LICENSE file in this repository. -# test_description="Test mount command in conjunction with publishing" +# imports . lib/test-lib.sh # if in travis CI, dont test mount (no fuse) @@ -16,56 +14,47 @@ fi test_init_ipfs -# start iptb -iptb init -n 2 -f --bootstrap=star --port=$PORT_SWARM -iptb start --wait -BADDR="/ip4/127.0.0.1/tcp/$PORT_SWARM/ipfs/" -ADDR1="${BADDR}$(iptb get id 0)" -ADDR2="${BADDR}$(iptb get id 1)" - -# bootstrap to the iptb peers -test_expect_success "bootstrap to iptb peers" ' - ipfs bootstrap add '$ADDR1' && - ipfs bootstrap add '$ADDR2' -' - -# launch the daemon -test_launch_ipfs_daemon - -# wait for peer bootstrapping -# TODO(noffle): this is very fragile -- how can we wait for this to happen for sure? -sleep 3 +# start iptb + wait for peering +NUM_NODES=3 +iptb init -n $NUM_NODES -f --bootstrap=none --port=0 +startup_cluster $NUM_NODES # pre-mount publish -HASH=$(echo 'hello warld' | ipfs add -q) +HASH=$(echo 'hello warld' | ipfsi 0 add -q) test_expect_success "can publish before mounting /ipns" ' - ipfs name publish '$HASH' + ipfsi 0 name publish '$HASH' ' # mount -test_mount_ipfs - -test_expect_success "cannot publish after mounting /ipns" ' - echo "Error: You cannot manually publish while IPNS is mounted." >expected && - test_must_fail ipfs name publish '$HASH' 2>actual && +IPFS_MOUNT_DIR="$PWD/ipfs" +IPNS_MOUNT_DIR="$PWD/ipns" +test_expect_success FUSE "'ipfs mount' succeeds" ' + ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual +' +test_expect_success FUSE "'ipfs mount' output looks good" ' + echo "IPFS mounted at: $PWD/ipfs" >expected && + echo "IPNS mounted at: $PWD/ipns" >>expected && test_cmp expected actual ' +test_expect_success "cannot publish after mounting /ipns" ' + echo "Error: You cannot manually publish while IPNS is mounted." >expected && + test_must_fail ipfsi 0 name publish '$HASH' 2>actual && + test_cmp expected actual +' test_expect_success "unmount /ipns out-of-band" ' - fusermount -u ipns + fusermount -u "'"$IPNS_MOUNT_DIR"'" ' -# wait a moment for the daemon to notice and clean up -# TODO(noffle): this is very fragile -- how can we wait for this to happen for sure? -sleep 2 - test_expect_success "can publish after unmounting /ipns" ' - ipfs name publish '$HASH' + ipfsi 0 name publish '$HASH' ' -# clean-up -test_kill_ipfs_daemon +# clean-up ipfs +test_expect_success "unmount /ipfs" ' + fusermount -u "'"$IPFS_MOUNT_DIR"'" +' iptb stop test_done