Skip to content

[PR #38] p3: MockERC20 missing transferFrom — mock is incomplete for executeOperation unit tests #132

@obchain

Description

@obchain

Summary

MockERC20 in CharonLiquidator.t.sol implements balanceOf, mint, transfer, approve, and allowance, but not transferFrom. The current test usage is limited to rescue tests where only transfer is needed.

However, any future mocked unit test for executeOperation will require transferFrom because:

  • PancakeSwap's exactInputSingle pulls tokens from the caller via transferFrom
  • Some ERC-20 implementations of liquidateBorrow on the debt side use transferFrom

Without transferFrom, any attempt to wire MockERC20 into an executeOperation unit test will silently fail (fallback to no-op or revert) and mask the real behavior.

Location

contracts/test/CharonLiquidator.t.solMockERC20 contract definition

Fix

Add transferFrom to MockERC20:

function transferFrom(address from, address to, uint256 amount) external returns (bool) {
    require(balanceOf[from] >= amount, "insufficient");
    balanceOf[from] -= amount;
    balanceOf[to] += amount;
    return true;
}

Refs #38

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions