2017-10-04 14:36:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
####
|
|
|
|
# Attempt to add and retrieve binary file from running daemon
|
|
|
|
#
|
|
|
|
####
|
|
|
|
|
|
|
|
source ./test_helpers.sh
|
|
|
|
|
|
|
|
IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
|
|
|
|
|
|
|
function pre {
|
|
|
|
rm -Rf /tmp/ipfs_1
|
|
|
|
eval "$IPFS" init;
|
2017-10-05 16:20:12 +00:00
|
|
|
check_failure_with_exit "pre" $?
|
2017-10-04 14:36:38 +00:00
|
|
|
cp ../config.test1.wo_journal /tmp/ipfs_1/config
|
|
|
|
}
|
|
|
|
|
|
|
|
function post {
|
|
|
|
rm -Rf /tmp/ipfs_1;
|
|
|
|
rm hello.bin;
|
|
|
|
rm hello2.bin;
|
|
|
|
}
|
|
|
|
|
|
|
|
function body {
|
2017-10-05 16:20:12 +00:00
|
|
|
create_binary_file 256;
|
2017-10-04 14:36:38 +00:00
|
|
|
|
|
|
|
#start the daemon
|
|
|
|
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
|
|
|
daemon_id=$!
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
# add file
|
|
|
|
eval "$IPFS" add hello.bin
|
2017-10-05 16:20:12 +00:00
|
|
|
check_failure_with_exit "add hello.bin" $?
|
2017-10-04 14:36:38 +00:00
|
|
|
sleep 5
|
|
|
|
|
|
|
|
# retrieve file
|
|
|
|
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
2017-10-05 16:20:12 +00:00
|
|
|
check_failure_with_exit "cat" $?
|
2017-10-04 14:36:38 +00:00
|
|
|
|
|
|
|
# file size should be 256
|
|
|
|
actualsize=$(wc -c < hello2.bin)
|
|
|
|
if [ $actualsize -ne 256 ]; then
|
|
|
|
echo '*** Failure *** file size incorrect'
|
|
|
|
fi
|
|
|
|
|
|
|
|
kill -9 $daemon_id
|
|
|
|
}
|