You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pattern is repeated over and over again, however the OZ Contracts do not include such trivial boilerplate contracts, in fact the contracts found in /mock are for internal testing and not typically used by end developers.
📝 Details
Include a *Mocking Harness (I use harness to distinguish between the existing usage of Mocks in the codebase and this new one meant to be used by end users
ERC20
// SPDX-License-Identifier: MITpragma solidity^0.8.0;
import"@openzeppelin/contracts/token/ERC20/ERC20.sol";
// A simple Mock ERC20 for testing purposes.contractMockERC20isERC20 {
constructor(stringmemoryname, stringmemorysymbol, uint256initialSupply) ERC20(name, symbol) {
_mint(msg.sender, initialSupply);
}
function mint(addressto, uint256amount) public {
_mint(to, amount);
}
}
🧐 Motivation
Common testing pattern in Solidity is to mock ERC tokens such as:
This pattern is repeated over and over again, however the OZ Contracts do not include such trivial boilerplate contracts, in fact the contracts found in
/mock
are for internal testing and not typically used by end developers.📝 Details
Include a *Mocking Harness (I use harness to distinguish between the existing usage of Mocks in the codebase and this new one meant to be used by end users
ERC20
ERC721
Naive Usage
Note
The path is just an example, for this issue, change as you will!
Conclusion
No more unneeded boilerplate copy paste yes plz sers?
I can open a PR if you would like,
Cheers!
The text was updated successfully, but these errors were encountered: