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

Ens hook unittest #280

Merged
merged 2 commits into from
Nov 17, 2021
Merged

Ens hook unittest #280

merged 2 commits into from
Nov 17, 2021

Conversation

schmanu
Copy link
Collaborator

@schmanu schmanu commented Nov 14, 2021

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.

* new safeUtil for mocking a connected gnosis safe
@schmanu schmanu requested a review from bh2smith November 14, 2021 13:29
Copy link
Owner

@bh2smith bh2smith left a 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! 🎸

Comment on lines +41 to +42
const resolvedAddress =
typeof cachedAddress !== "undefined" ? cachedAddress : await web3Provider.resolveName(ensName);
Copy link
Owner

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?

Copy link
Collaborator Author

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",
Copy link
Owner

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.

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

Successfully merging this pull request may close these issues.

2 participants