From 9409fb6161134f6743f4e694fa377226269dce43 Mon Sep 17 00:00:00 2001 From: hexshire Date: Mon, 8 Jul 2024 11:17:10 -0300 Subject: [PATCH 1/3] test: improve readability --- test/unit/L1OpUSDCBridgeAdapter.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/L1OpUSDCBridgeAdapter.t.sol b/test/unit/L1OpUSDCBridgeAdapter.t.sol index a7aaf972..0eb4350a 100644 --- a/test/unit/L1OpUSDCBridgeAdapter.t.sol +++ b/test/unit/L1OpUSDCBridgeAdapter.t.sol @@ -380,8 +380,8 @@ contract L1OpUSDCBridgeAdapter_Unit_BurnLockedUSDC is Base { function test_burnNotCalledIfAmountIsZero(address _circle) external { adapter.forTest_setBurnCaller(_circle); adapter.forTest_setMessengerStatus(IL1OpUSDCBridgeAdapter.Status.Deprecated); + adapter.forTest_setBurnAmount(0); - // This should pass without needing to mock because its set to zero by default // Execute vm.prank(_circle); adapter.burnLockedUSDC(); From c2a2f096ba9fb63cec4a72e9501e186b7f46fc6f Mon Sep 17 00:00:00 2001 From: hexshire Date: Mon, 8 Jul 2024 14:33:49 -0300 Subject: [PATCH 2/3] refactor: zero value tests --- test/unit/L1OpUSDCBridgeAdapter.t.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/unit/L1OpUSDCBridgeAdapter.t.sol b/test/unit/L1OpUSDCBridgeAdapter.t.sol index 948ede46..2d922369 100644 --- a/test/unit/L1OpUSDCBridgeAdapter.t.sol +++ b/test/unit/L1OpUSDCBridgeAdapter.t.sol @@ -96,10 +96,11 @@ contract L1OpUSDCBridgeAdapter_Unit_MigrateToNative is Base { address _burnCaller ) external { vm.assume(_burnCaller != address(0)); + address _roleCaller = address(0); // Execute vm.prank(_owner); vm.expectRevert(abi.encodeWithSelector(IOpUSDCBridgeAdapter.IOpUSDCBridgeAdapter_InvalidAddress.selector)); - adapter.migrateToNative(address(0), _burnCaller, _minGasLimitReceiveOnL2, _minGasLimitSetBurnAmount); + adapter.migrateToNative(_roleCaller, _burnCaller, _minGasLimitReceiveOnL2, _minGasLimitSetBurnAmount); } /** @@ -111,10 +112,11 @@ contract L1OpUSDCBridgeAdapter_Unit_MigrateToNative is Base { address _roleCaller ) external { vm.assume(_roleCaller != address(0)); + address _burnCaller = address(0); // Execute vm.prank(_owner); vm.expectRevert(abi.encodeWithSelector(IOpUSDCBridgeAdapter.IOpUSDCBridgeAdapter_InvalidAddress.selector)); - adapter.migrateToNative(_roleCaller, address(0), _minGasLimitReceiveOnL2, _minGasLimitSetBurnAmount); + adapter.migrateToNative(_roleCaller, _burnCaller, _minGasLimitReceiveOnL2, _minGasLimitSetBurnAmount); } /** From 3e563fdbf259157bfd1f35ece1331779c2995ee4 Mon Sep 17 00:00:00 2001 From: hexshire Date: Mon, 8 Jul 2024 15:36:10 -0300 Subject: [PATCH 3/3] chore: fix styling --- src/contracts/L1OpUSDCBridgeAdapter.sol | 2 +- src/contracts/L2OpUSDCBridgeAdapter.sol | 2 +- src/contracts/universal/OpUSDCBridgeAdapter.sol | 2 +- src/interfaces/IOpUSDCBridgeAdapter.sol | 2 +- src/libraries/CrossChainDeployments.sol | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/contracts/L1OpUSDCBridgeAdapter.sol b/src/contracts/L1OpUSDCBridgeAdapter.sol index fb7366f2..c081b26d 100644 --- a/src/contracts/L1OpUSDCBridgeAdapter.sol +++ b/src/contracts/L1OpUSDCBridgeAdapter.sol @@ -207,7 +207,7 @@ contract L1OpUSDCBridgeAdapter is IL1OpUSDCBridgeAdapter, OpUSDCBridgeAdapter { } /** - * @notice Send tokens to other chain through the linked adapter + * @notice Send signer tokens to other chain through the linked adapter * @param _signer The address of the user sending the message * @param _to The target address on the destination chain * @param _amount The amount of tokens to send diff --git a/src/contracts/L2OpUSDCBridgeAdapter.sol b/src/contracts/L2OpUSDCBridgeAdapter.sol index 63280a9f..5f1c52e9 100644 --- a/src/contracts/L2OpUSDCBridgeAdapter.sol +++ b/src/contracts/L2OpUSDCBridgeAdapter.sol @@ -153,7 +153,7 @@ contract L2OpUSDCBridgeAdapter is IL2OpUSDCBridgeAdapter, OpUSDCBridgeAdapter { } /** - * @notice Send tokens to other chain through the linked adapter + * @notice Send signer tokens to other chain through the linked adapter * @param _signer The address of the user sending the message * @param _to The target address on the destination chain * @param _amount The amount of tokens to send diff --git a/src/contracts/universal/OpUSDCBridgeAdapter.sol b/src/contracts/universal/OpUSDCBridgeAdapter.sol index 3d0bc55c..5d036e6b 100644 --- a/src/contracts/universal/OpUSDCBridgeAdapter.sol +++ b/src/contracts/universal/OpUSDCBridgeAdapter.sol @@ -49,7 +49,7 @@ abstract contract OpUSDCBridgeAdapter is IOpUSDCBridgeAdapter, Ownable { function sendMessage(address _to, uint256 _amount, uint32 _minGasLimit) external virtual; /** - * @notice Send tokens to other chain through the linked adapter + * @notice Send signer tokens to other chain through the linked adapter * @param _signer The address of the user sending the message * @param _to The target address on the destination chain * @param _amount The amount of tokens to send diff --git a/src/interfaces/IOpUSDCBridgeAdapter.sol b/src/interfaces/IOpUSDCBridgeAdapter.sol index 6a552f1f..8b4348b1 100644 --- a/src/interfaces/IOpUSDCBridgeAdapter.sol +++ b/src/interfaces/IOpUSDCBridgeAdapter.sol @@ -115,7 +115,7 @@ interface IOpUSDCBridgeAdapter { function sendMessage(address _to, uint256 _amount, uint32 _minGasLimit) external; /** - * @notice Send tokens to other chain through the linked adapter + * @notice Send signer tokens to other chain through the linked adapter * @param _signer The address of the user sending the message * @param _to The target address on the destination chain * @param _amount The amount of tokens to send diff --git a/src/libraries/CrossChainDeployments.sol b/src/libraries/CrossChainDeployments.sol index ad09576f..0cbcb604 100644 --- a/src/libraries/CrossChainDeployments.sol +++ b/src/libraries/CrossChainDeployments.sol @@ -75,8 +75,7 @@ library CrossChainDeployments { // A one-byte integer in the [0x00, 0x7f] range uses its own value as a length prefix, there is no // additional "0x80 + length" prefix that precedes it. - // A one-byte integer in the [0x00, 0x7f] range uses its own value as a length prefix, there is no - // additional "0x80 + length" prefix that precedes it. + if (_nonce <= 0x7f) { _data = abi.encodePacked(bytes1(0xd6), _LEN, _deployer, uint8(_nonce)); }