Skip to content

Commit

Permalink
Broken tests fixed:
Browse files Browse the repository at this point in the history
- Goerli gateway returns 403 now
- "https://rpc-mainnet.maticvigil.com/" returns 410 now
- `testInitURLError` shouldn't be working since there's always valid URL built within the client method itself, but it fails on empty data (wrong place).
  • Loading branch information
yaroslavyaroslav committed Sep 29, 2024
1 parent 4359267 commit 8a02610
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
20 changes: 2 additions & 18 deletions Tests/web3swiftTests/remoteTests/EIP1559Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,7 @@ final class EIP1559Tests: XCTestCase {
type: .eip1559,
to: EthereumAddress("0xb47292B7bBedA4447564B8336E4eD1f93735e7C7")!,
chainID: web3.provider.network!.chainID,
value: try XCTUnwrap(Utilities.parseToBigUInt("0.1", units: .ether)),
gasLimit: 21_000
)
// Vitalik's address
tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")!
// Should fail if there would be something wrong with the tx
let res = try await web3.eth.estimateGas(for: tx)
XCTAssertGreaterThan(res, 0)
}

func testEIP1159GoerliTransaction() async throws {
let web3 = try await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken)
var tx = CodableTransaction(
type: .eip1559,
to: EthereumAddress("0xeBec795c9c8bBD61FFc14A6662944748F299cAcf")!,
chainID: web3.provider.network!.chainID,
value: try XCTUnwrap(Utilities.parseToBigUInt("0.1", units: .ether)),
gasLimit: 21_000
value: try XCTUnwrap(Utilities.parseToBigUInt("0.1", units: .ether))
)
// Vitalik's address
tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")!
Expand All @@ -45,4 +28,5 @@ final class EIP1559Tests: XCTestCase {
XCTAssertGreaterThan(res, 0)
}

// MARK: Here was Goerli network test, but now gateway returns 410
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ final class EtherscanTransactionCheckerTests: XCTestCase {
}
}

func testInitURLError() async throws {
do {
let sut = EtherscanTransactionChecker(urlSession: URLSessionMock(), apiKey: " ")

_ = try await sut.hasTransactions(ethereumAddress: try XCTUnwrap(EthereumAddress(vitaliksAddress)))

XCTFail("URL init must throw an error")
} catch EtherscanTransactionCheckerError.invalidUrl {
XCTAssertTrue(true)
}
}

func testWrongApiKey() async throws {
do {
let sut = EtherscanTransactionChecker(urlSession: URLSession.shared, apiKey: "-")
Expand Down
3 changes: 0 additions & 3 deletions Tests/web3swiftTests/remoteTests/Web3HttpProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ final class Web3HttpProviderTests: XCTestCase {
web3 = try await Web3HttpProvider(url: URL(string: "https://rpc.ankr.com/bsc")!, network: nil)
XCTAssertEqual(web3.network?.chainID, 56)

web3 = try await Web3HttpProvider(url: URL(string: "https://rpc-mainnet.maticvigil.com/")!, network: nil)
XCTAssertEqual(web3.network?.chainID, 137)

web3 = try await Web3HttpProvider(url: URL(string: "https://optimism.gateway.tenderly.co")!, network: nil)
XCTAssertEqual(web3.network?.chainID, 10)
}
Expand Down

0 comments on commit 8a02610

Please sign in to comment.