|
| 1 | +// |
| 2 | +// EIP1559Tests.swift |
| 3 | +// |
| 4 | +// |
| 5 | +// Created by Jann Driessen on 01.11.22. |
| 6 | +// |
| 7 | + |
| 8 | +import XCTest |
| 9 | +import Core |
| 10 | + |
| 11 | +@testable import web3swift |
| 12 | + |
| 13 | +final class EIP1559Tests: XCTestCase { |
| 14 | + |
| 15 | + func testEIP1159MainnetTransaction() async throws { |
| 16 | + let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) |
| 17 | + var tx = CodableTransaction( |
| 18 | + type: .eip1559, |
| 19 | + to: EthereumAddress("0xb47292B7bBedA4447564B8336E4eD1f93735e7C7")!, |
| 20 | + chainID: web3.provider.network!.chainID, |
| 21 | + value: Utilities.parseToBigUInt("0.1", units: .eth)!, |
| 22 | + gasLimit: 21_000 |
| 23 | + ) |
| 24 | + // Vitalik's address |
| 25 | + tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")! |
| 26 | + // Should fail if there would be something wrong with the tx |
| 27 | + let res = try await web3.eth.estimateGas(for: tx) |
| 28 | + XCTAssertGreaterThan(res, 0) |
| 29 | + } |
| 30 | + |
| 31 | + func testEIP1159GoerliTransaction() async throws { |
| 32 | + let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken) |
| 33 | + var tx = CodableTransaction( |
| 34 | + type: .eip1559, |
| 35 | + to: EthereumAddress("0xeBec795c9c8bBD61FFc14A6662944748F299cAcf")!, |
| 36 | + chainID: web3.provider.network!.chainID, |
| 37 | + value: Utilities.parseToBigUInt("0.1", units: .eth)!, |
| 38 | + gasLimit: 21_000 |
| 39 | + ) |
| 40 | + // Vitalik's address |
| 41 | + tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")! |
| 42 | + // Should fail if there would be something wrong with the tx |
| 43 | + let res = try await web3.eth.estimateGas(for: tx) |
| 44 | + XCTAssertGreaterThan(res, 0) |
| 45 | + } |
| 46 | + |
| 47 | +} |
0 commit comments