diff options
Diffstat (limited to 'api/tests')
-rwxr-xr-x | api/tests/announce_zblock.sh | 8 | ||||
-rwxr-xr-x | api/tests/announce_zchain_link.sh | 10 | ||||
-rwxr-xr-x | api/tests/default_route.sh | 4 | ||||
-rwxr-xr-x | api/tests/gathered_zblocks.sh | 6 | ||||
-rwxr-xr-x | api/tests/gathered_zchain_zlatest_pairs.sh | 4 | ||||
-rwxr-xr-x | api/tests/get_peers.sh | 3 | ||||
-rwxr-xr-x | api/tests/latest_known_mined_block.sh | 4 | ||||
-rwxr-xr-x | api/tests/node_local_chain.sh | 4 | ||||
-rwxr-xr-x | api/tests/node_local_info.sh | 15 | ||||
-rwxr-xr-x | api/tests/node_local_zlatest.sh | 4 | ||||
-rwxr-xr-x | api/tests/show_mined_block.sh | 4 | ||||
-rwxr-xr-x | api/tests/test_all_routes.sh | 2 |
12 files changed, 43 insertions, 25 deletions
diff --git a/api/tests/announce_zblock.sh b/api/tests/announce_zblock.sh index 11572c0..43db7d3 100755 --- a/api/tests/announce_zblock.sh +++ b/api/tests/announce_zblock.sh @@ -1,9 +1,9 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" printf "TEST\t/v0/announce/zblock\n" printf "\t01:\tendpoint with valid data" -curl http://127.0.0.1:8610/v0/announce/zblock --header 'Content-Type: application/json' --data-raw '{"zblock":"'$(ak zchain --get-latest)'"}' 2>/dev/null | jq -M -c > /dev/null +curl -s http://127.0.0.1:8610/v0/announce/zblock --header 'Content-Type: application/json' --data-raw '{"zblock":"'$(ak zchain --get-latest)'"}' 2>/dev/null | jq -M -c > /dev/null if [ $? -eq 0 ] then printf "\t\t\033[0;32mPASSED\033[0;0m" @@ -13,7 +13,7 @@ fi printf "\n" printf "\t02:\tendpoint with invalid data" -curl http://127.0.0.1:8610/v0/announce/zblock --header 'Content-Type: application/json' --data-raw '{"zblock":"'$(ak zchain --get-latest)'sdfas"}' 2>/dev/null | jq -M -c > /dev/null +curl -s http://127.0.0.1:8610/v0/announce/zblock --header 'Content-Type: application/json' --data-raw '{"zblock":"'$(ak zchain --get-latest)'sdfas"}' 2>/dev/null | jq -M -c > /dev/null if [ $? -eq 0 ] then printf "\t\t\033[0;32mPASSED\033[0;0m" @@ -23,7 +23,7 @@ fi printf "\n" printf "\t03:\tendpoint no data" -curl http://127.0.0.1:8610/v0/announce/zblock --header 'Content-Type: application/json' --data-raw '{"zblock":""}' 2>/dev/null | jq -M -c > /dev/null +curl -s http://127.0.0.1:8610/v0/announce/zblock --header 'Content-Type: application/json' --data-raw '{"zblock":""}' 2>/dev/null | jq -M -c > /dev/null if [ $? -eq 0 ] then printf "\t\t\t\033[0;32mPASSED\033[0;0m" diff --git a/api/tests/announce_zchain_link.sh b/api/tests/announce_zchain_link.sh index c92a367..d938286 100755 --- a/api/tests/announce_zchain_link.sh +++ b/api/tests/announce_zchain_link.sh @@ -1,10 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" printf "TEST\t/v0/announce/zchain\n" -# curl http://127.0.0.1:8610/v0/announce/zchain +# curl -s http://127.0.0.1:8610/v0/announce/zchain printf "\t01:\tendpoint with valid data" -curl -POST http://localhost:8610/v0/announce/zchain --header 'Content-Type: application/json' --data-raw '{"zchain":"k51qzi5uqu5dgapvk7bhxmchuqya9immqdpbz0f1r91ckpdqzub63afn3d5apr"}' 2>/dev/null | jq -M -c > /dev/null +curl -s -POST http://localhost:8610/v0/announce/zchain --header 'Content-Type: application/json' --data-raw '{"zchain":"k51qzi5uqu5dgapvk7bhxmchuqya9immqdpbz0f1r91ckpdqzub63afn3d5apr"}' 2>/dev/null | jq -M -c > /dev/null if [ $? -eq 0 ] then printf "\t\t\033[0;32mPASSED\033[0;0m" @@ -14,7 +14,7 @@ fi printf "\n" printf "\t02:\tendpoint with invalid data" -curl -POST http://localhost:8610/v0/announce/zchain --header 'Content-Type: application/json' --data-raw '{"zchain":"k51qzi5uqu5dgapvk7bhxmchuqya9immqdpbz0f1r91ckpdqzub63afn3d5aar"}' 2>/dev/null | jq -M -c > /dev/null +curl -s -POST http://localhost:8610/v0/announce/zchain --header 'Content-Type: application/json' --data-raw '{"zchain":"k51qzi5uqu5dgapvk7bhxmchuqya9immqdpbz0f1r91ckpdqzub63afn3d5aar"}' 2>/dev/null | jq -M -c > /dev/null if [ $? -eq 0 ] then printf "\t\t\033[0;32mPASSED\033[0;0m" @@ -24,7 +24,7 @@ fi printf "\n" printf "\t03:\tendpoint no data" -curl -POST http://localhost:8610/v0/announce/zchain --header 'Content-Type: application/json' --data-raw '{"zchain":""}' 2>/dev/null | jq -M -c > /dev/null +curl -s -POST http://localhost:8610/v0/announce/zchain --header 'Content-Type: application/json' --data-raw '{"zchain":""}' 2>/dev/null | jq -M -c > /dev/null if [ $? -eq 0 ] then printf "\t\t\t\033[0;32mPASSED\033[0;0m" diff --git a/api/tests/default_route.sh b/api/tests/default_route.sh index 950ce32..3b1ba6c 100755 --- a/api/tests/default_route.sh +++ b/api/tests/default_route.sh @@ -1,7 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" -curl http://127.0.0.1:8610 2>/dev/null | jq > /dev/null +curl -s http://127.0.0.1:8610 2>/dev/null | jq > /dev/null if [ $? -eq 0 ] then printf "\t\t\033[0;32mPASSED\033[0;0m" diff --git a/api/tests/gathered_zblocks.sh b/api/tests/gathered_zblocks.sh index 3e38ccc..273f968 100755 --- a/api/tests/gathered_zblocks.sh +++ b/api/tests/gathered_zblocks.sh @@ -1,11 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash # PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" printf "TEST\t/see\n" printf "\t01:\tOutput is valid JSON format..." -curl http://127.0.0.1:8610/v0/see 2>/dev/null | jq > /dev/null +curl -s http://127.0.0.1:8610/v0/see 2>/dev/null | jq > /dev/null if [ $? -eq 0 ] then printf "\t\t\033[0;32mPASSED\033[0;0m" @@ -15,7 +15,7 @@ fi printf "\n" printf "\t02:\tFound blocks inside response..." -curl http://127.0.0.1:8610/v0/see 2>/dev/null | grep block > /dev/null +curl -s http://127.0.0.1:8610/v0/see 2>/dev/null | grep block > /dev/null if [ $? -eq 0 ] then printf "\t\t\033[0;32mPASSED\033[0;0m" diff --git a/api/tests/gathered_zchain_zlatest_pairs.sh b/api/tests/gathered_zchain_zlatest_pairs.sh index 361cc33..e30f24c 100755 --- a/api/tests/gathered_zchain_zlatest_pairs.sh +++ b/api/tests/gathered_zchain_zlatest_pairs.sh @@ -1,9 +1,9 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" printf "TEST\t/seens\n" printf "\t01:\tendpoint returns JSON..." -curl http://127.0.0.1:8610/v0/seens 2>/dev/null | jq > /dev/null +curl -s http://127.0.0.1:8610/v0/seens 2>/dev/null | jq > /dev/null if [ $? -eq 0 ] then printf '\t\t\033[0;32mPASSED\033[0;0m\n' diff --git a/api/tests/get_peers.sh b/api/tests/get_peers.sh new file mode 100755 index 0000000..14d7a54 --- /dev/null +++ b/api/tests/get_peers.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +curl -s -o soe "http://[`cjdns-online`]:8610/v0/peers" | jq diff --git a/api/tests/latest_known_mined_block.sh b/api/tests/latest_known_mined_block.sh index 64ff612..1ef55a1 100755 --- a/api/tests/latest_known_mined_block.sh +++ b/api/tests/latest_known_mined_block.sh @@ -1,10 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash # PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" printf "TEST\t/slatest\n" printf "\t01:\tendpoint" -A="$(curl http://127.0.0.1:8610/v0/slatest 2>/dev/null)" +A="$(curl -s http://127.0.0.1:8610/v0/slatest 2>/dev/null)" B="$(ak schain --get-latest)" if [ "$A" == "$B" ] then diff --git a/api/tests/node_local_chain.sh b/api/tests/node_local_chain.sh index d1b87b4..626456e 100755 --- a/api/tests/node_local_chain.sh +++ b/api/tests/node_local_chain.sh @@ -1,9 +1,9 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" printf "TEST /zchain\n" printf "\t01:\tComparing API with CLI response..." -API_RESPONSE="$(curl http://127.0.0.1:8610/v0/zchain 2>/dev/null | jq -c -M | sha512sum - | awk '{print $1 }')" +API_RESPONSE="$(curl -s http://127.0.0.1:8610/v0/zchain 2>/dev/null | jq -c -M | sha512sum - | awk '{print $1 }')" CMD_RESPONSE="$(ak zchain --crawl | jq -c -M | sha512sum - | awk '{ print $1 }')" if [ "$API_RESPONSE" == "$CMD_RESPONSE" ] then diff --git a/api/tests/node_local_info.sh b/api/tests/node_local_info.sh new file mode 100755 index 0000000..0d45438 --- /dev/null +++ b/api/tests/node_local_info.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +PROGRAM="$(basename $0)" +source $AK_LIBDIR/_ak_ipfs +printf '[%s]\n' "$PROGRAM" +API_RES="$(curl -s http://127.0.0.1:8610/v0/node_info 2>/dev/null | sha512sum - | awk '{ printf $1 }')" +CMD_RES="$(_ak_ipfs_cat $(ak-node-info --ipfs) | sha512sum - | awk '{ printf $1 }')" +printf "TEST /node_info\n" +printf "\t01:\tLatest is the same between API response and CLI..." +if [ "$API_RES" == "$CMD_RES" ] +then + printf "\t\t\033[0;32mPASSED\033[0;0m" +else + printf "\t\t\033[0;31mFAILED\033[0;0m" +fi +printf "\n" diff --git a/api/tests/node_local_zlatest.sh b/api/tests/node_local_zlatest.sh index aaf2681..fe8e01b 100755 --- a/api/tests/node_local_zlatest.sh +++ b/api/tests/node_local_zlatest.sh @@ -1,7 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" -API_RES="$(curl http://127.0.0.1:8610/v0/zlatest 2>/dev/null | sha512sum - | awk '{ printf $1 }')" +API_RES="$(curl -s http://127.0.0.1:8610/v0/zlatest 2>/dev/null | sha512sum - | awk '{ printf $1 }')" CMD_RES="$(ak zchain --get-latest | sed -e 's/^/{"zlatest":"/; s/$/"}/' | sha512sum - | awk '{ printf $1 }')" printf "TEST /zlatest\n" printf "\t01:\tLatest is the same between API response and CLI..." diff --git a/api/tests/show_mined_block.sh b/api/tests/show_mined_block.sh index 51847d7..a621af1 100755 --- a/api/tests/show_mined_block.sh +++ b/api/tests/show_mined_block.sh @@ -1,5 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s]\n' "$PROGRAM" printf "#TODO /sblock endpoint\n" -# curl http://127.0.0.1:8610/v0/sblock +# curl -s http://127.0.0.1:8610/v0/sblock diff --git a/api/tests/test_all_routes.sh b/api/tests/test_all_routes.sh index 9a56faa..b9fd125 100755 --- a/api/tests/test_all_routes.sh +++ b/api/tests/test_all_routes.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash PROGRAM="$(basename $0)" printf '[%s] Starting tests...\n' "$PROGRAM" bash node_local_chain.sh |