solidstate-solidity
solidstate-solidity copied to clipboard
feat: migrate to Hardhat chai matchers
Replaces the ethereum-waffle package with @ethereum-waffle/mock-contract and @nomicfoundation/hardhat-chai-matchers.
Summary of changes:
- Removed
ethereum-waffle
and@nomiclabs/hardhat-waffle
as dependencies - Added
@nomicfoundation/hardhat-chai-matchers
and@ethereum-waffle/mock-contract
as dependencies - Added import of
@nomiclabs/hardhat-ethers
hardhat configurations where the hardhat-waffle would import the hardhat-ethers plugin. - Updated imports of deployMockContract, MockContract to come from
@ethereum-waffle/mock-contract
. - Updated expected
Hardhat couldn't infer the reason
assertion with revertedWithoutReason matcher. - Fixed test AddressUtils target contract reverts, with default error message assertion.
Initially introduced 4 Failing tests:
4 failing
1) SolidStateDiamond
::SolidStateDiamond
::DiamondWritable
#diamondCut((address,enum,bytes4[])[],address,bytes)
reverts if
passed FacetCutAction is invalid:
AssertionError: Expected transaction to be reverted with reason 'Hardhat couldn't infer the reason.', but it reverted without a reason
2) DiamondWritable
::DiamondWritable
#diamondCut((address,enum,bytes4[])[],address,bytes)
reverts if
passed FacetCutAction is invalid:
AssertionError: Expected transaction to be reverted with reason 'Hardhat couldn't infer the reason.', but it reverted without a reason
3) ERC1155Base
__internal
#_burn(address,uint256,uint256)
reverts if
burn amount exceeds balance:
AssertionError: Expected transaction to be reverted with reason 'ERC1155: burn amount exceeds balance', but it reverted with reason 'ERC1155: burn amount exceeds balances'
4) AddressUtils
__internal
#functionCallWithValue(address,bytes,uint256)
reverts if
target contract reverts, with default error message:
AssertionError: Expected transaction to be reverted with reason 'AddressUtils: failed low-level call', but it reverted with reason 'AddressUtils: failed low-level call with value'
-
Failures # 1 & # 2 are occurring due to the way the new matchers work. The proper matcher would now be revertedWithoutReason.
-
Failure # 3 and # 4 is related to what was brought up in #124. # 3 was fixed upstream. # 4 is a similar issue, but in this case it is the test that has the incorrect error string.
Thanks for the PR, I'll review soon. Not much time at the moment.
This is required for PR #139, meaning that the breaking change mentioned in comments above is probably worth it. Merging into the error-types
branch.