diff --git a/test/e2e-go/restAPI/restClient_test.go b/test/e2e-go/restAPI/restClient_test.go index 49d05ae4a3..e8aff991d5 100644 --- a/test/e2e-go/restAPI/restClient_test.go +++ b/test/e2e-go/restAPI/restClient_test.go @@ -30,7 +30,6 @@ import ( "time" "unicode" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" algodclient "github.com/algorand/go-algorand/daemon/algod/api/client" @@ -935,131 +934,6 @@ func TestClientPrioritizesPendingTransactions(t *testing.T) { a.True(statusResponse.TruncatedTxns.Transactions[0].TxID == txHigh.ID().String()) } -func TestClientCanGetPendingTransactionInfo(t *testing.T) { - partitiontest.PartitionTest(t) - defer fixtures.ShutdownSynchronizedTest(t) - - a := require.New(fixtures.SynchronizedTest(t)) - var localFixture fixtures.RestClientFixture - localFixture.Setup(t, filepath.Join("nettemplates", "TwoNodes50EachFuture.json")) - defer localFixture.Shutdown() - - testClient := localFixture.LibGoalClient - - testClient.WaitForRound(1) - - testClient.SetAPIVersionAffinity(algodclient.APIVersionV2, kmdclient.APIVersionV1) - - wh, err := testClient.GetUnencryptedWalletHandle() - a.NoError(err) - addresses, err := testClient.ListAddresses(wh) - a.NoError(err) - _, someAddress := getMaxBalAddr(t, testClient, addresses) - if someAddress == "" { - t.Error("no addr with funds") - } - a.NoError(err) - addr, err := basics.UnmarshalChecksumAddress(someAddress) - - params, err := testClient.SuggestedParams() - a.NoError(err) - - firstRound := basics.Round(params.LastRound + 1) - lastRound := basics.Round(params.LastRound + 1000) - var gh crypto.Digest - copy(gh[:], params.GenesisHash) - - prog := `#pragma version 5 -byte "A" -loop: -int 0 -dup2 -getbyte -int 1 -+ -dup -int 97 //ascii code of last char -<= -bz end -setbyte -dup -log -b loop -end: -int 1 -return -` - ops, err := logic.AssembleString(prog) - approv := ops.Program - ops, err = logic.AssembleString("#pragma version 5 \nint 1") - clst := ops.Program - - gl := basics.StateSchema{ - NumByteSlice: 1, - } - lc := basics.StateSchema{ - NumByteSlice: 1, - } - minTxnFee, _, err := localFixture.CurrentMinFeeAndBalance() - - tx, err := testClient.MakeUnsignedApplicationCallTx(0, nil, addresses, nil, nil, transactions.NoOpOC, approv, clst, gl, lc, 0) - tx.Sender = addr - tx.Fee = basics.MicroAlgos{Raw: minTxnFee} - tx.FirstValid = firstRound - tx.LastValid = lastRound - tx.GenesisHash = gh - - txid, err := testClient.SignAndBroadcastTransaction(wh, nil, tx) - a.NoError(err) - _, err = waitForTransaction(t, testClient, someAddress, txid, 60*time.Second) - a.NoError(err) - txn, err := testClient.PendingTransactionInformationV2(txid) - a.NoError(err) - a.NotNil(txn.Logs) - a.Equal(32, len(*txn.Logs)) - for i, l := range *txn.Logs { - assert.Equal(t, []byte(string(rune('B'+i))), l) - } - - //check non-create app call - wh, err = testClient.GetUnencryptedWalletHandle() - a.NoError(err) - addresses, err = testClient.ListAddresses(wh) - a.NoError(err) - _, someAddress = getMaxBalAddr(t, testClient, addresses) - if someAddress == "" { - t.Error("no addr with funds") - } - a.NoError(err) - addr, err = basics.UnmarshalChecksumAddress(someAddress) - - params, err = testClient.SuggestedParams() - a.NoError(err) - - firstRound = basics.Round(params.LastRound + 1) - lastRound = basics.Round(params.LastRound + 1000) - - tx, err = testClient.MakeUnsignedAppNoOpTx(*txn.ApplicationIndex, nil, addresses, nil, nil) - tx.Sender = addr - tx.Fee = basics.MicroAlgos{Raw: minTxnFee} - tx.FirstValid = firstRound - tx.LastValid = lastRound - tx.GenesisHash = gh - - txid, err = testClient.SignAndBroadcastTransaction(wh, nil, tx) - a.NoError(err) - _, err = waitForTransaction(t, testClient, someAddress, txid, 60*time.Second) - a.NoError(err) - txn, err = testClient.PendingTransactionInformationV2(txid) - a.NoError(err) - a.NotNil(txn.Logs) - a.Equal(32, len(*txn.Logs)) - for i, l := range *txn.Logs { - assert.Equal(t, []byte(string(rune('B'+i))), l) - } - -} - func TestPendingTransactionInfoInnerTxnAssetCreate(t *testing.T) { partitiontest.PartitionTest(t) diff --git a/test/scripts/e2e_subs/e2e-logs.sh b/test/scripts/e2e_subs/e2e-logs.sh new file mode 100755 index 0000000000..7d40a62e1f --- /dev/null +++ b/test/scripts/e2e_subs/e2e-logs.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +filename=$(basename "$0") +scriptname="${filename%.*}" +date "+${scriptname} start %Y%m%d_%H%M%S" + + +my_dir="$(dirname "$0")" +source "$my_dir/rest.sh" "$@" +function rest() { + curl -q -s -H "Authorization: Bearer $PUB_TOKEN" "$NET$1" +} + +function app_txid { + # When app (call or optin) submits, this is how the txid is + # printed. + grep -o -E 'txid [A-Z0-9]{52}' | cut -c 6- | head -1 +} + +set -e +set -x +set -o pipefail +export SHELLOPTS + +WALLET=$1 + +TEAL=test/scripts/e2e_subs/tealprogs + +gcmd="goal -w ${WALLET}" + +ACCOUNT=$(${gcmd} account list|awk '{ print $3 }') +EXP=(B C D E F G H I J K L M N O P Q R S T U V W X Y Z \[ \\ \] ^ _ \` a b ) + +# app create +TXID=$(${gcmd} app create --creator "${ACCOUNT}" --approval-prog=${TEAL}/logs.teal --global-byteslices 4 --global-ints 0 --local-byteslices 0 --local-ints 1 --clear-prog=${TEAL}/approve-all.teal | app_txid) +response=$(rest "/v2/transactions/pending/$TXID") +# log len +[ "$(echo "$response" | jq '.logs | length')" = 32 ] +# log content +i=0 +for log in $(echo "$response" | jq -r '.logs | .[]') + do + c=`echo -n "${log}" | base64 --decode` + [ "$c" = "${EXP[i]}" ] + i=$((i+1)) + done + +# app call +APPID=$(echo "$response" | jq '.["application-index"]') +TXID=$(${gcmd} app call --app-id "${APPID}" --from "$ACCOUNT" | app_txid) +response=$(rest "/v2/transactions/pending/$TXID") +# log len +[ "$(echo "$response" | jq '.logs | length')" = 32 ] +# log content +i=0 +for log in $(echo "$response" | jq -r '.logs | .[]') + do + c=`echo -n "${log}" | base64 --decode` + [ "$c" = "${EXP[i]}" ] + i=$((i+1)) + done + +date "+${scriptname} OK %Y%m%d_%H%M%S" \ No newline at end of file diff --git a/test/scripts/e2e_subs/tealprogs/logs.teal b/test/scripts/e2e_subs/tealprogs/logs.teal new file mode 100644 index 0000000000..ab835003c2 --- /dev/null +++ b/test/scripts/e2e_subs/tealprogs/logs.teal @@ -0,0 +1,19 @@ +#pragma version 5 +byte "A" +loop: +int 0 +dup2 +getbyte +int 1 ++ +dup +int 97 //ascii code of last char +<= +bz end +setbyte +dup +log +b loop +end: +int 1 +return \ No newline at end of file