Skip to content

Commit 5a22432

Browse files
committed
Use guard
1 parent ba32a39 commit 5a22432

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

Tests/NetworkTests/Providers/ProviderTests.swift

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,29 @@ final class ProviderTests: XCTestCase {
1717
}
1818

1919
func testGetBlockWithTxsWithL1AcceptedBlockTag() async throws {
20-
let result = try await provider.send(request: RequestBuilder.getBlockWithTxs(StarknetBlockId.BlockTag.latest))
21-
switch result {
22-
case .processed:
23-
// Expected
24-
break
25-
default:
26-
XCTFail("Expected result to be of type .l1Accepted block tag")
20+
let result = try await provider.send(request: RequestBuilder.getBlockWithTxs(StarknetBlockId.BlockTag.l1Accepted))
21+
22+
guard case .processed = result else {
23+
XCTFail("Expected result to be of type .processed")
24+
return
2725
}
2826
}
2927

3028
func testGetBlockWithTxsWithLatestBlockTag() async throws {
3129
let result = try await provider.send(request: RequestBuilder.getBlockWithTxs(StarknetBlockId.BlockTag.latest))
32-
switch result {
33-
case .processed:
34-
// Expected
35-
break
36-
default:
37-
XCTFail("Expected result to be of type .processed block tag")
30+
31+
guard case .processed = result else {
32+
XCTFail("Expected result to be of type .processed")
33+
return
3834
}
3935
}
4036

4137
func testGetBlockWithTxsWithPreConfirmedBlockTag() async throws {
4238
let result = try await provider.send(request: RequestBuilder.getBlockWithTxs(StarknetBlockId.BlockTag.preConfirmed))
43-
switch result {
44-
case .preConfirmed:
45-
// Expected
46-
break
47-
default:
48-
XCTFail("Expected result to be of type .preConfirmed block tag")
39+
40+
guard case .processed = result else {
41+
XCTFail("Expected result to be of type .preConfirmed")
42+
return
4943
}
5044
}
5145

0 commit comments

Comments
 (0)