0

I'm facing some issue with test cases, I wrote some simple function in my smart contract as following:

function Create ( 
    bytes32 _a,
    address _b,
    string _c,
    address[] _d,
    uint256[] _e,

) public pure returns(bool){
    return true;
}

And here is the test case:

describe("Unit Test For Create Method", () => {
    it("first test case", async () => {
        const estimateGas = await Instance.Create.estimateGas(a, b, c, d, e);
        console.log(estimateGas);            
    });
});

while running test case, it's giving an error Error: VM Exception while processing transaction: out of gas

If I remove any single parameter, it starts working.. so, I assume there is an issue with number of arguments..any help?

Edit: I have defined variable globally:

contract('Unit Test for smart contract', function(){
    let a = "XVXIJLO-9XNQ-ZQWF-OLAF-E14L09FHZALQ",
        b = web3.eth.accounts[1],
        c = "fileHash",
        d = ['s1','s2'],
        e = [0,1,2],
        Instance;

        // test case here
}
0

After digging deeply, I found the exact cause of that error.

I was passing 36 bytes to the _a variable, wheres actual _a defined with bytes32 datatype.

In order to solve this issue, modified id to 32 bytes.

Or

use web3 js:

id = web3.sha3("XVXIJLO-9XNQ-ZQWF-OLAF-E14L09FHZALQ");

Hope this will help to others!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.