Skip to content
Merged
91 changes: 70 additions & 21 deletions contracts/test/ArbitrumMocks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,94 @@
pragma solidity ^0.8.0;

contract ArbitrumMockErc20GatewayRouter {
address public gateway;

event OutboundTransferCalled(
address l1Token,
address to,
uint256 amount,
uint256 maxGas,
uint256 gasPriceBid,
bytes data
);

event OutboundTransferCustomRefundCalled(
address l1Token,
address refundTo,
address to,
uint256 amount,
uint256 maxGas,
uint256 gasPriceBid,
bytes data
);

function setGateway(address _gateway) external {
gateway = _gateway;
}

function outboundTransferCustomRefund(
address,
address,
address,
uint256,
uint256,
uint256,
address _l1Token,
address _refundTo,
address _to,
uint256 _amount,
uint256 _maxGas,
uint256 _gasPriceBid,
bytes calldata _data
) external payable returns (bytes memory) {
emit OutboundTransferCustomRefundCalled(_l1Token, _refundTo, _to, _amount, _maxGas, _gasPriceBid, _data);
return _data;
}

function outboundTransfer(
address,
address,
uint256,
uint256,
uint256,
address _l1Token,
address _to,
uint256 _amount,
uint256 _maxGas,
uint256 _gasPriceBid,
bytes calldata _data
) external payable returns (bytes memory) {
emit OutboundTransferCalled(_l1Token, _to, _amount, _maxGas, _gasPriceBid, _data);
return _data;
}

function getGateway(address) external view returns (address) {
return address(this);
// Return custom gateway if set, otherwise return self (original behavior)
return gateway != address(0) ? gateway : address(this);
}
}

contract Inbox {
event RetryableTicketCreated(
address destAddr,
uint256 l2CallValue,
uint256 maxSubmissionCost,
address excessFeeRefundAddress,
address callValueRefundAddress,
uint256 maxGas,
uint256 gasPriceBid,
bytes data
);

function createRetryableTicket(
address,
uint256,
uint256,
address,
address,
uint256,
uint256,
bytes memory
) external pure returns (uint256) {
address _destAddr,
uint256 _l2CallValue,
uint256 _maxSubmissionCost,
address _excessFeeRefundAddress,
address _callValueRefundAddress,
uint256 _maxGas,
uint256 _gasPriceBid,
bytes memory _data
) external payable returns (uint256) {
emit RetryableTicketCreated(
_destAddr,
_l2CallValue,
_maxSubmissionCost,
_excessFeeRefundAddress,
_callValueRefundAddress,
_maxGas,
_gasPriceBid,
_data
);
return 0;
}
}
Expand Down
25 changes: 18 additions & 7 deletions contracts/test/MockCCTP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@ pragma solidity ^0.8.0;
import "../libraries/CircleCCTPAdapter.sol";

contract MockCCTPMinter is ITokenMinter {
function burnLimitsPerMessage(address) external pure returns (uint256) {
return type(uint256).max;
uint256 private _burnLimit = type(uint256).max;

function setBurnLimit(uint256 limit) external {
_burnLimit = limit;
}

function burnLimitsPerMessage(address) external view returns (uint256) {
return _burnLimit;
}
}

contract MockCCTPMessenger is ITokenMessenger {
ITokenMinter private minter;
uint256 public depositForBurnCallCount;

event DepositForBurnCalled(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken);

constructor(ITokenMinter _minter) {
minter = _minter;
}

function depositForBurn(
uint256,
uint32,
bytes32,
address
) external pure returns (uint64 _nonce) {
uint256 _amount,
uint32 _destinationDomain,
bytes32 _mintRecipient,
address _burnToken
) external returns (uint64 _nonce) {
depositForBurnCallCount++;
emit DepositForBurnCalled(_amount, _destinationDomain, _mintRecipient, _burnToken);
return 0;
}

Expand Down
36 changes: 36 additions & 0 deletions contracts/test/MockERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,42 @@ import { ERC20Permit } from "@openzeppelin/contracts-v4/token/ERC20/extensions/E
import { ERC20 } from "@openzeppelin/contracts-v4/token/ERC20/ERC20.sol";
import { SignatureChecker } from "@openzeppelin/contracts-v4/utils/cryptography/SignatureChecker.sol";

/**
* @title MintableERC20
* @notice Simple mintable ERC20 with configurable decimals for testing.
*/
contract MintableERC20 is ERC20 {
uint8 private _decimals;

constructor(string memory name, string memory symbol, uint8 decimals_) ERC20(name, symbol) {
_decimals = decimals_;
}

function mint(address to, uint256 amount) external returns (bool) {
_mint(to, amount);
return true;
}

function burn(uint256 amount) external {
_burn(msg.sender, amount);
}

function burnFrom(address from, uint256 amount) external returns (bool) {
_spendAllowance(from, msg.sender, amount);
_burn(from, amount);
return true;
}

// ExpandedIERC20 compatibility
function addMinter(address) external {}
function addBurner(address) external {}
function resetOwner(address) external {}

function decimals() public view override returns (uint8) {
return _decimals;
}
}

/**
* @title MockERC20
* @notice Implements mocked ERC20 contract with various features.
Expand Down
Loading
Loading