@@ -5,6 +5,7 @@ import "forge-std/Test.sol";
55
66import {TypeCasts} from "../../contracts/libs/TypeCasts.sol " ;
77import {MockMailbox} from "../../contracts/mock/MockMailbox.sol " ;
8+ import {MockWETH} from "../../contracts/mock/MockWETH.sol " ;
89import {TestPostDispatchHook} from "../../contracts/test/TestPostDispatchHook.sol " ;
910import {HypNative} from "../../contracts/token/HypNative.sol " ;
1011import {IWETH} from "../../contracts/token/interfaces/IWETH.sol " ;
@@ -13,79 +14,6 @@ import {HypNativeWethWrapperFactory} from "../../contracts/token/extensions/HypN
1314import {Quote} from "../../contracts/interfaces/ITokenBridge.sol " ;
1415import {Quotes} from "../../contracts/token/libs/Quotes.sol " ;
1516
16- /// @dev Minimal WETH9-compatible token for unit tests.
17- contract TestWETH is IWETH {
18- string public constant name = "Wrapped Ether " ;
19- string public constant symbol = "WETH " ;
20- uint8 public constant decimals = 18 ;
21-
22- mapping (address => uint256 ) public override balanceOf;
23- mapping (address => mapping (address => uint256 )) public override allowance;
24-
25- event Deposit (address indexed account , uint256 amount );
26- event Withdrawal (address indexed account , uint256 amount );
27-
28- function totalSupply () external view override returns (uint256 ) {
29- return address (this ).balance;
30- }
31-
32- function deposit () public payable override {
33- balanceOf[msg .sender ] += msg .value ;
34- emit Deposit (msg .sender , msg .value );
35- }
36-
37- function withdraw (uint256 amount ) external override {
38- require (balanceOf[msg .sender ] >= amount, "WETH: balance " );
39- balanceOf[msg .sender ] -= amount;
40- (bool ok , ) = msg .sender .call {value: amount}("" );
41- require (ok, "WETH: send failed " );
42- emit Withdrawal (msg .sender , amount);
43- }
44-
45- function approve (
46- address spender ,
47- uint256 amount
48- ) external override returns (bool ) {
49- allowance[msg .sender ][spender] = amount;
50- return true ;
51- }
52-
53- function transfer (
54- address to ,
55- uint256 amount
56- ) external override returns (bool ) {
57- return _transfer (msg .sender , to, amount);
58- }
59-
60- function transferFrom (
61- address from ,
62- address to ,
63- uint256 amount
64- ) external override returns (bool ) {
65- uint256 allowed = allowance[from][msg .sender ];
66- if (allowed != type (uint256 ).max) {
67- require (allowed >= amount, "WETH: allowance " );
68- allowance[from][msg .sender ] = allowed - amount;
69- }
70- return _transfer (from, to, amount);
71- }
72-
73- function _transfer (
74- address from ,
75- address to ,
76- uint256 amount
77- ) internal returns (bool ) {
78- require (balanceOf[from] >= amount, "WETH: balance " );
79- balanceOf[from] -= amount;
80- balanceOf[to] += amount;
81- return true ;
82- }
83-
84- receive () external payable {
85- deposit ();
86- }
87- }
88-
8917contract HypNativeWethWrapperTest is Test {
9018 using TypeCasts for address ;
9119 using Quotes for Quote[];
@@ -101,7 +29,7 @@ contract HypNativeWethWrapperTest is Test {
10129 TestPostDispatchHook internal noopHook;
10230 HypNative internal localRouter;
10331 HypNative internal remoteRouter;
104- TestWETH internal weth;
32+ MockWETH internal weth;
10533 HypNativeWethWrapper internal wrapper;
10634
10735 function setUp () public {
@@ -130,7 +58,7 @@ contract HypNativeWethWrapperTest is Test {
13058 address (localRouter).addressToBytes32 ()
13159 );
13260
133- weth = new TestWETH ();
61+ weth = new MockWETH ();
13462 wrapper = new HypNativeWethWrapper (IWETH (address (weth)), localRouter);
13563
13664 vm.label (ALICE, "ALICE " );
0 commit comments