I noticed that when I use the deal()
function to mint some tokens to an address for testing an ERC20 contract the forge test command gives me the MemoryLimitOOG
error, but suppose I use a mint
function implemented in the ERC20 contract itself to mint the tokens then forge test works fine.
This gives me the mentioned error while running forge test
import {Test, console2, StdStyle} from "forge-std/Test.sol";
import {ERC20} from "../src/ERC20.sol";
contract BaseSetup is ERC20, Test {
address internal alice;
address internal bob;
constructor() ERC20("Name", "SYM", 18) {}
function setUp() public virtual {
alice = makeAddr("alice");
bob = makeAddr("bob");
console2.log(StdStyle.blue("When Alice has 300 Tokens"));
deal(address(this), alice, 300e18); //using deal function
}
}
//Test Contracts here
Using deal() function
And this runs perfectly while running forge test
import {Test, console2, StdStyle} from "forge-std/Test.sol";
import {ERC20} from "../src/ERC20.sol";
contract BaseSetup is ERC20, Test {
address internal alice;
address internal bob;
constructor() ERC20("Name", "SYM", 18) {}
function setUp() public virtual {
alice = makeAddr("alice");
bob = makeAddr("bob");
console2.log(StdStyle.blue("When Alice has 300 Tokens"));
_mint(alice, 300e18); //_mint is an internal mint function implemented in the ERC20 contract.
}
}
//Test Contracts here
I’m wondering what could be the possible issue here. And how is it possible to resolve this?
I tried searching about this issue on the internet to no avail. I updated foundry to the latest version, cleared cache but nothing solves the issue.
Arish Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.