diff options
author | Pavel Zbitskiy <65323360+algorandskiy@users.noreply.github.com> | 2022-02-21 20:10:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 20:10:40 -0500 |
commit | bc5f22c50e476248159929766aebd835e31ea8d2 (patch) | |
tree | e79f314dcae210f9a95c674fba581e7a0b8208d7 | |
parent | a6f1b9e8eb73f058e1ec08b699b8a542070674b9 (diff) |
dryrun: add gloads test (#3664)
-rw-r--r-- | daemon/algod/api/server/v2/dryrun_test.go | 82 |
1 files changed, 79 insertions, 3 deletions
diff --git a/daemon/algod/api/server/v2/dryrun_test.go b/daemon/algod/api/server/v2/dryrun_test.go index f5c850e31..0ca7d882f 100644 --- a/daemon/algod/api/server/v2/dryrun_test.go +++ b/daemon/algod/api/server/v2/dryrun_test.go @@ -382,9 +382,14 @@ func checkAppCallPass(t *testing.T, response *generated.DryrunResponse) { } else if response.Txns[0].AppCallMessages == nil || len(*response.Txns[0].AppCallMessages) < 1 { t.Error("no response app msg") } else { - messages := *response.Txns[0].AppCallMessages - assert.GreaterOrEqual(t, len(messages), 1) - assert.Equal(t, "PASS", messages[len(messages)-1]) + assert.NotNil(t, response.Txns[0].AppCallMessages) + for idx := range response.Txns { + if response.Txns[idx].AppCallMessages != nil { + messages := *response.Txns[idx].AppCallMessages + assert.GreaterOrEqual(t, len(messages), 1) + assert.Equal(t, "PASS", messages[len(messages)-1]) + } + } } } @@ -1522,3 +1527,74 @@ int 1 logResponse(t, &response) } } + +func TestDryrunScratchSpace(t *testing.T) { + partitiontest.PartitionTest(t) + a := require.New(t) + + approvalOps, err := logic.AssembleString(` +#pragma version 5 +txn GroupIndex +int 3 +== +bnz checkgload +txn GroupIndex +store 254 +b exit +checkgload: +int 0 +gloads 254 +int 0 +== +int 1 +gloads 254 +int 1 +== +&& +int 2 +gloads 254 +int 2 +== +&& +assert +exit: +int 1`) + require.NoError(t, err) + + ops, err := logic.AssembleString("int 1") + clst := ops.Program + require.NoError(t, err) + + sender, err := basics.UnmarshalChecksumAddress("47YPQTIGQEO7T4Y4RWDYWEKV6RTR2UNBQXBABEEGM72ESWDQNCQ52OPASU") + a.NoError(err) + + txns := make([]transactions.SignedTxn, 0, 4) + apps := make([]generated.Application, 0, 4) + for appIdx := basics.AppIndex(1); appIdx <= basics.AppIndex(4); appIdx++ { + txns = append(txns, txntest.Txn{ + Type: protocol.ApplicationCallTx, + Sender: sender, + ApplicationID: appIdx}.SignedTxn()) + apps = append(apps, generated.Application{ + Id: uint64(appIdx), + Params: generated.ApplicationParams{ + ApprovalProgram: approvalOps.Program, + ClearStateProgram: clst, + }, + }) + } + dr := DryrunRequest{ + ProtocolVersion: string(dryrunProtoVersion), + Txns: txns, + Apps: apps, + Accounts: []generated.Account{ + {Address: sender.String(), Status: "Offline", Amount: 100_000_000}, // sender + }, + } + var response generated.DryrunResponse + doDryrunRequest(&dr, &response) + checkAppCallPass(t, &response) + if t.Failed() { + logResponse(t, &response) + } +} |