The substring3 opcode got error when run with `runtime` env.
Closed this issue · 1 comments
vuvoth commented
Describe the bug
Got error when using substring3
opcode. But work well with the Algorand goal
command line.
Expected Behavior
Run substring3 successful
Current Behavior
Return error when running substring3
Error
Error: RUNTIME_ERR1003: Type of data is incorrect. Expected byte[] but got bigint at line 14
Possible Solution
Steps to Reproduce
- TEAL contract
This contract uses teal version 5.
Filename: string.teal.
#pragma version 5
int 0
txn ApplicationID
==
bnz on_creation
byte "result"
byte "this_is_not_bug"
int 0
int 1
substring3
app_global_put
int 1
return
on_creation:
int 1
return
- Test file
const { getProgram } = require('@algo-builder/algob');
const { Runtime, AccountStore } = require('@algo-builder/runtime');
const { types } = require('@algo-builder/web');
const { assert } = require('chai');
const { convert } = require('@algo-builder/algob');
const minBalance = BigInt(1e6);
const masterBalance = BigInt(10e6);
const amount = BigInt(1e6);
describe("Test String", function () {
let testAccount;
let runtime;
let executorProgram;
let appID;
this.beforeEach(async () => {
// prepare smart contract
testAccount = new AccountStore(masterBalance);
runtime = new Runtime([testAccount]);
executorProgram = getProgram("string.teal");
// deploy application
appID = runtime.addApp({
sender: testAccount.account,
globalBytes: 32,
globalInts: 32,
localBytes: 8,
localInts: 8
}, {}, executorProgram);
});
function syncAccounts() {
testAccount = runtime.getAccount(testAccount.address);
}
it("Test", () => {
const fee = 4000;
const txnParams = {
type: types.TransactionType.CallApp,
sign: types.SignType.SecretKey,
fromAccount: testAccount.account,
appID: appID,
payFlags: { totalFee: fee }
};
runtime.executeTx(txnParams);
const result = runtime.getGlobalState(txnParams.appID, 'result');
console.log(result);
})
})
Environment
- OS: MacOS
- Node.js version: v14
- algob version: 2.1.0
Thanks for your support! ❤️