aboutsummaryrefslogtreecommitdiff
path: root/api/tests
diff options
context:
space:
mode:
Diffstat (limited to 'api/tests')
-rw-r--r--api/tests/default_route.sh2
-rwxr-xr-xapi/tests/gathered_zblocks.sh23
-rwxr-xr-xapi/tests/gathered_zchain_zlatest_pairs.sh10
-rwxr-xr-xapi/tests/latest_known_mined_block.sh13
-rwxr-xr-xapi/tests/node_local_chain.sh12
-rwxr-xr-xapi/tests/node_local_zlatest.sh12
-rwxr-xr-xapi/tests/send_me_a_zblock.sh3
-rwxr-xr-xapi/tests/send_me_a_zchain_link.sh3
-rwxr-xr-xapi/tests/show_mined_block.sh3
-rwxr-xr-xapi/tests/test_all_routes.sh9
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