Cyfrin / foundry-smart-contract-lottery-cu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setup failed: Arithmetic over/underflow

przemyslawdrozd opened this issue · comments

I have started to write tests (5:04h) for Raffle contract, but executing forge test I got:

ERROR forge::runner: setUp failed reason="Arithmetic over/underflow" contract=0x7fa9385be102ac3eac297483dd6233d62b3e1496
Running 1 test for test/unit/RaffleTest.t.sol:RaffleTest
[FAIL. Reason: Setup failed: Arithmetic over/underflow] setUp() (gas: 0)
Test result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 1.88ms
Ran 1 test suites: 0 tests passed, 1 failed, 0 skipped (1 total tests)

Looks like issue is somewhere on calling contract creation inside DeployRaffle

vm.startBroadcast();
Raffle raffle = new Raffle(
    enterenceFee,
    interval,
    vrfCoordinator,
    gasLane,
    subId,
    callbackGasLimit
);
vm.stopBroadcast();

When I will comment this out, issue gone, but I cannot find what is the actual cause of it.

I have found the issue. Just typo on Raffle.sol constructor:

 constructor(
        uint256 enterenceFee,
        uint256 interval,
        address vrfCoordinator,
        bytes32 gasLane,
        uint64 subId,
        uint32 callbackGasLimit
    ) VRFConsumerBaseV2(vrfCoordinator) {
        i_enterenceFee = enterenceFee;
        i_interval = interval;
        i_vrfCoordinator = VRFCoordinatorV2Interface(vrfCoordinator);
        i_gasLane = gasLane;
        i_subId = subId;
        i_callbackGasLimit = callbackGasLimit;
        s_lastTimeStamp - block.timestamp; <-- typo here
    }