Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions test/scripts/e2e_subs/algod-v1-confirm-sunset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# The test confirms algod v1 REST API returns the expected post-sunset status code (410).

filename=$(basename "$0")
scriptname="${filename%.*}"
date "+${scriptname} start %Y%m%d_%H%M%S"

my_dir="$(dirname "$0")"
source "$my_dir/rest.sh" "$@"

# Function is inspired by prior tests defining similar functions.
function rest() {
local endpoint=$1
local method=$2
curl --include -X "$method" -q -s -H "Authorization: Bearer $PUB_TOKEN" "$NET$endpoint"
}

set -e
set -x
set -o pipefail

export SHELLOPTS

declare -a gets=(
"/v1/status"
"/v1/status/wait-for-block-after/1"
"/v1/account/1"
"/v1/account/1/transaction/1"
"/v1/transactions/params"
"/v1/account/1/transactions"
"/v1/block/1"
"/v1/ledger/supply"
"/v1/transactions/pending"
"/v1/transactions/pending/1"
"/v1/account/1/transactions/pending"
"/v1/asset/1"
"/v1/assets"
"/v1/transaction/1"
)

declare -a posts=(
"/v1/transactions"
)

for endpoint in "${gets[@]}"; do
response=$(rest "$endpoint" 'GET')
if [ "$(echo "$response" | grep -c 'HTTP/1.1 410 Gone')" -ne 1 ]; then
date "+${scriptname} status code != 410 for endpoint = $endpoint with response = $response"
exit 1
fi
done

for endpoint in "${posts[@]}"; do
response=$(rest "$endpoint" 'POST')
if [ "$(echo "$response" | grep -c 'HTTP/1.1 410 Gone')" -ne 1 ]; then
date "+${scriptname} status code != 410 for endpoint = $endpoint with response = $response"
exit 1
fi
done

date "+${scriptname} OK %Y%m%d_%H%M%S"