-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: can't calculate gas when program start with label (#547)
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma version 5 | ||
// default clear program | ||
int 1 | ||
return |
26 changes: 26 additions & 0 deletions
26
packages/runtime/test/fixtures/basic-teal/assets/label-first-line.teal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma version 5 | ||
|
||
txn ApplicationID | ||
bz creation | ||
|
||
loop: | ||
load 0 | ||
int 10 | ||
< | ||
bz break | ||
|
||
load 0 | ||
int 1 | ||
+ | ||
store 0 | ||
|
||
b loop | ||
|
||
break: | ||
|
||
int 1 | ||
return | ||
|
||
creation: | ||
int 1 | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { types as rtypes } from '@algo-builder/runtime'; | ||
import { types } from "@algo-builder/web"; | ||
import { expect } from "chai"; | ||
|
||
import { AccountStore, Runtime } from "../../src/index"; | ||
import { AppDeploymentFlags } from "../../src/types"; | ||
import { useFixture } from "../helpers/integration"; | ||
|
||
describe("TEALv5: Pooled Opcode Cost calculation", function () { | ||
useFixture("basic-teal"); | ||
const john = new AccountStore(10e6); | ||
|
||
let runtime: Runtime; | ||
let approvalProgramFileName: string; | ||
let clearProgramFileName: string; | ||
let flags: AppDeploymentFlags; | ||
let appID: number; | ||
let appCallParam: types.AppCallsParam; | ||
this.beforeAll(async function () { | ||
runtime = new Runtime([john]); // setup test | ||
approvalProgramFileName = 'label-first-line.teal'; | ||
clearProgramFileName = 'clear.teal'; | ||
|
||
flags = { | ||
sender: john.account, | ||
globalBytes: 1, | ||
globalInts: 1, | ||
localBytes: 1, | ||
localInts: 1 | ||
}; | ||
|
||
appID = runtime.deployApp(approvalProgramFileName, clearProgramFileName, flags, {}).appID; | ||
|
||
appCallParam = { | ||
type: types.TransactionType.CallApp, | ||
sign: types.SignType.SecretKey, | ||
fromAccount: john.account, | ||
appID: appID, | ||
payFlags: { totalFee: 1000 } | ||
}; | ||
}); | ||
|
||
it("Gas should be number", function () { | ||
const receipt = runtime.executeTx(appCallParam) as rtypes.TxReceipt; | ||
expect(receipt.gas).to.equal(98); | ||
}); | ||
}); |