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

The substring3 opcode got error when run with runtime env. #502

Closed
vuvoth opened this issue Oct 29, 2021 · 1 comment
Closed

The substring3 opcode got error when run with runtime env. #502

vuvoth opened this issue Oct 29, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@vuvoth
Copy link
Contributor

vuvoth commented Oct 29, 2021

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

  1. 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
  1. 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! ❤️

@vuvoth vuvoth added the bug Something isn't working label Oct 29, 2021
@vuvoth vuvoth changed the title Substring3 error when run with runtime The substring3 opcode got error when run with runtime env. Oct 29, 2021
@vuvoth
Copy link
Contributor Author

vuvoth commented Oct 29, 2021

I created pull request #505 to fix this bug. Please check it. Thanks! ❤️

@vuvoth vuvoth closed this as completed Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant