Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion test/scripts/e2e_subs/teal-app-params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ gcmd="goal -w ${WALLET}"

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

APPID=$(${gcmd} app create --creator "$ACCOUNT" --approval-prog=${TEAL}/app-params.teal --clear-prog=${TEAL}/approve-all.teal --global-byteslices 1 --global-ints 2 --local-byteslices 3 --local-ints 4 --extra-pages 2 --app-arg "addr:$ACCOUNT" | grep Created | awk '{ print $6 }')
APPID=$(${gcmd} app create --creator "$ACCOUNT" --approval-prog=${TEAL}/app-params.teal --clear-prog=${TEAL}/approve-all.teal --global-byteslices 1 --global-ints 2 --local-byteslices 3 --local-ints 4 --extra-pages 2 --app-arg "addr:$ACCOUNT" | grep Created | awk '{ print $6 }')

ACCOUNTB=$(${gcmd} account new|awk '{ print $6 }')
${gcmd} clerk send -f "$ACCOUNT" -t "$ACCOUNTB" -a 1000000

# Now call from a different account
${gcmd} app call --app-id="$APPID" --from="$ACCOUNTB" --app-arg "addr:$ACCOUNT"

# The below checks use quine.teal to test "app_params_get AppApprovalProgram"

# Verify "app_params_get AppApprovalProgram" works on create
APPID_2=$(${gcmd} app create --creator "$ACCOUNTB" --approval-prog=${TEAL}/quine.teal --clear-prog=${TEAL}/approve-all.teal --global-byteslices 0 --global-ints 0 --local-byteslices 0 --local-ints 0 --extra-pages 0 | grep Created | awk '{ print $6 }')

# Verify "app_params_get AppApprovalProgram" works on regular app call
${gcmd} app call --app-id="$APPID_2" --from="$ACCOUNTB"

# Verify "app_params_get AppApprovalProgram" works on update
${gcmd} app update --app-id="$APPID_2" --from="$ACCOUNTB" --approval-prog=${TEAL}/approve-all.teal --clear-prog=${TEAL}/approve-all.teal

date "+${scriptname} OK %Y%m%d_%H%M%S"
22 changes: 22 additions & 0 deletions test/scripts/e2e_subs/tealprogs/quine.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma version 5
// To modify the program:
// 1. Replace the first line with `pushbytes ""`.
// 2. Compile the program.
// 3. Replace the first line with `pushbytes <compiled bytecode>`
// 4. Update the varuint length of the new bytecode (line 11)
// 5. The quine is complete. Compile again.
pushbytes 0x0580004957000280011a504f0149570300505081007200441243
dup
extract 0 2
pushbytes 0x1a // the varuint length of 0x0580...
concat
uncover 1
dup
extract 3 0 // the range here must be updated if the varuint length is longer than 1 byte
concat
concat // after this line the whole program is on the stack
pushint 0
app_params_get AppApprovalProgram
assert
==
return