Skip to content

Commit

Permalink
update unit tests for bridges
Browse files Browse the repository at this point in the history
  • Loading branch information
kovalgek committed Feb 8, 2024
1 parent 7abf60f commit 707da9b
Show file tree
Hide file tree
Showing 5 changed files with 1,258 additions and 514 deletions.
6 changes: 5 additions & 1 deletion contracts/optimism/L2ERC20TokenBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@ contract L2ERC20TokenBridge is
bytes calldata data_
) internal {
if (l2Token_ == L2_TOKEN_REBASABLE) {

// TODO: maybe loosing 1 wei here as well
uint256 shares = ERC20Rebasable(L2_TOKEN_REBASABLE).getSharesByTokens(amount_);
ERC20Rebasable(L2_TOKEN_REBASABLE).burnShares(msg.sender, shares);
_initiateWithdrawal(L2_TOKEN_REBASABLE, L2_TOKEN_REBASABLE, msg.sender, to_, shares, l1Gas_, data_);

_initiateWithdrawal(L1_TOKEN_REBASABLE, L2_TOKEN_REBASABLE, msg.sender, to_, shares, l1Gas_, data_);
emit WithdrawalInitiated(L1_TOKEN_REBASABLE, L2_TOKEN_REBASABLE, msg.sender, to_, amount_, data_);
} else if (l2Token_ == L2_TOKEN_NON_REBASABLE) {

IERC20Bridged(L2_TOKEN_NON_REBASABLE).bridgeBurn(msg.sender, amount_);

_initiateWithdrawal(L1_TOKEN_NON_REBASABLE, L2_TOKEN_NON_REBASABLE, msg.sender, to_, amount_, l1Gas_, data_);
emit WithdrawalInitiated(L1_TOKEN_NON_REBASABLE, L2_TOKEN_NON_REBASABLE, msg.sender, to_, amount_, data_);
}
Expand Down
3 changes: 2 additions & 1 deletion contracts/stubs/ERC20WrapperStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {IERC20Bridged} from "../token/interfaces/IERC20Bridged.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20WstETH} from "../token/interfaces/IERC20WstETH.sol";
import {IERC20Wrapper} from "../token/interfaces/IERC20Wrapper.sol";

// represents wstETH on L1
contract ERC20WrapperStub is IERC20WstETH, ERC20 {
contract ERC20WrapperStub is IERC20Wrapper, IERC20WstETH, ERC20 {

IERC20 public stETH;
address public bridge;
Expand Down
Loading

0 comments on commit 707da9b

Please sign in to comment.