Skip to content
Merged
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
32 changes: 6 additions & 26 deletions test/scripts/e2e_subs/rest-participation-key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,28 @@ date "+$0 start %Y%m%d_%H%M%S"
# Use admin token for both get and post
export USE_ADMIN=true

pushd "${TEMPDIR}" || exit
pushd "${TEMPDIR}" || exit 1

FIRST_ROUND=0
# A really large (but arbitrary) last valid round
LAST_ROUND=1200000
LAST_ROUND=120

NAME_OF_TEMP_PARTKEY="tmp.${FIRST_ROUND}.${LAST_ROUND}.partkey"

algokey part generate --first ${FIRST_ROUND} --last ${LAST_ROUND} --keyfile ${NAME_OF_TEMP_PARTKEY} --parent ${ACCOUNT}

popd || exit
popd || exit 1

call_and_verify "Get List of Keys" "/v2/participation" 200 'address'

# Find out how many keys there are installed so far
NUM_IDS_1=$(echo "$RES" | python3 -c 'import json,sys;o=json.load(sys.stdin);print(len(o))')
call_and_verify "Get List of Keys" "/v2/participation" 200 'address' 'effective-first-valid'

RES=""
call_post_and_verify "Install a basic participation key" "/v2/participation" 200 ${NAME_OF_TEMP_PARTKEY} 'partId'

# Get the returned participation id from the RESULT (aka $RES) variable
INSTALLED_ID=$(echo "$RES" | python3 -c 'import json,sys;o=json.load(sys.stdin);print(o["partId"])')

# Should contain the installed id
call_and_verify "Get List of Keys" "/v2/participation" 200 'address' "${INSTALLED_ID}"

# Get list of keys
NUM_IDS_2=$(echo "$RES" | python3 -c 'import json,sys;o=json.load(sys.stdin);print(len(o))')

if [[ $((NUM_IDS_1 + 1)) -ne $NUM_IDS_2 ]]; then
printf "\n\nFailed test. New number of IDs (%s) is not one more than old ID count(%s)\n\n" "${NUM_IDS_2}" "${NUM_IDS_1}"
exit 1
fi
call_and_verify "Get List of Keys" "/v2/participation" 200 'address' "${INSTALLED_ID}" 'address' 'effective-first-valid'

call_and_verify "Get a specific ID" "/v2/participation/${INSTALLED_ID}" 200 "${INSTALLED_ID}"

Expand All @@ -49,13 +39,3 @@ call_delete_and_verify "Delete the specific ID" "/v2/participation/${INSTALLED_I

# Verify that it got called previously and now returns an error message saying that no key was found
call_delete_and_verify "Delete the specific ID" "/v2/participation/${INSTALLED_ID}" 404 true 'participation id not found'

# Get list of keys
NUM_IDS_3=$(echo "$RES" | python3 -c 'import json,sys;o=json.load(sys.stdin);print(len(o))')

if [[ "$NUM_IDS_3" -ne "$NUM_IDS_1" ]]; then
printf "\n\nFailed test. New number of IDs (%s) is not equal to original ID count (%s)\n\n" "${NUM_IDS_3}" "${NUM_IDS_1}"
exit 1
fi