-
Notifications
You must be signed in to change notification settings - Fork 45
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
Ens hook unittest #280
Ens hook unittest #280
Conversation
* new safeUtil for mocking a connected gnosis safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is very nice! Looks like a lot of scaffolding, but I presume - now that its here - some of it can be reused for future tests.
Very nice clean code introduced here! 🎸
const resolvedAddress = | ||
typeof cachedAddress !== "undefined" ? cachedAddress : await web3Provider.resolveName(ensName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like introducing the tests revealed a potential bug here... or was this just an adaption to accommodate the test itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null was not cached. So names which can't be resolved where retried and not cached.
@@ -3,7 +3,7 @@ import { SafeInfo } from "@gnosis.pm/safe-apps-sdk"; | |||
import { TokenInfo } from "../utils"; | |||
|
|||
const dummySafeInfo: SafeInfo = { | |||
safeAddress: "0x123", | |||
safeAddress: "0x1230000000000000000000000000000000000000", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, I had a feeling this wouldn't last like this. Glad the test picked it up.
I checked out how exactly the gnosis SafeProvider gets the safe info when to be able to write Unit Tests for our components / hooks.
This PR provides 100% test coverage for our ens hook as a proof of concept.
I refactored the SafeInfo Mock Code into a new test util file.
This enables us to unit test all our hooks. Its a bit ugly because we have to write test components which use our hooks but AFAIK its the only way to do this.