Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve test readability and general styling #97

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/contracts/L1OpUSDCBridgeAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/L2OpUSDCBridgeAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/universal/OpUSDCBridgeAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IOpUSDCBridgeAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/CrossChainDeployments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
8 changes: 5 additions & 3 deletions test/unit/L1OpUSDCBridgeAdapter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -380,8 +382,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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should apply this style to the rest of our tests too, so the revert cases explicitly show what is happening, doc just used this one as an example haha

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh! Ok, this is going to take some time, thanks!


// This should pass without needing to mock because its set to zero by default
// Execute
vm.prank(_circle);
adapter.burnLockedUSDC();
Expand Down