@@ -11,6 +11,7 @@ import "../../../../contracts/test/MockCCTP.sol";
1111import { IOFT, SendParam, MessagingFee } from "../../../../contracts/interfaces/IOFT.sol " ;
1212import { MockOFTMessenger } from "../../../../contracts/test/MockOFTMessenger.sol " ;
1313import { AddressToBytes32 } from "../../../../contracts/libraries/AddressConverters.sol " ;
14+ import { OFTTransportAdapter } from "../../../../contracts/libraries/OFTTransportAdapter.sol " ;
1415
1516contract MockHelios is IHelios {
1617 mapping (bytes32 => bytes32 ) public storageSlots;
@@ -70,7 +71,6 @@ contract UniversalSpokePoolTest is Test {
7071 using AddressToBytes32 for address ;
7172 MockUniversalSpokePool spokePool;
7273 MockHelios helios;
73- IOFT oftMessenger;
7474
7575 address hubPoolStore;
7676 address hubPool;
@@ -111,7 +111,6 @@ contract UniversalSpokePoolTest is Test {
111111 new ERC1967Proxy (address (spokePool), abi.encodeCall (Universal_SpokePool.initialize, (0 , hubPool, hubPool)))
112112 );
113113 spokePool = MockUniversalSpokePool (payable (proxy));
114- oftMessenger = IOFT (new MockOFTMessenger (address (usdt)));
115114 deal (address (usdc), address (spokePool), usdcMintAmount, true );
116115 }
117116
@@ -294,6 +293,7 @@ contract UniversalSpokePoolTest is Test {
294293 }
295294
296295 function testSetOftMessenger () public {
296+ IOFT oftMessenger = IOFT (new MockOFTMessenger (address (usdt), 0 , 0 ));
297297 bytes memory message = abi.encodeWithSignature (
298298 "setOftMessenger(address,address) " ,
299299 address (usdt),
@@ -305,7 +305,53 @@ contract UniversalSpokePoolTest is Test {
305305 assertEq (spokePool.oftMessengers (address (usdt)), address (oftMessenger));
306306 }
307307
308+ function testNonZeroLzFee () public {
309+ // Mock an OFT messenger that returns a non-zero lzTokenFee
310+ MockOFTMessenger oftMessengerWithNonZeroLzFee = new MockOFTMessenger (address (usdt), 0 , 1 ); // nativeFee = 0, lzFee = 1
311+
312+ // Set this messenger for USDT
313+ bytes memory message = abi.encodeWithSignature (
314+ "setOftMessenger(address,address) " ,
315+ address (usdt),
316+ address (oftMessengerWithNonZeroLzFee)
317+ );
318+ bytes memory value = abi.encode (address (spokePool), message);
319+ helios.updateStorageSlot (spokePool.getSlotKey (nonce), keccak256 (value));
320+ spokePool.executeMessage (nonce, value, 100 );
321+ nonce++ ; // Increment nonce for the next message
322+
323+ // Expect the OftLzFeeNotZero error from OFTTransportAdapter
324+ vm.expectRevert (OFTTransportAdapter.OftLzFeeNotZero.selector );
325+ spokePool.test_bridgeTokensToHubPool (usdcMintAmount, address (usdt));
326+ }
327+
328+ function testFeeTooHigh () public {
329+ // Mock an OFT messenger that returns a nativeFee higher than OFT_FEE_CAP
330+ uint256 highNativeFee = spokePool.OFT_FEE_CAP () + 1 ;
331+ MockOFTMessenger oftMessengerWithHighFee = new MockOFTMessenger (address (usdt), highNativeFee, 0 ); // nativeFee > OFT_FEE_CAP, lzFee = 0
332+
333+ // Set this messenger for USDT
334+ bytes memory message = abi.encodeWithSignature (
335+ "setOftMessenger(address,address) " ,
336+ address (usdt),
337+ address (oftMessengerWithHighFee)
338+ );
339+ bytes memory value = abi.encode (address (spokePool), message);
340+ helios.updateStorageSlot (spokePool.getSlotKey (nonce), keccak256 (value));
341+ spokePool.executeMessage (nonce, value, 100 );
342+ nonce++ ; // Increment nonce for the next message
343+
344+ // Fund the spokePool with enough native currency to attempt the transaction but less than the high fee
345+ // The check for OFT_FEE_CAP happens before the balance check.
346+ deal (address (spokePool), spokePool.OFT_FEE_CAP ());
347+
348+ // Expect the OftFeeCapExceeded error from OFTTransportAdapter
349+ vm.expectRevert (OFTTransportAdapter.OftFeeCapExceeded.selector );
350+ spokePool.test_bridgeTokensToHubPool (usdcMintAmount, address (usdt));
351+ }
352+
308353 function testBridgeTokensToHubPool_oft () public {
354+ IOFT oftMessenger = IOFT (new MockOFTMessenger (address (usdt), 0 , 0 ));
309355 bytes memory message = abi.encodeWithSignature (
310356 "setOftMessenger(address,address) " ,
311357 address (usdt),
0 commit comments