Skip to content

Commit c3376c5

Browse files
authored
Merge pull request #336 from argentlabs/issue/locking-async-await
[FIX] Remove potential deadlock when using async-await. Provide network at client initialization instead
2 parents 7d7428d + 03dc1d8 commit c3376c5

24 files changed

+60
-68
lines changed

web3sTests/Client/EthereumClientTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class EthereumClientTests: XCTestCase {
3535

3636
override func setUp() {
3737
super.setUp()
38-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
38+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
3939
account = try? EthereumAccount(keyStorage: TestEthereumKeyStorage(privateKey: TestConfig.privateKey))
4040
}
4141

@@ -435,14 +435,14 @@ class EthereumWebSocketClientTests: EthereumClientTests {
435435

436436
override func setUp() {
437437
super.setUp()
438-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
438+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
439439

440440
}
441441
#if os(Linux)
442442
// On Linux some tests are fail. Need investigation
443443
#else
444444
func testWebSocketNoAutomaticOpen() {
445-
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: .init(automaticOpen: false))
445+
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: .init(automaticOpen: false), network: TestConfig.network)
446446

447447
guard let client = client as? EthereumWebSocketClient else {
448448
XCTFail("Expected client to be EthereumWebSocketClient")
@@ -453,7 +453,7 @@ class EthereumWebSocketClientTests: EthereumClientTests {
453453
}
454454

455455
func testWebSocketConnect() {
456-
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: .init(automaticOpen: false))
456+
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: .init(automaticOpen: false), network: TestConfig.network)
457457

458458
guard let client = client as? EthereumWebSocketClient else {
459459
XCTFail("Expected client to be EthereumWebSocketClient")

web3sTests/Contract/ABIEventTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ABIEventTests: XCTestCase {
1212

1313
override func setUp() {
1414
super.setUp()
15-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
15+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
1616
}
1717

1818
func test_givenEventWithData4_ItParsesCorrectly() async {
@@ -60,7 +60,7 @@ class ABIEventTests: XCTestCase {
6060
class ABIEventWebSocketTests: ABIEventTests {
6161
override func setUp() {
6262
super.setUp()
63-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
63+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
6464
}
6565
}
6666

web3sTests/ENS/ENSOffchainTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ENSOffchainTests: XCTestCase {
1212

1313
override func setUp() {
1414
super.setUp()
15-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
15+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
1616
}
1717

1818
func testDNSEncode() {
@@ -149,6 +149,6 @@ class ENSOffchainTests: XCTestCase {
149149
class ENSOffchainWebSocketTests: ENSOffchainTests {
150150
override func setUp() {
151151
super.setUp()
152-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
152+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
153153
}
154154
}

web3sTests/ENS/ENSTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class ENSTests: XCTestCase {
363363
class ENSWebSocketTests: ENSTests {
364364
override func setUp() {
365365
super.setUp()
366-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
367-
mainnetClient = EthereumWebSocketClient(url: URL(string: TestConfig.wssMainnetUrl)!, configuration: TestConfig.webSocketConfig)
366+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
367+
mainnetClient = EthereumWebSocketClient(url: URL(string: TestConfig.wssMainnetUrl)!, configuration: TestConfig.webSocketConfig, network: .mainnet)
368368
}
369369
}

web3sTests/ERC1271/ERC1271Tests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ERC1271Tests: XCTestCase {
1313
override func setUp() {
1414
super.setUp()
1515
if self.client == nil {
16-
self.client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
16+
self.client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
1717
}
1818
self.erc1271 = ERC1271(client: self.client)
1919
}
@@ -105,7 +105,7 @@ final class ERC1271WebSocketTests: ERC1271Tests {
105105

106106
override func setUp() {
107107
if self.client == nil {
108-
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!)
108+
self.client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, network: TestConfig.network)
109109
}
110110
super.setUp()
111111
}

web3sTests/ERC165/ERC165Tests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ERC165Tests: XCTestCase {
1515

1616
override func setUp() {
1717
super.setUp()
18-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
18+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
1919
erc165 = ERC165(client: client)
2020
}
2121

@@ -54,6 +54,6 @@ class ERC165Tests: XCTestCase {
5454
class ERC165WebSocketTests: ERC165Tests {
5555
override func setUp() {
5656
super.setUp()
57-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
57+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
5858
}
5959
}

web3sTests/ERC20/ERC20Tests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ERC20Tests: XCTestCase {
1414

1515
override func setUp() {
1616
super.setUp()
17-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
17+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
1818
erc20 = ERC20(client: client!)
1919
}
2020

@@ -114,6 +114,6 @@ class ERC20Tests: XCTestCase {
114114
class ERC20WebSocketTests: ERC20Tests {
115115
override func setUp() {
116116
super.setUp()
117-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
117+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
118118
}
119119
}

web3sTests/ERC721/ERC721Tests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ERC721Tests: XCTestCase {
2424

2525
override func setUp() {
2626
super.setUp()
27-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
27+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
2828
erc721 = ERC721(client: client)
2929
}
3030

@@ -111,7 +111,7 @@ class ERC721MetadataTests: XCTestCase {
111111

112112
override func setUp() {
113113
super.setUp()
114-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
114+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
115115
erc721 = ERC721Metadata(client: client, metadataSession: URLSession.shared)
116116
}
117117

@@ -163,7 +163,7 @@ class ERC721EnumerableTests: XCTestCase {
163163

164164
override func setUp() {
165165
super.setUp()
166-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
166+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
167167
erc721 = ERC721Enumerable(client: client)
168168
}
169169

@@ -211,20 +211,20 @@ class ERC721EnumerableTests: XCTestCase {
211211
class ERC721WebSocketTests: ERC721Tests {
212212
override func setUp() {
213213
super.setUp()
214-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
214+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
215215
}
216216
}
217217

218218
class ERC721MetadataWebSocketTests: ERC721MetadataTests {
219219
override func setUp() {
220220
super.setUp()
221-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
221+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
222222
}
223223
}
224224

225225
class ERC721EnumerableWebSocketTests: ERC721EnumerableTests {
226226
override func setUp() {
227227
super.setUp()
228-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
228+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
229229
}
230230
}

web3sTests/Multicall/MulticallTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MulticallTests: XCTestCase {
1313

1414
override func setUp() {
1515
super.setUp()
16-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
16+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
1717
multicall = Multicall(client: client!)
1818
}
1919

@@ -83,6 +83,6 @@ class MulticallTests: XCTestCase {
8383
class MulticallWebSocketTests: MulticallTests {
8484
override func setUp() {
8585
super.setUp()
86-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
86+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
8787
}
8888
}

web3sTests/OffchainLookup/OffchainLookupTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class OffchainLookupTests: XCTestCase {
145145

146146
override func setUp() {
147147
super.setUp()
148-
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!)
148+
client = EthereumHttpClient(url: URL(string: TestConfig.clientUrl)!, network: TestConfig.network)
149149
account = try? EthereumAccount(keyStorage: TestEthereumKeyStorage(privateKey: TestConfig.privateKey))
150150
}
151151

@@ -331,6 +331,6 @@ private func expectedResponse(
331331
class OffchainLookupWebSocketTests: OffchainLookupTests {
332332
override func setUp() {
333333
super.setUp()
334-
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig)
334+
client = EthereumWebSocketClient(url: URL(string: TestConfig.wssUrl)!, configuration: TestConfig.webSocketConfig, network: TestConfig.network)
335335
}
336336
}

0 commit comments

Comments
 (0)