Idiomatic way of testing a Diamond smart contract

Viewed 73

I've been writing and testing solidity code for quite a while, and I've been finding myself using the smock2 library quite extensively. In a nutshell, making sure that during a ContractA test, testing that ContractA calls ContractB rather than testing that the actual side effects of the ContractB call. It allows for great separation of concerns and reduces code duplication.

However, when working with EIP-2535 (aka Diamond pattern), I'm having a difficult time figuring out how to avoid testing FacetB from FacetA, when for example a method of FacetA calls FacetB(address(this)).doSomething().

Is there an accepted way to mock facets? Or otherwise, is there an idiomatic way of testing facets separately, even if they rely on one another? Ideally without having to duplicate FacetB into a solidity mock just used for testing...

I usually use hardhat (Along with ethers) and hardhat-deploy and unfortunately there's very little documentation for the later. Extra points would go for anything utilizing hardhat-deploy's fixtures along with smock.

0 Answers
Related