Files
smom-dbis-138/test/bridge/adapters/TezosAdapter.t.sol
2026-03-02 12:14:09 -08:00

47 lines
1.7 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Test} from "forge-std/Test.sol";
import {TezosAdapter} from "../../../contracts/bridge/adapters/non-evm/TezosAdapter.sol";
import {IChainAdapter} from "../../../contracts/bridge/interfaces/IChainAdapter.sol";
contract TezosAdapterTest is Test {
TezosAdapter public adapter;
address public admin = address(0x1);
address public oracle = address(0x2);
address public user = address(0x3);
function setUp() public {
vm.startPrank(admin);
adapter = new TezosAdapter(admin);
adapter.grantRole(adapter.ORACLE_ROLE(), oracle);
vm.stopPrank();
vm.deal(user, 10 ether);
}
function test_getChainType() public view {
assertEq(adapter.getChainType(), "Tezos");
}
function test_getChainIdentifier() public view {
(uint256 chainId, string memory id) = adapter.getChainIdentifier();
assertEq(chainId, 0);
assertEq(id, "Tezos-Mainnet");
}
function test_validateDestination_valid() public view {
string memory tz1 = "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb";
assertTrue(adapter.validateDestination(bytes(tz1)));
}
function test_bridge_nativeAndConfirm() public {
bytes memory dest = bytes("tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb");
vm.prank(user);
bytes32 requestId = adapter.bridge{value: 1 ether}(address(0), 1 ether, dest, "");
assertEq(uint256(adapter.getBridgeStatus(requestId).status), uint256(IChainAdapter.BridgeStatus.Locked));
vm.prank(oracle);
adapter.confirmTransaction(requestId, "opHash123");
assertEq(uint256(adapter.getBridgeStatus(requestId).status), uint256(IChainAdapter.BridgeStatus.Confirmed));
}
}