@@ -300,6 +300,32 @@ contract DelegationMetaSwapAdapterMockTest is DelegationMetaSwapAdapterBaseTest
300300 super .setUp ();
301301 }
302302
303+ /**
304+ * @notice Verifies that the contract reverts when the zero address is used as an input.
305+ */
306+ function test_revert_invalidZeroAddressInConstructor () public {
307+ address owner_ = address (1 );
308+ address swapApiSigner_ = address (1 );
309+ IDelegationManager delegationManager_ = IDelegationManager (address (1 ));
310+ IMetaSwap metaSwap_ = IMetaSwap (address (1 ));
311+ address argsEqualityCheckEnforcer_ = address (1 );
312+
313+ vm.expectRevert (abi.encodeWithSelector (Ownable.OwnableInvalidOwner.selector , address (0 )));
314+ new DelegationMetaSwapAdapter (address (0 ), swapApiSigner_, delegationManager_, metaSwap_, argsEqualityCheckEnforcer_);
315+
316+ vm.expectRevert (DelegationMetaSwapAdapter.InvalidZeroAddress.selector );
317+ new DelegationMetaSwapAdapter (owner_, address (0 ), delegationManager_, metaSwap_, argsEqualityCheckEnforcer_);
318+
319+ vm.expectRevert (DelegationMetaSwapAdapter.InvalidZeroAddress.selector );
320+ new DelegationMetaSwapAdapter (owner_, swapApiSigner_, IDelegationManager (address (0 )), metaSwap_, argsEqualityCheckEnforcer_);
321+
322+ vm.expectRevert (DelegationMetaSwapAdapter.InvalidZeroAddress.selector );
323+ new DelegationMetaSwapAdapter (owner_, swapApiSigner_, delegationManager_, IMetaSwap (address (0 )), argsEqualityCheckEnforcer_);
324+
325+ vm.expectRevert (DelegationMetaSwapAdapter.InvalidZeroAddress.selector );
326+ new DelegationMetaSwapAdapter (owner_, swapApiSigner_, delegationManager_, metaSwap_, address (0 ));
327+ }
328+
303329 /**
304330 * @notice Verifies that tokens can be swapped by delegations in a purely local environment (using a MetaSwapMock).
305331 */
@@ -1130,6 +1156,14 @@ contract DelegationMetaSwapAdapterMockTest is DelegationMetaSwapAdapterBaseTest
11301156 assertEq (delegationMetaSwapAdapter.swapApiSigner (), newSigner_, "Swap API signer was not updated " );
11311157 }
11321158
1159+ /// @notice Tests that the owner cannot set the swap API signer to the zero address.
1160+ function test_revert_setSwapApiSigner_ifZeroAddress () public {
1161+ _setUpMockContracts ();
1162+ vm.prank (owner);
1163+ vm.expectRevert (DelegationMetaSwapAdapter.InvalidZeroAddress.selector );
1164+ delegationMetaSwapAdapter.setSwapApiSigner (address (0 ));
1165+ }
1166+
11331167 /// @notice Tests that a non-owner calling setSwapApiSigner reverts.
11341168 function test_revert_setSwapApiSigner_ifNotOwner () public {
11351169 _setUpMockContracts ();
@@ -1161,6 +1195,29 @@ contract DelegationMetaSwapAdapterMockTest is DelegationMetaSwapAdapterBaseTest
11611195 delegationMetaSwapAdapter.swapByDelegation (sigData_, delegations_, true );
11621196 }
11631197
1198+ /// @notice Tests that swapByDelegation reverts with SignatureExpired when the signature expiration is equal to current
1199+ /// timestamp.
1200+ function test_revert_swapByDelegation_signatureExpired_equal () public {
1201+ _setUpMockContracts ();
1202+ bytes memory swapData_ = _encodeSwapData (IERC20 (tokenA), IERC20 (tokenB), amountFrom, amountTo, hex "" , 0 , address (0 ), true );
1203+ bytes memory apiData_ = _encodeApiData (aggregatorId, IERC20 (tokenA), amountFrom, swapData_);
1204+ // Set expiration in the current time.
1205+ uint256 expiredTime = block .timestamp ;
1206+ bytes memory signature = _getValidSignature (apiData_, expiredTime);
1207+ DelegationMetaSwapAdapter.SignatureData memory sigData_ =
1208+ DelegationMetaSwapAdapter.SignatureData ({ apiData: apiData_, expiration: expiredTime, signature: signature });
1209+
1210+ Delegation[] memory delegations_ = new Delegation [](2 );
1211+ Delegation memory vaultDelegation_ = _getVaultDelegation ();
1212+ Delegation memory subVaultDelegation_ = _getSubVaultDelegation (EncoderLib._getDelegationHash (vaultDelegation_));
1213+ delegations_[1 ] = vaultDelegation_;
1214+ delegations_[0 ] = subVaultDelegation_;
1215+
1216+ vm.prank (address (subVault.deleGator));
1217+ vm.expectRevert (DelegationMetaSwapAdapter.SignatureExpired.selector );
1218+ delegationMetaSwapAdapter.swapByDelegation (sigData_, delegations_, true );
1219+ }
1220+
11641221 /// @notice Tests that swapByDelegation reverts with InvalidApiSignature when the signature is invalid.
11651222 function test_revert_swapByDelegation_invalidApiSignature () public {
11661223 _setUpMockContracts ();
0 commit comments