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

ENSTests added assertions #722

Merged

Conversation

albertopeam
Copy link
Contributor

Summary of Changes

Added assertions to ENSTests, related to #716

testDomainNormalization lacks the assertion, easy to fix.
testTTL lacks also the assertion, I were checking EIP137 and doing some checks with other lib(web3js) and the TTL was zero for "somename.eth". The point here to add this assertion is:

  1. ttl will be 0 or greater
  2. if something fails it will trigger an exception
    The only way to verify a non zero TTL is to change the cache time(TTL) via setter and then run the getter, but being in the mainnet it will generate costs in terms of eth. What do you think?

Test Data or Screenshots

By submitting this pull request, you are confirming the following:
  • I have reviewed the Contribution Guidelines.
  • I have performed a self-review of my own code.
  • I have updated my repository to match the develop branch.
  • I have included test data or screenshots that prove my fix is effective or that my feature works.
  • I have checked that all tests work and swiftlint is not throwing any errors/warnings.

let ttl = try await ens?.registry.getTTL(node: domain)

let ttl = try await ens.registry.getTTL(node: domain)
XCTAssertGreaterThanOrEqual(ttl, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your explanation makes sense here. Just one question so since it's try and the test function throws, this test would fail if there is an issue with getting the TTL for the domain, correct?

Copy link
Contributor Author

@albertopeam albertopeam Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, getTTL will throw if arises any issue:

  1. if nameHash couldn't be obtained
  2. if transaction couldn't be created
  3. if calling contract the result is nil
  4. if the result doesn't contain "0" key

Captura de Pantalla 2023-01-05 a las 15 32 55

Copy link
Collaborator

@janndriessen janndriessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you. 🙏

@JeneaVranceanu JeneaVranceanu merged commit aca53e5 into web3swift-team:develop Jan 10, 2023
@albertopeam albertopeam deleted the feature/ENSTests-warnings branch January 11, 2023 21:55
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.

3 participants