// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Test} from "forge-std/Test.sol";
import {ReceiverExecutorMainnet} from "../../contracts/treasury/ReceiverExecutorMainnet.sol";

contract ReceiverExecutorMainnetTest is Test {
    ReceiverExecutorMainnet public receiver;
    address public admin;
    address public keeper;
    address public bridge;

    function setUp() public {
        admin = address(1);
        keeper = address(2);
        bridge = address(0x99);
        receiver = new ReceiverExecutorMainnet(admin);
        vm.startPrank(admin);
        receiver.grantRole(receiver.KEEPER_ROLE(), keeper);
        vm.stopPrank();
    }

    function test_expectedWeth9Source_defaultZero() public view {
        assertEq(receiver.getExpectedWeth9Source(), address(0));
        assertEq(receiver.expectedWeth9Source(), address(0));
    }

    function test_setExpectedWeth9Source_success() public {
        vm.prank(admin);
        receiver.setExpectedWeth9Source(bridge);
        assertEq(receiver.getExpectedWeth9Source(), bridge);
        assertEq(receiver.expectedWeth9Source(), bridge);
    }

    function test_setExpectedWeth9Source_revert_notAdmin() public {
        vm.prank(keeper);
        vm.expectRevert();
        receiver.setExpectedWeth9Source(bridge);
    }

    function test_receive_acceptsEth() public {
        (bool sent,) = address(receiver).call{value: 1 ether}("");
        assertTrue(sent);
        assertEq(address(receiver).balance, 1 ether);
    }

    function test_constants_matchMainnet() public view {
        assertEq(receiver.WETH9_MAINNET(), 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
        assertEq(receiver.USDC_MAINNET(), 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
        assertEq(receiver.USDT_MAINNET(), 0xdAC17F958D2ee523a2206206994597C13D831ec7);
    }
}
