diff --git a/.changeset/kind-meals-thank.md b/.changeset/kind-meals-thank.md new file mode 100644 index 000000000..6da707270 --- /dev/null +++ b/.changeset/kind-meals-thank.md @@ -0,0 +1,5 @@ +--- +"@layerzerolabs/oft-example": patch +--- + +Fix OFT example tests diff --git a/examples/oft/contracts/mocks/MyOFTMock.sol b/examples/oft/contracts/mocks/MyOFTMock.sol new file mode 100644 index 000000000..3ebb888d4 --- /dev/null +++ b/examples/oft/contracts/mocks/MyOFTMock.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.22; + +import { MyOFT } from "../MyOFT.sol"; + +// @dev WARNING: This is for testing purposes only +contract MyOFTMock is MyOFT { + constructor( + string memory _name, + string memory _symbol, + address _lzEndpoint, + address _delegate + ) MyOFT(_name, _symbol, _lzEndpoint, _delegate) {} + + function mint(address _to, uint256 _amount) public { + _mint(_to, _amount); + } +} diff --git a/examples/oft/contracts/mocks/OFTMock.sol b/examples/oft/contracts/mocks/OFTMock.sol deleted file mode 100644 index 953871882..000000000 --- a/examples/oft/contracts/mocks/OFTMock.sol +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.0; - -import { OFT } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFT.sol"; -import { SendParam } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFTCore.sol"; -import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; - -// @dev WARNING: This is for mock purposes only -contract OFTMock is OFT { - constructor( - string memory _name, - string memory _symbol, - address _lzEndpoint, - address _delegate - ) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {} - - function mint(address _to, uint256 _amount) public { - _mint(_to, _amount); - } - - // @dev expose internal functions for testing purposes - function debit( - uint256 _amountToSendLD, - uint256 _minAmountToCreditLD, - uint32 _dstEid - ) public returns (uint256 amountDebitedLD, uint256 amountToCreditLD) { - return _debit(_amountToSendLD, _minAmountToCreditLD, _dstEid); - } - - function debitView( - uint256 _amountToSendLD, - uint256 _minAmountToCreditLD, - uint32 _dstEid - ) public view returns (uint256 amountDebitedLD, uint256 amountToCreditLD) { - return _debitView(_amountToSendLD, _minAmountToCreditLD, _dstEid); - } - - function removeDust(uint256 _amountLD) public view returns (uint256 amountLD) { - return _removeDust(_amountLD); - } - - function toLD(uint64 _amountSD) public view returns (uint256 amountLD) { - return _toLD(_amountSD); - } - - function toSD(uint256 _amountLD) public view returns (uint64 amountSD) { - return _toSD(_amountLD); - } - - function credit(address _to, uint256 _amountToCreditLD, uint32 _srcEid) public returns (uint256 amountReceivedLD) { - return _credit(_to, _amountToCreditLD, _srcEid); - } - - function buildMsgAndOptions( - SendParam calldata _sendParam, - uint256 _amountToCreditLD - ) public view returns (bytes memory message, bytes memory options) { - return _buildMsgAndOptions(_sendParam, _amountToCreditLD); - } -} diff --git a/examples/oft/test/hardhat/MyOFT.test.ts b/examples/oft/test/hardhat/MyOFT.test.ts index b4536351a..4bb4ee95c 100644 --- a/examples/oft/test/hardhat/MyOFT.test.ts +++ b/examples/oft/test/hardhat/MyOFT.test.ts @@ -23,7 +23,9 @@ describe('MyOFT Test', function () { // Before hook for setup that runs once before all tests in the block before(async function () { // Contract factory for our tested contract - MyOFT = await ethers.getContractFactory('OFTMock') + // + // We are using a derived contract that exposes a mint() function for testing purposes + MyOFT = await ethers.getContractFactory('MyOFTMock') // Fetching the first three signers (accounts) from Hardhat's local Ethereum network const signers = await ethers.getSigners()