Skip to content

Commit

Permalink
tealdbg: use associated group index instead of global (algorand#3111)
Browse files Browse the repository at this point in the history
setting group index to be the one associated with the run
  • Loading branch information
barnjamin authored Oct 21, 2021
1 parent c2054e5 commit 38b08a0
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/tealdbg/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func (r *LocalRunner) RunAll() error {
ep := logic.EvalParams{
Proto: &r.proto,
Debugger: r.debugger,
Txn: &r.txnGroup[groupIndex],
Txn: &r.txnGroup[run.groupIndex],
TxnGroup: r.txnGroup,
GroupIndex: run.groupIndex,
PastSideEffects: run.pastSideEffects,
Expand Down Expand Up @@ -588,7 +588,7 @@ func (r *LocalRunner) Run() (bool, error) {
}
ep := logic.EvalParams{
Proto: &r.proto,
Txn: &r.txnGroup[groupIndex],
Txn: &r.txnGroup[run.groupIndex],
TxnGroup: r.txnGroup,
GroupIndex: run.groupIndex,
PastSideEffects: run.pastSideEffects,
Expand Down
100 changes: 100 additions & 0 deletions cmd/tealdbg/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1350,3 +1350,103 @@ byte 0x5ce9454909639d2d17a3f753ce7d93fa0b9ab12e // addr
})
}
}

func TestGroupTxnIdx(t *testing.T) {

partitiontest.PartitionTest(t)
a := require.New(t)

ddrBlob := `{
"accounts": [
{
"address": "FPVVJ7N42QRVP2OWBGZ3XPTQAZFQNBYHJGZ2CJFOATAQNWFA5NWB4MPWBQ",
"amount": 3999999999497000,
"amount-without-pending-rewards": 3999999999497000,
"created-apps": [
{
"id": 1,
"params": {
"approval-program": "BSABATEQIhJAABExEIEGEkAAByJAAAEAIkMiQ4EAQw==",
"clear-state-program": "BYEBQw==",
"creator": "FPVVJ7N42QRVP2OWBGZ3XPTQAZFQNBYHJGZ2CJFOATAQNWFA5NWB4MPWBQ"
}
}
],
"pending-rewards": 0,
"rewards": 0,
"round": 2,
"status": "Online"
},
{
"address": "WCS6TVPJRBSARHLN2326LRU5BYVJZUKI2VJ53CAWKYYHDE455ZGKANWMGM",
"amount": 500000,
"amount-without-pending-rewards": 500000,
"pending-rewards": 0,
"rewards": 0,
"round": 2,
"status": "Offline"
}
],
"apps": [
{
"id": 1,
"params": {
"approval-program": "BSABATEQIhJAABExEIEGEkAAByJAAAEAIkMiQ4EAQw==",
"clear-state-program": "BYEBQw==",
"creator": "FPVVJ7N42QRVP2OWBGZ3XPTQAZFQNBYHJGZ2CJFOATAQNWFA5NWB4MPWBQ"
}
}
],
"latest-timestamp": 1634765269,
"protocol-version": "future",
"round": 2,
"sources": null,
"txns": [
{
"sig": "8Z/ECart3vFBSKp5sFuNRN4coliea4TE+xttZNn9E15DJ8GZ++kgtZKhG4Tiopv7r61Lqh8VBuyuTf9AC3uQBQ==",
"txn": {
"amt": 5000,
"fee": 1000,
"fv": 3,
"gen": "sandnet-v1",
"gh": "pjM5GFR9MpNkWIibcfqtu/a2OIZTBy/mSQc++sF1r0Q=",
"grp": "2ca4sSb5aGab0k065qIT3J3AcB5YWYezrRh6bLB0ve8=",
"lv": 1003,
"note": "V+GSPgDmLQo=",
"rcv": "WCS6TVPJRBSARHLN2326LRU5BYVJZUKI2VJ53CAWKYYHDE455ZGKANWMGM",
"snd": "FPVVJ7N42QRVP2OWBGZ3XPTQAZFQNBYHJGZ2CJFOATAQNWFA5NWB4MPWBQ",
"type": "pay"
}
},
{
"sig": "4/gj+6rllN/Uc55kAJ0BOKTzoUJKJ7gExE3vp7cr5vC9XVStx0QNZq1DFXLhpTZnTQAl3zOrGzIxfS5HOpSyCg==",
"txn": {
"apid": 1,
"fee": 1000,
"fv": 3,
"gh": "pjM5GFR9MpNkWIibcfqtu/a2OIZTBy/mSQc++sF1r0Q=",
"grp": "2ca4sSb5aGab0k065qIT3J3AcB5YWYezrRh6bLB0ve8=",
"lv": 1003,
"note": "+fl8jkXqyFc=",
"snd": "FPVVJ7N42QRVP2OWBGZ3XPTQAZFQNBYHJGZ2CJFOATAQNWFA5NWB4MPWBQ",
"type": "appl"
}
}
]
}`

ds := DebugParams{
Proto: string(protocol.ConsensusCurrentVersion),
DdrBlob: []byte(ddrBlob),
GroupIndex: 0,
RunMode: "application",
}

local := MakeLocalRunner(nil)
err := local.Setup(&ds)
a.NoError(err)

pass, err := local.Run()
a.NoError(err)
a.True(pass)
}
2 changes: 1 addition & 1 deletion cmd/tealdbg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func debugLocal(args []string) {
if len(txnFile) > 0 {
txnBlob, err = ioutil.ReadFile(txnFile)
if err != nil {
log.Fatalf("Error txn reading %s: %s", balanceFile, err)
log.Fatalf("Error txn reading %s: %s", txnFile, err)
}
}

Expand Down

0 comments on commit 38b08a0

Please sign in to comment.