Error in test: Number can only safely store up to 53 bits even with BN.js

The error occurs right before console.log(1.92) every time in tests on ganache, no matter if I use BN.js or web3.utils.toBN. I've tried looking into every answer but they just tell you basic stuff like not to use .toNumber() which I am not doing. This crashes both ganache-cli and the GUI regardless of which I use. Any ideas?

If I combine e.g. 5 mintings in 1, I just get it after a roughly equivalent number of calls.

        await waypoint.mint(investor, new BN("100000000000000000000"))
        await waypoint.mint(investor, new BN("100000000000000000000"))
        console.log(1.6)
        await waypoint.processMints(investor)
        console.log(1.7)
        result = await waypoint.totalSupply()
        assert.equal(result.toString(), tokens('2100'), 'total Supply correct after minting started3 ')
        
        result = await waypoint.balanceOf(investor)
        assert.equal(result.toString(),tokens('300'), 'investor WPNT wallet balance correct after minting3')
        
        time.setDate(time.getDate() + 1)
        console.log(1.8)
        await advanceBlockAtTime(time.getTime())
        console.log(1.9)
        await waypoint.mint(investor, new BN("100000000000000000000"))
        console.log(1.91)
        await waypoint.mint(investor, new BN("100000000000000000000"))
        console.log(1.92)
    function mint(address _to, uint256 _amount) external returns (bool success) {
        // for use by the staking contract and cross-chain transfers
        // mintings occur after a delay to inform users in advance
        require(owners[msg.sender] == true, "request must be made by an owner");
        require(totalSupply() + _amount < maxSupply, "the total supply must be lower than the maximum supply");
        mintings[_to].push([block.timestamp + mintWait, _amount]);
        emit MintStarted(_to, block.timestamp + mintWait, _amount);
        return true;
    }

Ganache CLI v6.12.2 (ganache-core: 2.13.2)]
node v15.12.0
npm 7.6.3

1 Like

Seems to be a bug with using

      web3.currentProvider.send(
        {
          jsonrpc: "2.0",
          method: "evm_mine",
          params: [time],
          id: 42,
        },

in ganache. Using evm_increaseTime might sidestep it.

1 Like

Hi @Svilen_Todorov,

Welcome to the community :wave:

I am not sure why you get a number that is too large for JavaScript. in your mint when previously this worked.

I couldn’t see what you are using for modifying time, you could look at OpenZeppelin Test Helpers if you are using web3/Truffle: https://docs.openzeppelin.com/test-helpers/0.5/api#time