feat: add mock contract boilerplate for testing #5554
Closed
+826
−273
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds mock contract boilerplate code for usage in testing as requested in issue #5491. It includes:
MockERC20.sol
: A simple ERC20 implementation with mint and burn functionsMockERC721.sol
: A simple ERC721 implementation with mint, safeMint, and burn functionsThese mock contracts are placed in the
contracts/testing/token/
directory and are intended for developers to use in their tests without having to create their own implementations.Motivation
As mentioned in the issue, this is a common testing pattern in Solidity. Developers frequently need to create mock token implementations for testing purposes. By providing these implementations in the library, we can reduce boilerplate code and make testing easier.
Testing
Comprehensive tests have been added for both mock contracts:
test/testing/token/MockERC20.test.js
test/testing/token/MockERC721.test.js
All tests are passing.
Documentation
Documentation has been added:
contracts/testing/README.md
: General documentation for the testing utilitiescontracts/testing/token/README.md
: Specific documentation for the token mocksFixes #5491