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

Sign-In with Ethereum + ERC1271 #246

Merged
merged 8 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions web3sTests/ERC1271/ERC1271Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import XCTest
@testable import web3

final class ERC1271Tests: XCTestCase {
class ERC1271Tests: XCTestCase {
var client: EthereumClientProtocol!
var erc1271: ERC1271!

override func setUp() {
super.setUp()
self.client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
if self.client == nil {
self.client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
}
self.erc1271 = ERC1271(client: self.client)
}

Expand Down Expand Up @@ -100,3 +102,13 @@ final class ERC1271Tests: XCTestCase {
}
}
}

final class ERC1271WSSTests: ERC1271Tests {
dioKaratzas marked this conversation as resolved.
Show resolved Hide resolved

override func setUp() {
if self.client == nil {
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!)
}
super.setUp()
}
}
24 changes: 22 additions & 2 deletions web3sTests/SIWE/SIWETests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@
import XCTest
@testable import web3

final class SIWETests: XCTestCase {
class SIWETests: XCTestCase {

var client: EthereumClientProtocol!
var verifier: SiweVerifier!

override func setUp() {
super.setUp()
if self.client == nil {
self.client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
}
self.verifier = SiweVerifier(client: self.client)
}

func testEndToEnd() async {
let verifier = SiweVerifier(client: EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!))
let account = try! EthereumAccount.init(keyStorage: TestEthereumKeyStorage(privateKey: "0x4646464646464646464646464646464646464646464646464646464646464646"))
let message = try! SiweMessage(
"""
Expand Down Expand Up @@ -45,3 +55,13 @@ final class SIWETests: XCTestCase {
}
}
}

final class SIWEWSSTests: SIWETests {
dioKaratzas marked this conversation as resolved.
Show resolved Hide resolved

override func setUp() {
if self.client == nil {
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!)
}
super.setUp()
}
}
22 changes: 20 additions & 2 deletions web3sTests/SIWE/SiweVerifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
import XCTest
@testable import web3

final class SiweVerifierTests: XCTestCase {
let client: EthereumHttpClient = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
class SiweVerifierTests: XCTestCase {

var client: EthereumClientProtocol!

override func setUp() {
super.setUp()
if self.client == nil {
self.client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
}
}

func testNetworkVerification() async {
let verifier = SiweVerifier(client: client, dateProvider: { Date(timeIntervalSince1970: 1_655_110_800.0) })
Expand Down Expand Up @@ -215,3 +223,13 @@ final class SiweVerifierTests: XCTestCase {
}
}
}

final class SiweVerifierWSSTests: SiweVerifierTests {
dioKaratzas marked this conversation as resolved.
Show resolved Hide resolved

override func setUp() {
if self.client == nil {
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!)
}
super.setUp()
}
}