diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2023-03-30 01:09:30 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2023-03-30 01:09:30 +0300 |
commit | e2da6d2db20093ebd2a65aad35c9991ab1a02176 (patch) | |
tree | e5c77a8f4a6fd106b13b659e248cab5768d07cdc /api/tests | |
parent | a4901ad47d2945e9a6c6616661840c97ebbf03e7 (diff) | |
download | arching-kaos-tools-e2da6d2db20093ebd2a65aad35c9991ab1a02176.tar.gz arching-kaos-tools-e2da6d2db20093ebd2a65aad35c9991ab1a02176.tar.bz2 arching-kaos-tools-e2da6d2db20093ebd2a65aad35c9991ab1a02176.zip |
Introducing an HTTP JSON API
Diffstat (limited to 'api/tests')
-rw-r--r-- | api/tests/default_route.sh | 2 | ||||
-rwxr-xr-x | api/tests/gathered_zblocks.sh | 23 | ||||
-rwxr-xr-x | api/tests/gathered_zchain_zlatest_pairs.sh | 10 | ||||
-rwxr-xr-x | api/tests/latest_known_mined_block.sh | 13 | ||||
-rwxr-xr-x | api/tests/node_local_chain.sh | 12 | ||||
-rwxr-xr-x | api/tests/node_local_zlatest.sh | 12 | ||||
-rwxr-xr-x | api/tests/send_me_a_zblock.sh | 3 | ||||
-rwxr-xr-x | api/tests/send_me_a_zchain_link.sh | 3 | ||||
-rwxr-xr-x | api/tests/show_mined_block.sh | 3 | ||||
-rwxr-xr-x | api/tests/test_all_routes.sh | 9 |
10 files changed, 90 insertions, 0 deletions
diff --git a/api/tests/default_route.sh b/api/tests/default_route.sh new file mode 100644 index 0000000..8e73ae6 --- /dev/null +++ b/api/tests/default_route.sh @@ -0,0 +1,2 @@ +#!/bin/bash +curl http://127.0.0.1:8610 diff --git a/api/tests/gathered_zblocks.sh b/api/tests/gathered_zblocks.sh new file mode 100755 index 0000000..cbe2c9a --- /dev/null +++ b/api/tests/gathered_zblocks.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# + +printf "TEST /see\n" +printf "\t01:\tOutput is JSON" +curl http://127.0.0.1:8610/v0/see 2>/dev/null | jq > /dev/null +if [ "$?" == "0" ] +then + printf "\n\t\t\033[0;32mPASSED\033[0;0m" +else + printf "\t\033[0;31mFAILED\033[0;0m" +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 +if [ "$?" == "0" ] +then + printf "\n\t\t\033[0;32mPASSED\033[0;0m" +else + printf "\n\t\t\033[0;31mFAILED\033[0;0m" +fi +printf "\n" diff --git a/api/tests/gathered_zchain_zlatest_pairs.sh b/api/tests/gathered_zchain_zlatest_pairs.sh new file mode 100755 index 0000000..466c669 --- /dev/null +++ b/api/tests/gathered_zchain_zlatest_pairs.sh @@ -0,0 +1,10 @@ +#!/bin/bash +printf "TEST\t/seens\n" +printf "\t01:\tendpoint returns JSON...\n" +curl http://127.0.0.1:8610/v0/seens 2>/dev/null | jq > /dev/null +if [ "$?" == "0" ] +then + printf '\t\t\033[0;32mPASSED\033[0;0m\n' +else + printf '\t\t\033[0;31mFAILED\033[0;0m\n' +fi diff --git a/api/tests/latest_known_mined_block.sh b/api/tests/latest_known_mined_block.sh new file mode 100755 index 0000000..b26e6f3 --- /dev/null +++ b/api/tests/latest_known_mined_block.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# +printf "TEST\t/slatest\n" +printf "\t01:\tendpoint\n" +A="$(curl http://127.0.0.1:8610/v0/slatest 2>/dev/null)" +B="$(bash /home/$USER/projects/arching-kaos-tools/find-latest-mined-block.sh)" +if [ "$A" == "$B" ] +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_chain.sh b/api/tests/node_local_chain.sh new file mode 100755 index 0000000..06b08cc --- /dev/null +++ b/api/tests/node_local_chain.sh @@ -0,0 +1,12 @@ +#!/bin/bash +printf "\nTEST /zchain\n" +printf "\t01:\tComparing API with CLI response..." +API_RESPONSE="$(curl http://127.0.0.1:8610/v0/zchain 2>/dev/null | sha512sum - | awk '{print $1 }')" +CMD_RESPONSE="$(get-chain-min | sha512sum - | awk '{ print $1 }')" +printf "api: %s\nenter: %s\n" $API_RESPONSE $CMD_RESPONSE +if [ "$API_RESPONSE" == "$CMD_RESPONSE" ] +then + printf "\t\t\033[0;32mPASSED\033[0;0m\n" +else + printf "\t\t\033[0;31mFAILED\033[0;0m\n" +fi diff --git a/api/tests/node_local_zlatest.sh b/api/tests/node_local_zlatest.sh new file mode 100755 index 0000000..4f37280 --- /dev/null +++ b/api/tests/node_local_zlatest.sh @@ -0,0 +1,12 @@ +#!/bin/bash +API_RES="$(curl http://127.0.0.1:8610/v0/zlatest 2>/dev/null | sha512sum - | awk '{ printf $1 }')" +CMD_RES="$(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..." +if [ "$API_RES" == "$CMD_RES" ] +then + printf "\n\t\t\033[0;32mPASSED\033[0;0m" +else + printf "\n\t\t\033[0;31mFAILED\033[0;0m" +fi +printf "\n" diff --git a/api/tests/send_me_a_zblock.sh b/api/tests/send_me_a_zblock.sh new file mode 100755 index 0000000..7fd814e --- /dev/null +++ b/api/tests/send_me_a_zblock.sh @@ -0,0 +1,3 @@ +#!/bin/bash +printf "\n#TODO Send me a block /sblk endpoint\n" +# curl http://127.0.0.1:8610/v0/sblk diff --git a/api/tests/send_me_a_zchain_link.sh b/api/tests/send_me_a_zchain_link.sh new file mode 100755 index 0000000..9820c7b --- /dev/null +++ b/api/tests/send_me_a_zchain_link.sh @@ -0,0 +1,3 @@ +#!/bin/bash +printf "\n#TODO /szch endpoint\n" +# curl http://127.0.0.1:8610/v0/szch diff --git a/api/tests/show_mined_block.sh b/api/tests/show_mined_block.sh new file mode 100755 index 0000000..99d126c --- /dev/null +++ b/api/tests/show_mined_block.sh @@ -0,0 +1,3 @@ +#!/bin/bash +printf "\n#TODO /sblock endpoint\n" +# curl http://127.0.0.1:8610/v0/sblock diff --git a/api/tests/test_all_routes.sh b/api/tests/test_all_routes.sh new file mode 100755 index 0000000..4903ca9 --- /dev/null +++ b/api/tests/test_all_routes.sh @@ -0,0 +1,9 @@ +#!/bin/bash +bash node_local_chain.sh +bash node_local_zlatest.sh +bash gathered_zblocks.sh +bash gathered_zchain_zlatest_pairs.sh +bash latest_known_mined_block.sh +bash show_mined_block.sh +bash send_me_a_zchain_link.sh +bash send_me_a_zblock.sh |