0

I have a contract that basically mints an ERC20 token in exchange for USDT. So something like this:

contract USDTStrategy is ICoinYield, ReentrancyGuard {
  address private constant USDT_ADDRESS = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
  IERC20 private constant _usdt = IERC20(USDT_ADDRESS);
  CYUSDTToken private immutable _cyusdt = new CYUSDTToken();
  
  function deposit(uint256 amount) override external payable nonReentrant {
    // Transfer amount USDT tokens from msg.sender to contract
    _usdt.transferFrom(msg.sender, address(this), amount);

    // Send amount tokens to msg.sender
    _cyusdt.mint(msg.sender, amount);
  }
}

Now I would like to unit test the deposit function, however I would need to mock the USDT token. I can't see anyway of doing this apart from moving the USDT_ADDRESS into a constructor so that the address can be mocked. Is there a better way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.