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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Tests/web3swiftTests/remoteTests/ENSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import Web3Core
class ENSTests: XCTestCase {

func testDomainNormalization() throws {
let normalizedString = NameHash.normalizeDomainName("example.ens")

let normalizedString = NameHash.normalizeDomainName("Example.ENS")
XCTAssertEqual(normalizedString, "example.ens")
}

func testNameHash() throws {
Expand Down Expand Up @@ -79,10 +79,10 @@ class ENSTests: XCTestCase {

func testTTL() async throws {
let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
let ens = ENS(web3: web3)
let ens = try XCTUnwrap(ENS(web3: web3))
let domain = "somename.eth"
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

}

func testGetAddress() async throws {
Expand Down