-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat request: mocking Diamond proxy schemes #116
Comments
hi @hickscorp, |
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 #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.
The text was updated successfully, but these errors were encountered: