Test/diamond cut facet#151
Conversation
|
@megabyte0x This pull request is very much appreciated. One thing that is sorely need, (very very much) needed right now is tests that show gas usage for very large diamonds, for example 200 facets with 10 functions each, added to a diamond. This is especially needed for testing and seeing the gas used by the functions in DiamondLoupeFacet for the diamond gas challenge. Is this something that can be added fairly easily to these tests? |
Coverage Report
Last updated: Mon, 03 Nov 2025 21:10:38 GMT for commit |
Gas ReportNo gas usage changes detected between All functions maintain the same gas costs. ✅ Last updated: Mon, 03 Nov 2025 21:11:02 GMT for commit |
hey @mudgen |
|
hey @mudgen I am done with the This coverage was only achievable when I removed the following |
|
@adamgall Do the tests look okay to you? |
See #165 |
There was a problem hiding this comment.
Let's remove this file from the PR for now, please
| function test_DiamondCut_initalizeCallWithWrongCalldataReturningErrorMessage() public { | ||
| (DiamondCutFacet.FacetCut[] memory _cut,,) = _basicAction(); | ||
|
|
||
| ERC20FacetHarnessWithFallback newFacet = new ERC20FacetHarnessWithFallback(); | ||
| address _init = address(newFacet); | ||
|
|
||
| bytes memory _wrongCalldata = abi.encodeWithSelector( | ||
| bytes4(keccak256("initialize(string,string,uint256)")), TOKEN_NAME, TOKEN_DECIMALS, TOKEN_DECIMALS | ||
| ); | ||
|
|
||
| vm.prank(owner); | ||
| vm.expectRevert(abi.encode("WRONG FUNCTION CALL")); | ||
| facet.diamondCut(_cut, _init, _wrongCalldata); | ||
| } |
There was a problem hiding this comment.
I'm probably missing something, but can you explain what this test is testing for?
The revert comes from the ERC20FacetHarnessWithFallbackHarness (not an actual src contract), so it seems to me like this test doesn't actually hit a real contract.
There was a problem hiding this comment.
This test is for the following condition branch when the _init address sends an error message on failed execution of the _calldata.
ERC20FacetHarnessWithFallbackHarness inherits the ERC20Facet which is being as the _init contract for testing, like in other test cases ERC20Harness is utilized.
@mudgen |
|
@megabyte0x Great! Love to see this. @adamgall is this ready for us to merge? @megabyte0x You can work on |
|
@megabyte0x Format check failed. Need to run |
fixed this. @mudgen If this PR is ready for merge as per you, then let's merge this. I'll work on the |
|
@megabyte0x Great, thanks very much. Merged. |
…ondCutFacet Test/diamond cut facet


Tests for DiamondCutFacet, LibDiamond and DiamondLoupeFacet.
Issue: #119