0

I am following the new foundry course by Patrick and was wondering if I could get tips on how to test the deploy script - https://github.com/Cyfrin/foundry-smart-contract-lottery-f23/blob/main/script/DeployRaffle.s.sol

I am unable to brainstorm ideas on how the testing should happen:

contract DeployRaffleTest is Test {
    uint256 entranceFee;
    uint256 interval;
    address vrfCoordinator;
    bytes32 gasLane;
    uint64 subscriptionId; //either get this from UI or make yourself
    uint32 callbackGasLimit;
    address link;
    uint256 deployerKey;
    HelperConfig helperConfig = new HelperConfig();

    function setUp() public {
        (
            entranceFee,
            interval,
            vrfCoordinator,
            gasLane,
            subscriptionId,
            callbackGasLimit,
            ,
            deployerKey
        ) = helperConfig.activeNetworkConfig();
    }

    Raffle deployedRaffle;

    //     new Raffle(
    //         entranceFee,
    //         interval,
    //         vrfCoordinator,
    //         gasLane,
    //         subscriptionId,
    //         callbackGasLimit
    //     );

    function testDeployRaffleReturnValuesAreNotNull() public {
        DeployRaffle deployer = new DeployRaffle();
        (deployedRaffle, helperConfig) = deployer.run();

        assert(address(deployedRaffle) != address(0));
        assert(address(helperConfig) != address(0));
    }
}

Please guide.

1 Answer 1

0

You can use forge test to run all the tests quickly.

To test particular file you can use forge test ../path

To fork a network you can use:- forge test --rpc-url url-here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.