I am running tests of my !ink smart contracts using @727-ventures/typechain-polkadot
module.
But when I am running tests, sometimes getting OutOfGas Error.
The strange thing is that not all cases are failing.
I tried to put gasLimit
manually but didn't work.
Here is the code for calling smart contract.
const MAX_CALL_WEIGHT = new BN(5_000_000_000_000_000).isub(BN_ONE)
const PROOFSIZE = new BN(1_000_000_000)
const gasLimit = api?.registry.createType('WeightV2', {
refTime: MAX_CALL_WEIGHT,
proofSize: PROOFSIZE,
}) as WeightV2
const result = await contract.query.func(...args, { gasLimit })
const gasRequired = preview.gasRequired as WeightV2
const newGasLimit = api?.registry.createType('WeightV2', gasRequired) as WeightV2
const res = await contract.tx.func(...args, { gasLimit: newGasLimit })
This code is running well sometimes but getting error sometimes.