Skip to content
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

Foundry SDK for writing end-to-end tests #584

Open
PaulRBerg opened this issue Jun 3, 2023 · 3 comments
Open

Foundry SDK for writing end-to-end tests #584

PaulRBerg opened this issue Jun 3, 2023 · 3 comments

Comments

@PaulRBerg
Copy link

Context

Scenario: Foundry project in which I want to write end-to-end tests that ensure that our protocol works with Safe.

Proposed solution

Provide a Foundry-based SDK for facilitating end-to-end tests. The SDK should contain:

  • The essential interfaces needed for testing, e.g. GnosisSafeProy
  • The Safe factory addresses deployed to all relevant chains (useful for fork testing)
  • Some testing utilities, e.g. signing messages

Additional context

It looks like Permit2 has a Safe e2e test:

https://github.com/Uniswap/permit2/blob/bbbc92f895049ca45c4b25a450f9d3e907659284/test/integration/GnosisSafe.t.sol

@mmv08
Copy link
Member

mmv08 commented Jun 3, 2023

What exactly do you want to test? Generally, as long as you do not do things like tx.origin == msg.sender no custom logic is required to make the protocol work with Safe (or any thoughtfully written smart contract wallets). This is one of our main goals when writing the contracts.

In my opinion, such integration or end-to-end testing only makes sense when you're developing a protocol as an extension of Safe, like Zodiac's DAO protocol designed to work with Safe, so involving Safe's production code is highly beneficial there.

Using Safe in that Uniswap test makes little sense to me. Their goal was to test that permit2 works with EIP-1271, and they used the foundry's vm hack to change the storage slot directly... Any wallet could've been used there or even a stub

Also, do you have examples of such SDKs?

@PaulRBerg
Copy link
Author

Good points.

I guess I was mostly looking for a minimal set of helpers, e.g. the Safe factory addresses.

While it's true that Safe is a generic type of wallet, that doesn't mean that running fork tests against the actual deployed contracts wouldn't give greater confidence that the protocol behaves as expected.

For instance, our protocol uses a different proxy system (PRBProxy) compared to Safe, and so we would find it helpful to check that Safe is compatible with this other proxy.

Also, do you have examples of such SDKs?

"SDK" was a stretch - what I meant was test utils. See PRBProxy and Permit2:

@PaulRBerg
Copy link
Author

It looks like this might be what I was looking for?

https://github.com/ind-igo/forge-safe

farreldarian pushed a commit to farreldarian/safe-contracts that referenced this issue Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants