Skip to content

Commit 17d33db

Browse files
Merge pull request #485 from yaroslavyaroslav/ganache-tests
2 parents f665a7c + 5b35c78 commit 17d33db

32 files changed

+599
-543
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@ jobs:
3232
run: swift package resolve
3333
- name: Build
3434
run: swift build --build-tests
35-
# - name: Run local tests
36-
# run: swift test --skip-build -c debug --filter localTests
35+
- name: Install ganache
36+
run: npm install ganache --global
37+
- name: Start ganache in background
38+
run: ganache &
39+
- name: Wait till ganache starts
40+
run: sleep 1
41+
- name: Run local tests
42+
run: swift test --skip-build -c debug --filter localTests
43+
# - name: Run remote tests
44+
# run: swift test --skip-build -c debug --filter remoteTests
3745
carthage:
3846
name: Carthage
3947
runs-on: macOS-11
@@ -53,5 +61,13 @@ jobs:
5361
run: carthage build --no-use-binaries --platform iOS Simulator --use-xcframeworks
5462
- name: Building framework
5563
run: xcodebuild build-for-testing -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan LocalTests
56-
# - name: Running local tests
57-
# run: xcodebuild test-without-building -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan LocalTests
64+
- name: Install ganache
65+
run: npm install ganache --global
66+
- name: Start ganache in background
67+
run: ganache &
68+
- name: Wait till ganache starts
69+
run: sleep 1
70+
- name: Run local tests
71+
run: xcodebuild test-without-building -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan LocalTests
72+
# - name: Run remote tests
73+
# run: xcodebuild test-without-building -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan RemoteTests

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let package = Package(
4242
.testTarget(
4343
name: "localTests",
4444
dependencies: ["web3swift"],
45-
path: "Tests/web3swiftTests/local_tests",
45+
path: "Tests/web3swiftTests/localTests",
4646
resources: [
4747
.copy("../../../TestToken/Helpers/SafeMath/SafeMath.sol"),
4848
.copy("../../../TestToken/Helpers/TokenBasics/ERC20.sol"),
@@ -53,7 +53,7 @@ let package = Package(
5353
.testTarget(
5454
name: "remoteTests",
5555
dependencies: ["web3swift"],
56-
path: "Tests/web3swiftTests/infura_tests",
56+
path: "Tests/web3swiftTests/remoteTests",
5757
resources: [
5858
.copy("../../../TestToken/Helpers/SafeMath/SafeMath.sol"),
5959
.copy("../../../TestToken/Helpers/TokenBasics/ERC20.sol"),

Tests/web3swiftTests/local_tests/LocalTests.xctestplan renamed to Tests/web3swiftTests/localTests/LocalTests.xctestplan

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"testTargets" : [
1515
{
1616
"skippedTests" : [
17+
"web3swiftENSTests",
18+
"web3swiftGanacheTests",
19+
"web3swiftRemoteParsingTests",
20+
"web3swiftST20AndSecurityTokenTests",
21+
"web3swiftWebsocketTests",
1722
"web3swift_ENS_Tests",
1823
"web3swift_ST20AndSecurityToken_Tests",
1924
"web3swift_infura_Tests",

Tests/web3swiftTests/local_tests/web3swift_AdvancedABIv2_Tests.swift renamed to Tests/web3swiftTests/localTests/web3swiftAdvancedABIv2Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import BigInt
1010

1111
@testable import web3swift
1212

13-
class web3swift_AdvancedABIv2_Tests: XCTestCase {
13+
class web3swiftAdvancedABIv2Tests: XCTestCase {
1414

1515
func testAdvancedABIv2() throws {
1616
let abiString = "[{\"constant\":true,\"inputs\":[],\"name\":\"testDynOfDyn\",\"outputs\":[{\"name\":\"ts\",\"type\":\"string[]\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"testStOfDyn\",\"outputs\":[{\"name\":\"ts\",\"type\":\"string[2]\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"testDynArray\",\"outputs\":[{\"components\":[{\"name\":\"number\",\"type\":\"uint256\"},{\"name\":\"someText\",\"type\":\"string\"},{\"name\":\"staticArray\",\"type\":\"uint256[2]\"},{\"name\":\"dynamicArray\",\"type\":\"uint256[]\"},{\"name\":\"anotherDynamicArray\",\"type\":\"string[2]\"}],\"name\":\"ts\",\"type\":\"tuple[]\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"testStaticArray\",\"outputs\":[{\"components\":[{\"name\":\"number\",\"type\":\"uint256\"},{\"name\":\"someText\",\"type\":\"string\"},{\"name\":\"staticArray\",\"type\":\"uint256[2]\"},{\"name\":\"dynamicArray\",\"type\":\"uint256[]\"},{\"name\":\"anotherDynamicArray\",\"type\":\"string[2]\"}],\"name\":\"ts\",\"type\":\"tuple[2]\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"testSingle\",\"outputs\":[{\"components\":[{\"name\":\"number\",\"type\":\"uint256\"},{\"name\":\"someText\",\"type\":\"string\"},{\"name\":\"staticArray\",\"type\":\"uint256[2]\"},{\"name\":\"dynamicArray\",\"type\":\"uint256[]\"},{\"name\":\"anotherDynamicArray\",\"type\":\"string[2]\"}],\"name\":\"t\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]"

Tests/web3swiftTests/local_tests/web3swift_basic_local_node_Tests.swift renamed to Tests/web3swiftTests/localTests/web3swiftBasicLocalNodeTests.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import BigInt
1111

1212
@testable import web3swift
1313

14-
class web3swift_basic_local_node_Tests: XCTestCase {
14+
class web3swiftBasicLocalNodeTests: XCTestCase {
1515

1616
func testDeployWithRemoteSigning() throws {
1717
let web3 = try Web3.new(URL.init(string: "http://127.0.0.1:8545")!)
@@ -95,14 +95,15 @@ class web3swift_basic_local_node_Tests: XCTestCase {
9595
}
9696

9797
// FIXME: Crashes on CI/CD
98-
func testSignPersonal() throws {
99-
let web3 = try Web3.new(URL.init(string: "http://127.0.0.1:8545")!)
100-
let allAddresses = try web3.eth.getAccounts()
98+
// FIXME: Fails on ganache
99+
// func testSignPersonal() throws {
100+
// let web3 = try Web3.new(URL.init(string: "http://127.0.0.1:8545")!)
101+
// let allAddresses = try web3.eth.getAccounts()
101102

102-
let response = try web3.personal.signPersonalMessage(message: "hello world".data(using: .utf8)!, from: allAddresses[0])
103+
// let response = try web3.personal.signPersonalMessage(message: "hello world".data(using: .utf8)!, from: allAddresses[0])
103104

104-
XCTAssert(response.toHexString() == "b686c8ddc854bd49de9eb62eb4e52af4c69a89802b40fe9a295e346b111406393c6e3f05114561ab845a47196ad22c33cec67592af9a9e42bfc067a20c7d4b6101")
105-
}
105+
// XCTAssert(response.toHexString() == "b686c8ddc854bd49de9eb62eb4e52af4c69a89802b40fe9a295e346b111406393c6e3f05114561ab845a47196ad22c33cec67592af9a9e42bfc067a20c7d4b6101")
106+
// }
106107

107108
// MARK: Ganache doesn't support a mempool for now
108109
// func testTxPoolStatus() throws {

Tests/web3swiftTests/local_tests/web3swift_EIP67_Tests.swift renamed to Tests/web3swiftTests/localTests/web3swiftEIP67Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import BigInt
1010

1111
@testable import web3swift
1212

13-
class web3swift_EIP67_Tests: XCTestCase {
13+
class web3swiftEIP67Tests: XCTestCase {
1414

1515
func testEIP67encoding() throws {
1616
var eip67Data = Web3.EIP67Code.init(address: EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!)

Tests/web3swiftTests/local_tests/web3swift_EIP681_Tests.swift renamed to Tests/web3swiftTests/localTests/web3swiftEIP681Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import XCTest
88
@testable import web3swift
99

10-
class web3swift_EIP681_Tests: XCTestCase {
10+
class web3swiftEIP681Tests: XCTestCase {
1111

1212
//Custom payment
1313
//ethereum:0xfb6916095ca1df60bb79Ce92ce3ea74c37c5d359?value=2.014e18

Tests/web3swiftTests/local_tests/web3swift_ERC20_Class_Tests.swift renamed to Tests/web3swiftTests/localTests/web3swiftERC20ClassTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import BigInt
99

1010
@testable import web3swift
1111

12-
class web3swift_ERC20_Class_Tests: XCTestCase {
12+
class web3swiftERC20ClassTests: XCTestCase {
1313

1414
func testERC20TokenCreation() throws {
15-
let (web3, _, receipt, _) = try web3swift_helpers.localDeployERC20()
15+
let (web3, _, receipt, _) = try web3swiftHelpers.localDeployERC20()
1616
let erc20token = ERC20.init(web3: web3, provider: web3.provider, address: receipt.contractAddress!)
1717
erc20token.readProperties()
1818
XCTAssert(erc20token.symbol == "w3s")
@@ -21,7 +21,7 @@ class web3swift_ERC20_Class_Tests: XCTestCase {
2121
}
2222

2323
func testERC20tokenBalanceAndAllowance() throws {
24-
let (web3, _, receipt, _) = try web3swift_helpers.localDeployERC20()
24+
let (web3, _, receipt, _) = try web3swiftHelpers.localDeployERC20()
2525
let erc20token = ERC20.init(web3: web3, provider: web3.provider, address: receipt.contractAddress!)
2626

2727
let userAddress = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!

0 commit comments

Comments
 (0)