Added more tests, fixed bug with binary file xfer
This commit is contained in:
parent
b9c28ceed4
commit
8aa7b7ca77
4 changed files with 14 additions and 7 deletions
|
@ -394,7 +394,8 @@ void *api_connection_thread (void *ptr)
|
|||
}
|
||||
r = read(s, buf, sizeof buf);
|
||||
if (r <= 0) {
|
||||
libp2p_logger_error("api", "Read from client fail.\n");
|
||||
// this is a common occurrence, so moved from error to debug
|
||||
libp2p_logger_debug("api", "Read from client fail.\n");
|
||||
goto quit;
|
||||
}
|
||||
buf[r] = '\0';
|
||||
|
|
|
@ -293,7 +293,7 @@ int ipfs_exporter_object_cat(struct CliArguments* args) {
|
|||
size_t response_size = 0;
|
||||
int retVal = ipfs_core_http_request_get(local_node, request, &response, &response_size);
|
||||
if (response != NULL && response_size > 0) {
|
||||
fprintf(stdout, response);
|
||||
fwrite(response, 1, response_size, stdout);
|
||||
free(response);
|
||||
} else {
|
||||
retVal = 0;
|
||||
|
|
|
@ -18,7 +18,8 @@ function pre {
|
|||
|
||||
function post {
|
||||
rm -Rf /tmp/ipfs_1;
|
||||
# rm hello.bin;
|
||||
rm hello.bin;
|
||||
rm hello2.bin;
|
||||
}
|
||||
|
||||
function body {
|
||||
|
@ -31,8 +32,14 @@ function body {
|
|||
daemon_id=$!
|
||||
sleep 5
|
||||
|
||||
eval "$IPFS" cat QmSsV5T26CnCk3Yt7gtf6Bgyqwe4UtiaLiPbe9uUyr1nHd > hello2.bin
|
||||
eval "$IPFS" cat QmX4zpwaE7CSgZZsULgoB3gXYC6hh7RN19bEfWxw7sL8Xx > hello2.bin
|
||||
check_failure "cat" $?
|
||||
|
||||
# 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
|
||||
}
|
||||
|
|
5
test/scripts/test_helpers.sh
Normal file → Executable file
5
test/scripts/test_helpers.sh
Normal file → Executable file
|
@ -16,9 +16,9 @@ function create_hello_world {
|
|||
###
|
||||
function create_binary_file {
|
||||
rm hello.bin
|
||||
for byte in `seq 0 256`;
|
||||
for byte in `seq 0 255`;
|
||||
do
|
||||
printf "\\$(printf "%o" 0x$byte)" >> hello.bin
|
||||
printf "\\$(printf "%o" $byte)" >> hello.bin
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -34,4 +34,3 @@ function check_failure() {
|
|||
echo "***Failure*** in $FUNC. The return value was $RESULT";
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue