From 0955a7d1cc876cca25efcca83b2d68d905329fac Mon Sep 17 00:00:00 2001 From: "shiqi.zheng@algorand.com" Date: Wed, 29 Sep 2021 19:26:46 -0400 Subject: [PATCH 1/2] lower acct bal so it receives no reward --- test/scripts/e2e_subs/app-assets.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/test/scripts/e2e_subs/app-assets.sh b/test/scripts/e2e_subs/app-assets.sh index 65fd5e9270..2e48acfe1d 100755 --- a/test/scripts/e2e_subs/app-assets.sh +++ b/test/scripts/e2e_subs/app-assets.sh @@ -26,15 +26,15 @@ ACCOUNT=$(${gcmd} account list|awk '{ print $3 }') # Create a smaller account so rewards won't change balances. SMALL=$(${gcmd} account new | awk '{ print $6 }') # Under one algo receives no rewards -${gcmd} clerk send -a 1000000 -f "$ACCOUNT" -t "$SMALL" +${gcmd} clerk send -a 999000 -f "$ACCOUNT" -t "$SMALL" function balance { acct=$1; shift goal account balance -a "$acct" | awk '{print $1}' } -[ "$(balance "$ACCOUNT")" = 999998999000 ] -[ "$(balance "$SMALL")" = 1000000 ] +[ "$(balance "$ACCOUNT")" = 999999000000 ] +[ "$(balance "$SMALL")" = 999000 ] function created_assets { acct=$1; @@ -62,7 +62,7 @@ function assets { } APPID=$(${gcmd} app create --creator "${SMALL}" --approval-prog=${TEAL}/assets-escrow.teal --global-byteslices 4 --global-ints 0 --local-byteslices 0 --local-ints 1 --clear-prog=${TEAL}/approve-all.teal | grep Created | awk '{ print $6 }') -[ "$(balance "$SMALL")" = 999000 ] # 1000 fee +[ "$(balance "$SMALL")" = 998000 ] # 1000 fee function appl { method=$1; shift @@ -81,7 +81,6 @@ function asset-id { } APPACCT=$(python -c "import algosdk.encoding as e; print(e.encode_address(e.checksum(b'appID'+($APPID).to_bytes(8, 'big'))))") -[ "$(balance "$SMALL")" = 999000 ] # 1000 fee function asset-create { amount=$1; shift @@ -116,15 +115,15 @@ function sign { TXID=$(${gcmd} app optin --app-id "$APPID" --from "${SMALL}" | app-txid) # Rest succeeds, no stray inner-txn array [ "$(rest "/v2/transactions/pending/$TXID" | jq '.["inner-txn"]')" == null ] -[ "$(balance "$SMALL")" = 998000 ] # 1000 fee +[ "$(balance "$SMALL")" = 997000 ] # 1000 fee ASSETID=$(asset-create 1000000 --name "e2e" --unitname "e" | asset-id) -[ "$(balance "$SMALL")" = 997000 ] # 1000 fee +[ "$(balance "$SMALL")" = 996000 ] # 1000 fee ${gcmd} clerk send -a 1000000 -f "$ACCOUNT" -t "$APPACCT" appl "optin():void" --foreign-asset="$ASSETID" --from="$SMALL" [ "$(balance "$APPACCT")" = 999000 ] # 1000 fee -[ "$(balance "$SMALL")" = 996000 ] +[ "$(balance "$SMALL")" = 995000 ] appl "deposit():void" -o "$T/deposit.tx" --from="$SMALL" asset-deposit 1000 $ASSETID -o "$T/axfer1.tx" @@ -136,7 +135,7 @@ ${gcmd} clerk rawsend -f "$T/group.stx" [ "$(asset_bal "$SMALL")" = 999000 ] # asset balance [ "$(asset_ids "$APPACCT")" = $ASSETID ] [ "$(asset_bal "$APPACCT")" = 1000 ] -[ "$(balance "$SMALL")" = 994000 ] # 2 fees +[ "$(balance "$SMALL")" = 993000 ] # 2 fees [ "$(balance "$APPACCT")" = 999000 ] # Withdraw 100 in app. Confirm that inner txn is visible to transaction API. @@ -151,12 +150,12 @@ rest "/v2/blocks/$ROUND" | jq .block.txns[0].dt.itx [ "$(asset_bal "$SMALL")" = 999100 ] # 100 asset withdrawn [ "$(asset_bal "$APPACCT")" = 900 ] # 100 asset withdrawn -[ "$(balance "$SMALL")" = 993000 ] # 1 fee +[ "$(balance "$SMALL")" = 992000 ] # 1 fee [ "$(balance "$APPACCT")" = 998000 ] # fee paid by app appl "withdraw(uint64):void" --app-arg="int:100" --foreign-asset="$ASSETID" --fee 2000 --from="$SMALL" [ "$(asset_bal "$SMALL")" = 999200 ] # 100 asset withdrawn -[ "$(balance "$SMALL")" = 991000 ] # 2000 fee +[ "$(balance "$SMALL")" = 990000 ] # 2000 fee [ "$(asset_bal "$APPACCT")" = 800 ] # 100 asset withdrawn [ "$(balance "$APPACCT")" = 998000 ] # fee credit used @@ -164,18 +163,18 @@ appl "withdraw(uint64):void" --app-arg="int:100" --foreign-asset="$ASSETID" --f appl "withdraw(uint64):void" --app-arg="int:1000" --foreign-asset="$ASSETID" --from="$SMALL" && exit 1 [ "$(asset_bal "$SMALL")" = 999200 ] # no change [ "$(asset_bal "$APPACCT")" = 800 ] # no change -[ "$(balance "$SMALL")" = 991000 ] +[ "$(balance "$SMALL")" = 990000 ] [ "$(balance "$APPACCT")" = 998000 ] # Show that it works AT exact asset balance appl "withdraw(uint64):void" --app-arg="int:800" --foreign-asset="$ASSETID" --from="$SMALL" [ "$(asset_bal "$SMALL")" = 1000000 ] [ "$(asset_bal "$APPACCT")" = 0 ] -[ "$(balance "$SMALL")" = 990000 ] +[ "$(balance "$SMALL")" = 989000 ] [ "$(balance "$APPACCT")" = 997000 ] USER=$(${gcmd} account new | awk '{ print $6 }') #new account -${gcmd} clerk send -a 1000000 -f "$ACCOUNT" -t "$USER" #fund account +${gcmd} clerk send -a 999000 -f "$ACCOUNT" -t "$USER" #fund account asset-optin -f "$USER" -t "$USER" --assetid "$ASSETID" #opt in to asset # SET $USER as clawback address ${gcmd} asset config --manager $SMALL --assetid $ASSETID --new-clawback $USER @@ -190,7 +189,7 @@ ${gcmd} clerk send --from "$USER" --to "$USER" -a 0 --rekey-to "$APPACCT" ${gcmd} asset send -f "$SMALL" -t "$USER" -a "1000" --assetid "$ASSETID" --clawback "$USER" && exit 1 USER2=$(${gcmd} account new | awk '{ print $6 }') #new account -${gcmd} clerk send -a 1000000 -f "$ACCOUNT" -t "$USER2" #fund account +${gcmd} clerk send -a 999000 -f "$ACCOUNT" -t "$USER2" #fund account asset-optin -f "$USER2" -t "$USER2" --assetid "$ASSETID" #opt in to asset # set $APPACCT as clawback address on asset ${gcmd} asset config --manager $SMALL --assetid $ASSETID --new-clawback $APPACCT From d6ce7bbfbd7b3af058006f5b4f68e0fe5773e306 Mon Sep 17 00:00:00 2001 From: "shiqi.zheng@algorand.com" Date: Thu, 30 Sep 2021 09:55:47 -0400 Subject: [PATCH 2/2] bug fix --- test/scripts/e2e_subs/app-assets.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/scripts/e2e_subs/app-assets.sh b/test/scripts/e2e_subs/app-assets.sh index 2e48acfe1d..8b1fa6f5da 100755 --- a/test/scripts/e2e_subs/app-assets.sh +++ b/test/scripts/e2e_subs/app-assets.sh @@ -120,9 +120,9 @@ TXID=$(${gcmd} app optin --app-id "$APPID" --from "${SMALL}" | app-txid) ASSETID=$(asset-create 1000000 --name "e2e" --unitname "e" | asset-id) [ "$(balance "$SMALL")" = 996000 ] # 1000 fee -${gcmd} clerk send -a 1000000 -f "$ACCOUNT" -t "$APPACCT" +${gcmd} clerk send -a 999000 -f "$ACCOUNT" -t "$APPACCT" appl "optin():void" --foreign-asset="$ASSETID" --from="$SMALL" -[ "$(balance "$APPACCT")" = 999000 ] # 1000 fee +[ "$(balance "$APPACCT")" = 998000 ] # 1000 fee [ "$(balance "$SMALL")" = 995000 ] appl "deposit():void" -o "$T/deposit.tx" --from="$SMALL" @@ -136,7 +136,7 @@ ${gcmd} clerk rawsend -f "$T/group.stx" [ "$(asset_ids "$APPACCT")" = $ASSETID ] [ "$(asset_bal "$APPACCT")" = 1000 ] [ "$(balance "$SMALL")" = 993000 ] # 2 fees -[ "$(balance "$APPACCT")" = 999000 ] +[ "$(balance "$APPACCT")" = 998000 ] # Withdraw 100 in app. Confirm that inner txn is visible to transaction API. TXID=$(appl "withdraw(uint64):void" --app-arg="int:100" --foreign-asset="$ASSETID" --from="$SMALL" | app-txid) @@ -151,27 +151,27 @@ rest "/v2/blocks/$ROUND" | jq .block.txns[0].dt.itx [ "$(asset_bal "$SMALL")" = 999100 ] # 100 asset withdrawn [ "$(asset_bal "$APPACCT")" = 900 ] # 100 asset withdrawn [ "$(balance "$SMALL")" = 992000 ] # 1 fee -[ "$(balance "$APPACCT")" = 998000 ] # fee paid by app +[ "$(balance "$APPACCT")" = 997000 ] # fee paid by app appl "withdraw(uint64):void" --app-arg="int:100" --foreign-asset="$ASSETID" --fee 2000 --from="$SMALL" [ "$(asset_bal "$SMALL")" = 999200 ] # 100 asset withdrawn [ "$(balance "$SMALL")" = 990000 ] # 2000 fee [ "$(asset_bal "$APPACCT")" = 800 ] # 100 asset withdrawn -[ "$(balance "$APPACCT")" = 998000 ] # fee credit used +[ "$(balance "$APPACCT")" = 997000 ] # fee credit used # Try to withdraw too much appl "withdraw(uint64):void" --app-arg="int:1000" --foreign-asset="$ASSETID" --from="$SMALL" && exit 1 [ "$(asset_bal "$SMALL")" = 999200 ] # no change [ "$(asset_bal "$APPACCT")" = 800 ] # no change [ "$(balance "$SMALL")" = 990000 ] -[ "$(balance "$APPACCT")" = 998000 ] +[ "$(balance "$APPACCT")" = 997000 ] # Show that it works AT exact asset balance appl "withdraw(uint64):void" --app-arg="int:800" --foreign-asset="$ASSETID" --from="$SMALL" [ "$(asset_bal "$SMALL")" = 1000000 ] [ "$(asset_bal "$APPACCT")" = 0 ] [ "$(balance "$SMALL")" = 989000 ] -[ "$(balance "$APPACCT")" = 997000 ] +[ "$(balance "$APPACCT")" = 996000 ] USER=$(${gcmd} account new | awk '{ print $6 }') #new account ${gcmd} clerk send -a 999000 -f "$ACCOUNT" -t "$USER" #fund account