Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dryrun: add gloads test #3664

Merged
merged 1 commit into from
Feb 22, 2022
Merged
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
82 changes: 79 additions & 3 deletions daemon/algod/api/server/v2/dryrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
}
}
}

Expand Down Expand Up @@ -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)
}
}