Skip to content

Commit

Permalink
Initialize past side effects with correct length during dryrun reques…
Browse files Browse the repository at this point in the history
…ts (algorand#2448)

This PR fixes a typo in the dryrun code that caused certain dryrun requests containing multiple transactions to fail.
  • Loading branch information
jdtzmn authored and algonathan committed Jul 8, 2021
1 parent b794e76 commit fa2be72
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion daemon/algod/api/server/v2/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func doDryrunRequest(dr *DryrunRequest, response *generated.DryrunResponse) {

response.Txns = make([]generated.DryrunTxnResult, len(dr.Txns))
for ti, stxn := range dr.Txns {
pse := logic.MakePastSideEffects(1)
pse := logic.MakePastSideEffects(len(dr.Txns))
ep := logic.EvalParams{
Txn: &stxn,
Proto: &proto,
Expand Down
48 changes: 48 additions & 0 deletions daemon/algod/api/server/v2/dryrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,54 @@ func TestDryrunLocalCheck(t *testing.T) {
doDryrunRequest(&dr, &response)
checkAppCallPass(t, &response)
}

func TestDryrunMultipleTxns(t *testing.T) {
t.Parallel()

var dr DryrunRequest
var response generated.DryrunResponse

dr.ProtocolVersion = string(dryrunProtoVersion)

txn := transactions.SignedTxn{
Txn: transactions.Transaction{
Type: protocol.ApplicationCallTx,
ApplicationCallTxnFields: transactions.ApplicationCallTxnFields{
ApplicationID: 1,
ApplicationArgs: [][]byte{
[]byte("write"),
},
},
},
}

dr.Txns = []transactions.SignedTxn{txn, txn}
gkv := generated.TealKeyValueStore{
generated.TealKeyValue{
Key: b64("foo"),
Value: generated.TealValue{Type: uint64(basics.TealBytesType), Bytes: b64("bar")},
},
}
dr.Apps = []generated.Application{
{
Id: 1,
Params: generated.ApplicationParams{
ApprovalProgram: globalTestProgram,
GlobalState: &gkv,
GlobalStateSchema: &generated.ApplicationStateSchema{
NumByteSlice: 10,
NumUint: 10,
},
},
},
}
doDryrunRequest(&dr, &response)
checkAppCallPass(t, &response)
if t.Failed() {
logResponse(t, &response)
}
}

func TestDryrunEncodeDecode(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit fa2be72

Please sign in to comment.