Closed hickscorp closed 2 years ago
hi @hickscorp, could you provide a basic example within the smock repo of a diamond deployment and the expected behaviour? we're not very experienced with proxies and i'm afraid i do not totally understand how the feature would work. if you can include the required packages and some test contracts, i can help you to develop the tests and add it as a bounty to develop
I will!
@wei3erHase happy to team up together today if you have a bit of time. We could get clean requirements written together?
I made a repository which has a README explaining the specs: https://github.com/hickscorp/smock-diamond-showcase
This is not a bug report - rather it's probably the start of a discuthis ssion, which could either lead to discovering that
smock
could have new features around the diamond pattern, or a contribution from people who found ways to do things neatly.Consider the following architecture:
Diamond
.FacetA
andFacetB
.FacetA
, and you don't want to mix concerns fromFacetB
- in a nutshell, you would like to somehow act as ifFacetB
would be a separate contract.At this point, I found myself stuck - because although
FacetA
andFacetB
are split into different contacts, all their methods are in fact accessible through theDiamond
contract. I didn't find a way to mockFacetB
- and I found myself quite often testing things from theFacetA
tests that are relevant toFacetB
and reciproquelly.I think since Diamonds often use libraries for functions that are reused across facets, there could be overlap with https://github.com/defi-wonderland/smock/issues/50 ... But it's not always the case. Very often in
FacetA.sol
there are calls such asFacetB(address(this)).someFunction()
- and it's not something thatsmock
can help with unfortunatelly.Can we maybe brainstorm a bit - it might be that I am missing something obvious here - but if not, I think it would be of great help to think about how
smock
could be improved to help with the diamond pattern.One of the solution I found which would potentially work, would be to have some facets duplicated just for tests... But that would require quite some boilerplate written in solidity all the time - for example having
FacetBMock.sol
have afallback()
function which would record all calls so that they could be inspected by the typescript test - return values wouldn't work though.Another option would be to allow
smock
to "connect" to an existing address... For example the flow would look like:FacetA
.FacetB
(Eg smock.mock('FacetB')) and perform a
diamondCut` to set it on the diamond.In case it helps gathering ideas: this is a stack overflow post I've made regarding this particular topic.