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

import {Test, console} from "forge-std/Test.sol";
import "../../../contracts/bridge/trustless/SwapBridgeSwapCoordinator.sol";
import "../../../contracts/bridge/trustless/EnhancedSwapRouter.sol";
import "../../../contracts/bridge/trustless/LiquidityPoolETH.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MockERC20 is ERC20 {
    constructor(string memory name, string memory symbol) ERC20(name, symbol) {
        _mint(msg.sender, 1000000 ether);
    }
}

contract SwapBridgeSwapCoordinatorTest is Test {
    SwapBridgeSwapCoordinator public coordinator;
    EnhancedSwapRouter public swapRouter;
    address public mockBridge;

    MockERC20 public weth;
    address public deployer = address(0xDE01);

    function setUp() public {
        vm.startPrank(deployer);
        weth = new MockERC20("WETH", "WETH");
        address u = address(0x1111);
        address c = address(0x2222);
        address d = address(0x3333);
        address b = address(0x4444);
        address o = address(0x5555);
        swapRouter = new EnhancedSwapRouter(u, c, d, b, o, address(weth), u, c, address(0x6666));
        mockBridge = address(0xBEEF);
        coordinator = new SwapBridgeSwapCoordinator(address(swapRouter), mockBridge);
        vm.stopPrank();
    }

    function testConstructor() public view {
        assertEq(address(coordinator.swapRouter()), address(swapRouter));
        assertEq(address(coordinator.bridge()), mockBridge);
    }

    function testSwapAndBridgeRevertsZeroAmount() public {
        vm.prank(deployer);
        vm.expectRevert(SwapBridgeSwapCoordinator.ZeroAmount.selector);
        coordinator.swapAndBridge(
            address(weth),
            0,
            0,
            address(weth),
            5009297550715157269,
            deployer,
            bytes32(0),
            false,
            false
        );
    }

    function testSwapAndBridgeRevertsZeroAddress() public {
        vm.prank(deployer);
        weth.approve(address(coordinator), 1 ether);
        vm.expectRevert(SwapBridgeSwapCoordinator.ZeroAddress.selector);
        coordinator.swapAndBridge(
            address(0),
            1 ether,
            0,
            address(weth),
            5009297550715157269,
            deployer,
            bytes32(0),
            false,
            false
        );
    }
}
