aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-03-31 21:34:47 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-03-31 21:34:47 +0300
commit52e61043bcb716af42f9fd167aa2bb280bde5b5b (patch)
tree5f8f2708bd6ac8da77d12872036d056ea80369fa /api
parent3023b8396d3656887a95f11e45da2e79406d64d1 (diff)
downloadarching-kaos-tools-52e61043bcb716af42f9fd167aa2bb280bde5b5b.tar.gz
arching-kaos-tools-52e61043bcb716af42f9fd167aa2bb280bde5b5b.tar.bz2
arching-kaos-tools-52e61043bcb716af42f9fd167aa2bb280bde5b5b.zip
Updated test scripts
Diffstat (limited to 'api')
-rwxr-xr-x[-rw-r--r--]api/tests/default_route.sh11
-rwxr-xr-xapi/tests/gathered_zblocks.sh14
-rwxr-xr-xapi/tests/gathered_zchain_zlatest_pairs.sh5
-rwxr-xr-xapi/tests/latest_known_mined_block.sh6
-rwxr-xr-xapi/tests/node_local_chain.sh14
-rwxr-xr-xapi/tests/node_local_zlatest.sh8
-rwxr-xr-xapi/tests/send_me_a_zblock.sh4
-rwxr-xr-xapi/tests/send_me_a_zchain_link.sh33
-rwxr-xr-xapi/tests/show_mined_block.sh4
-rwxr-xr-xapi/tests/test_all_routes.sh2
10 files changed, 79 insertions, 22 deletions
diff --git a/api/tests/default_route.sh b/api/tests/default_route.sh
index 8e73ae6..1505b68 100644..100755
--- a/api/tests/default_route.sh
+++ b/api/tests/default_route.sh
@@ -1,2 +1,11 @@
#!/bin/bash
-curl http://127.0.0.1:8610
+PROGRAM="$(basename $0)"
+printf '[%s]\n' "$PROGRAM"
+curl http://127.0.0.1:8610 2>/dev/null | jq > /dev/null
+if [ "$?" == "0" ]
+then
+ printf "\t\t\033[0;32mPASSED\033[0;0m"
+else
+ printf "\t\033[0;31mFAILED\033[0;0m"
+fi
+printf "\n"
diff --git a/api/tests/gathered_zblocks.sh b/api/tests/gathered_zblocks.sh
index cbe2c9a..35920e0 100755
--- a/api/tests/gathered_zblocks.sh
+++ b/api/tests/gathered_zblocks.sh
@@ -1,23 +1,25 @@
#!/bin/bash
#
-printf "TEST /see\n"
-printf "\t01:\tOutput is JSON"
+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
if [ "$?" == "0" ]
then
- printf "\n\t\t\033[0;32mPASSED\033[0;0m"
+ printf "\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"
+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"
+ printf "\t\t\033[0;32mPASSED\033[0;0m"
else
- printf "\n\t\t\033[0;31mFAILED\033[0;0m"
+ printf "\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
index 466c669..d6c1274 100755
--- a/api/tests/gathered_zchain_zlatest_pairs.sh
+++ b/api/tests/gathered_zchain_zlatest_pairs.sh
@@ -1,6 +1,8 @@
#!/bin/bash
+PROGRAM="$(basename $0)"
+printf '[%s]\n' "$PROGRAM"
printf "TEST\t/seens\n"
-printf "\t01:\tendpoint returns JSON...\n"
+printf "\t01:\tendpoint returns JSON..."
curl http://127.0.0.1:8610/v0/seens 2>/dev/null | jq > /dev/null
if [ "$?" == "0" ]
then
@@ -8,3 +10,4 @@ then
else
printf '\t\t\033[0;31mFAILED\033[0;0m\n'
fi
+printf "\n"
diff --git a/api/tests/latest_known_mined_block.sh b/api/tests/latest_known_mined_block.sh
index 90c3feb..c4e40bb 100755
--- a/api/tests/latest_known_mined_block.sh
+++ b/api/tests/latest_known_mined_block.sh
@@ -1,9 +1,11 @@
#!/bin/bash
#
+PROGRAM="$(basename $0)"
+printf '[%s]\n' "$PROGRAM"
printf "TEST\t/slatest\n"
-printf "\t01:\tendpoint\n"
+printf "\t01:\tendpoint"
A="$(curl http://127.0.0.1:8610/v0/slatest 2>/dev/null)"
-B="$(ak-find-latest-mined-block)"
+B="$(ak-find-latest-mined-sblock)"
if [ "$A" == "$B" ]
then
printf '\t\t\033[0;32mPASSED\033[0;0m'
diff --git a/api/tests/node_local_chain.sh b/api/tests/node_local_chain.sh
index 06b08cc..843de35 100755
--- a/api/tests/node_local_chain.sh
+++ b/api/tests/node_local_chain.sh
@@ -1,12 +1,14 @@
#!/bin/bash
-printf "\nTEST /zchain\n"
+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 | sha512sum - | awk '{print $1 }')"
-CMD_RESPONSE="$(get-chain-min | sha512sum - | awk '{ print $1 }')"
-printf "api: %s\nenter: %s\n" $API_RESPONSE $CMD_RESPONSE
+API_RESPONSE="$(curl http://127.0.0.1:8610/v0/zchain 2>/dev/null | jq -c -M | sha512sum - | awk '{print $1 }')"
+CMD_RESPONSE="$(ak-get-chain-minified | jq -c -M | sha512sum - | awk '{ print $1 }')"
if [ "$API_RESPONSE" == "$CMD_RESPONSE" ]
then
- printf "\t\t\033[0;32mPASSED\033[0;0m\n"
+ printf "\t\t\033[0;32mPASSED\033[0;0m"
else
- printf "\t\t\033[0;31mFAILED\033[0;0m\n"
+ 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 4f37280..f562bc6 100755
--- a/api/tests/node_local_zlatest.sh
+++ b/api/tests/node_local_zlatest.sh
@@ -1,12 +1,14 @@
#!/bin/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 }')"
-CMD_RES="$(get-latest | sed -e 's/^/{"zlatest":"/; s/$/"}/' | sha512sum - | awk '{ printf $1 }')"
+CMD_RES="$(ak-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"
+ printf "\t\t\033[0;32mPASSED\033[0;0m"
else
- printf "\n\t\t\033[0;31mFAILED\033[0;0m"
+ printf "\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
index 7fd814e..b5f9d0d 100755
--- a/api/tests/send_me_a_zblock.sh
+++ b/api/tests/send_me_a_zblock.sh
@@ -1,3 +1,5 @@
#!/bin/bash
-printf "\n#TODO Send me a block /sblk endpoint\n"
+PROGRAM="$(basename $0)"
+printf '[%s]\n' "$PROGRAM"
+printf "#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
index 9820c7b..15bc2a0 100755
--- a/api/tests/send_me_a_zchain_link.sh
+++ b/api/tests/send_me_a_zchain_link.sh
@@ -1,3 +1,34 @@
#!/bin/bash
-printf "\n#TODO /szch endpoint\n"
+PROGRAM="$(basename $0)"
+printf '[%s]\n' "$PROGRAM"
+printf "TEST\t/szch\n"
# curl http://127.0.0.1:8610/v0/szch
+printf "\t01:\tendpoint with valid data"
+curl -POST http://localhost:8610/v0/szch --header 'Content-Type: application/json' --data-raw '{"zchain":"k51qzi5uqu5dgapvk7bhxmchuqya9immqdpbz0f1r91ckpdqzub63afn3d5apr"}' 2>/dev/null | jq -M -c > /dev/null
+if [ "$?" == "0" ]
+then
+ printf "\t\t\033[0;32mPASSED\033[0;0m"
+else
+ printf "\t\033[0;31mFAILED\033[0;0m"
+fi
+printf "\n"
+
+printf "\t02:\tendpoint with invalid data"
+curl -POST http://localhost:8610/v0/szch --header 'Content-Type: application/json' --data-raw '{"zchain":"k51qzi5uqu5dgapvk7bhxmchuqya9immqdpbz0f1r91ckpdqzub63afn3d5aar"}' 2>/dev/null | jq -M -c > /dev/null
+if [ "$?" == "0" ]
+then
+ printf "\t\t\033[0;32mPASSED\033[0;0m"
+else
+ printf "\t\033[0;31mFAILED\033[0;0m"
+fi
+printf "\n"
+
+printf "\t03:\tendpoint no data"
+curl -POST http://localhost:8610/v0/szch --header 'Content-Type: application/json' --data-raw '{"zchain":""}' 2>/dev/null | jq -M -c > /dev/null
+if [ "$?" == "0" ]
+then
+ printf "\t\t\033[0;32mPASSED\033[0;0m"
+else
+ printf "\t\033[0;31mFAILED\033[0;0m"
+fi
+printf "\n"
diff --git a/api/tests/show_mined_block.sh b/api/tests/show_mined_block.sh
index 99d126c..51847d7 100755
--- a/api/tests/show_mined_block.sh
+++ b/api/tests/show_mined_block.sh
@@ -1,3 +1,5 @@
#!/bin/bash
-printf "\n#TODO /sblock endpoint\n"
+PROGRAM="$(basename $0)"
+printf '[%s]\n' "$PROGRAM"
+printf "#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
index 4903ca9..9a56faa 100755
--- a/api/tests/test_all_routes.sh
+++ b/api/tests/test_all_routes.sh
@@ -1,4 +1,6 @@
#!/bin/bash
+PROGRAM="$(basename $0)"
+printf '[%s] Starting tests...\n' "$PROGRAM"
bash node_local_chain.sh
bash node_local_zlatest.sh
bash gathered_zblocks.sh