summaryrefslogtreecommitdiff
path: root/test/scripts/e2e_subs/e2e-app-abi-add.sh
blob: 60e1c1f3eb2cc9e236225d47968a24ea71e6859e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

date '+app-abi-add-test start %Y%m%d_%H%M%S'

set -e
set -x
set -o pipefail
export SHELLOPTS

WALLET=$1

# Directory of this bash program
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

gcmd="goal -w ${WALLET}"

GLOBAL_INTS=2
ACCOUNT=$(${gcmd} account list|awk '{ print $3 }')

printf '#pragma version 2\nint 1' > "${TEMPDIR}/simple.teal"
PROGRAM=($(${gcmd} clerk compile "${TEMPDIR}/simple.teal"))
APPID=$(${gcmd} app create --creator ${ACCOUNT} --approval-prog ${DIR}/tealprogs/app-abi-add-example.teal --clear-prog ${TEMPDIR}/simple.teal --global-byteslices 0 --global-ints ${GLOBAL_INTS} --local-byteslices 0 --local-ints 0 | grep Created | awk '{ print $6 }')

# Should succeed to opt in
${gcmd} app optin --app-id $APPID --from $ACCOUNT

# Call should now succeed
RES=$(${gcmd} app method --method "add(uint64,uint64)uint64" --arg 1 --arg 2 --app-id $APPID --from $ACCOUNT 2>&1 || true)
EXPECTED="method add(uint64,uint64)uint64 output: 3"
if [[ $RES != *"${EXPECTED}"* ]]; then
    date '+app-abi-add-test FAIL the application creation should not fail %Y%m%d_%H%M%S'
    false
fi

# Delete application should still succeed
${gcmd} app delete --app-id $APPID --from $ACCOUNT

# Clear should still succeed
${gcmd} app clear --app-id $APPID --from $ACCOUNT