I'm writing foundry tests for a function which batch mints erc1155 tokens for the users, but I'm getting a panic revert.
The function I'm testing:
function mintBatch(
address to_,
uint256[] calldata tokenIds_,
uint256[] calldata amounts_,
bytes calldata data_
) external payable {
for (uint256 i = 0; i < tokenIds_.length; i++) {
Work storage work = works[tokenIds_[i]];
FEE_MANAGER.collectMintFee{value: msg.value}(
this, tokenIds_[i], amounts_[i], msg.sender, address(0), work.strategy
);
}
_batchMint(to_, tokenIds_, amounts_, data_);
}
The foundry test I wrote:
function test_batchMint() public {
uint[] memory tokenIds = new uint[](2);
tokenIds[1] = 1;
tokenIds[2] = 2;
uint[] memory tokenAmts = new uint[](2);
tokenAmts[1] = 1;
tokenAmts[2] = 1;
edition.mintBatch{value: 0.0106 ether}(address(1), tokenIds, tokenAmts, new bytes(0));
assertEq(edition.totalSupply(1), 1);
assertEq(edition.totalSupply(2), 1);
}
The error I'm getting, which I run forge test --mt test_batchMint
:
Failing tests:
Encountered 1 failing test in test/editions/Edition.t.sol:EditionTest
[FAIL. Reason: panic: array out-of-bounds access (0x32)] test_batchMint() (gas: 424)
Encountered a total of 1 failing tests, 0 tests succeeded
Pls help me, I tried finding a solution but got none, pls guide me about what's wrong I'm doing, Is I am inputting arrays correctly? Thanks!