6
6
7
7
import XCTest
8
8
import BigInt
9
+ import Core
9
10
10
11
@testable import web3swift
11
12
12
- class EIP681Tests : LocalTestCase {
13
+ class EIP681Tests : XCTestCase {
13
14
14
- func testParsing( ) throws {
15
+ func testParsing( ) async throws {
15
16
let testAddress = " 0x5ffc014343cd971b7eb70732021e26c35b744cc4 "
16
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) ?value=2.014e18 " )
17
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) ?value=2.014e18 " )
17
18
XCTAssert ( eip681Code != nil )
18
19
guard let eip681Code = eip681Code else { return }
19
20
switch eip681Code. targetAddress {
@@ -26,9 +27,9 @@ class EIP681Tests: LocalTestCase {
26
27
XCTAssertEqual ( eip681Code. amount, BigUInt ( 2014000000000000000 ) )
27
28
}
28
29
29
- func testParsingWithEncoding( ) throws {
30
+ func testParsingWithEncoding( ) async throws {
30
31
let testAddress = " 0x5ffc014343cd971b7eb70732021e26c35b744cc4 "
31
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) ?value=2.014e18 " . addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
32
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) ?value=2.014e18 " . addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
32
33
XCTAssert ( eip681Code != nil )
33
34
guard let eip681Code = eip681Code else { return }
34
35
switch eip681Code. targetAddress {
@@ -40,9 +41,9 @@ class EIP681Tests: LocalTestCase {
40
41
XCTAssertEqual ( eip681Code. amount, BigUInt ( 2014000000000000000 ) )
41
42
}
42
43
43
- func testParsing2( ) throws {
44
+ func testParsing2( ) async throws {
44
45
let testAddress = " 0x8932404A197D84Ec3Ea55971AADE11cdA1dddff1 "
45
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=0x6891dC3962e710f0ff711B9c6acc26133Fd35Cb4&uint256=1 " )
46
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=0x6891dC3962e710f0ff711B9c6acc26133Fd35Cb4&uint256=1 " )
46
47
XCTAssert ( eip681Code != nil )
47
48
guard let eip681Code = eip681Code else { return }
48
49
switch eip681Code. targetAddress {
@@ -60,9 +61,9 @@ class EIP681Tests: LocalTestCase {
60
61
XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
61
62
}
62
63
63
- func testParsing2WithEncoding( ) throws {
64
+ func testParsing2WithEncoding( ) async throws {
64
65
let testAddress = " 0x8932404A197D84Ec3Ea55971AADE11cdA1dddff1 "
65
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=0x6891dC3962e710f0ff711B9c6acc26133Fd35Cb4&uint256=1 "
66
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=0x6891dC3962e710f0ff711B9c6acc26133Fd35Cb4&uint256=1 "
66
67
. addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
67
68
XCTAssert ( eip681Code != nil )
68
69
guard let eip681Code = eip681Code else { return }
@@ -81,9 +82,9 @@ class EIP681Tests: LocalTestCase {
81
82
XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
82
83
}
83
84
84
- func testENSParsing( ) throws {
85
+ func testENSParsing( ) async throws {
85
86
let testAddress = " somename.eth "
86
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=somename.eth&uint256=1 " )
87
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=somename.eth&uint256=1 " )
87
88
XCTAssert ( eip681Code != nil )
88
89
guard let eip681Code = eip681Code else { return }
89
90
switch eip681Code. targetAddress {
@@ -103,9 +104,9 @@ class EIP681Tests: LocalTestCase {
103
104
XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
104
105
}
105
106
106
- func testENSParsingWithEncoding( ) throws {
107
+ func testENSParsingWithEncoding( ) async throws {
107
108
let testAddress = " somename.eth "
108
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=somename.eth&uint256=1 " . addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
109
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) /transfer?address=somename.eth&uint256=1 " . addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
109
110
XCTAssert ( eip681Code != nil )
110
111
guard let eip681Code = eip681Code else { return }
111
112
switch eip681Code. targetAddress {
@@ -125,10 +126,10 @@ class EIP681Tests: LocalTestCase {
125
126
XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
126
127
}
127
128
128
- func testParsingOfArrayOfBytesAsParameter( ) throws {
129
+ func testParsingOfArrayOfBytesAsParameter( ) async throws {
129
130
let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
130
131
let chainID = BigUInt ( 2828 )
131
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /setData?bytes32[]=[0x4b80742de2bf82acb3630000005e9F5BB83481d5627aA8c48527C174579bC428,0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3,0xdf30dba06db6a30e65354d9a64c6098600000000000000000000000000000004]&bytes[]=[0x0000000000000000000000000000000000000000000000000000000000000038,0x0000000000000000000000000000000000000000000000000000000000000004,0x005e9F5BB83481d5627aA8c48527C174579bC428] " )
132
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /setData?bytes32[]=[0x4b80742de2bf82acb3630000005e9F5BB83481d5627aA8c48527C174579bC428,0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3,0xdf30dba06db6a30e65354d9a64c6098600000000000000000000000000000004]&bytes[]=[0x0000000000000000000000000000000000000000000000000000000000000038,0x0000000000000000000000000000000000000000000000000000000000000004,0x005e9F5BB83481d5627aA8c48527C174579bC428] " )
132
133
XCTAssert ( eip681Code != nil )
133
134
guard let eip681Code = eip681Code else { return }
134
135
switch eip681Code. targetAddress {
@@ -155,10 +156,10 @@ class EIP681Tests: LocalTestCase {
155
156
XCTAssertEqual ( data ? [ 2 ] , Data . fromHex ( " 0x005e9F5BB83481d5627aA8c48527C174579bC428 " ) !)
156
157
}
157
158
158
- func testParsingOfArrayOfBytesAsParameterWithEncoding( ) throws {
159
+ func testParsingOfArrayOfBytesAsParameterWithEncoding( ) async throws {
159
160
let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
160
161
let chainID = BigUInt ( 2828 )
161
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /setData?bytes32[]=[0x4b80742de2bf82acb3630000005e9F5BB83481d5627aA8c48527C174579bC428,0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3,0xdf30dba06db6a30e65354d9a64c6098600000000000000000000000000000004]&bytes[]=[0x0000000000000000000000000000000000000000000000000000000000000038,0x0000000000000000000000000000000000000000000000000000000000000004,0x005e9F5BB83481d5627aA8c48527C174579bC428] " . addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
162
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /setData?bytes32[]=[0x4b80742de2bf82acb3630000005e9F5BB83481d5627aA8c48527C174579bC428,0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3,0xdf30dba06db6a30e65354d9a64c6098600000000000000000000000000000004]&bytes[]=[0x0000000000000000000000000000000000000000000000000000000000000038,0x0000000000000000000000000000000000000000000000000000000000000004,0x005e9F5BB83481d5627aA8c48527C174579bC428] " . addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
162
163
XCTAssert ( eip681Code != nil )
163
164
guard let eip681Code = eip681Code else { return }
164
165
switch eip681Code. targetAddress {
@@ -185,10 +186,10 @@ class EIP681Tests: LocalTestCase {
185
186
XCTAssertEqual ( data ? [ 2 ] , Data . fromHex ( " 0x005e9F5BB83481d5627aA8c48527C174579bC428 " ) !)
186
187
}
187
188
188
- func testParsingOfArrayOfIntAsParameter( ) throws {
189
+ func testParsingOfArrayOfIntAsParameter( ) async throws {
189
190
let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
190
191
let chainID = BigUInt ( 2828 )
191
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /functionName123?int256[]=[1,2,5000,3,4,10000] " )
192
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /functionName123?int256[]=[1,2,5000,3,4,10000] " )
192
193
XCTAssert ( eip681Code != nil )
193
194
guard let eip681Code = eip681Code else { return }
194
195
switch eip681Code. targetAddress {
@@ -207,10 +208,10 @@ class EIP681Tests: LocalTestCase {
207
208
XCTAssertEqual ( data, Array < BigInt > ( arrayLiteral: 1 , 2 , 5000 , 3 , 4 , 10000 ) )
208
209
}
209
210
210
- func testParsingOfArrayOfIntOfFixedLengthAsParameter( ) throws {
211
+ func testParsingOfArrayOfIntOfFixedLengthAsParameter( ) async throws {
211
212
let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
212
213
let chainID = BigUInt ( 2828 )
213
- let eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /functionName123?int256[3]=[1,2,5000] " )
214
+ let eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum: \( testAddress) @ \( chainID. description) /functionName123?int256[3]=[1,2,5000] " )
214
215
XCTAssert ( eip681Code != nil )
215
216
guard let eip681Code = eip681Code else { return }
216
217
switch eip681Code. targetAddress {
@@ -229,27 +230,27 @@ class EIP681Tests: LocalTestCase {
229
230
XCTAssertEqual ( data, Array < BigInt > ( arrayLiteral: 1 , 2 , 5000 ) )
230
231
}
231
232
232
- func testParsingQueryParameterFixedLengthArray( ) throws {
233
+ func testParsingQueryParameterFixedLengthArray( ) async throws {
233
234
/// Declared `int256[3]` with 2 values instead of expected 3.
234
- var eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?int256[3]=[1,2] " )
235
+ var eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?int256[3]=[1,2] " )
235
236
XCTAssert ( eip681Code != nil )
236
237
XCTAssert ( eip681Code? . parameters. count == 0 )
237
238
/// Declared `int256[3]` with 4 values instead of expected 3.
238
- eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?int256[3]=[1,2,2,3] " )
239
+ eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?int256[3]=[1,2,2,3] " )
239
240
XCTAssert ( eip681Code != nil )
240
241
XCTAssert ( eip681Code? . parameters. count == 0 )
241
242
}
242
243
243
- func testParsingQueryParameterStringsArray( ) throws {
244
- var eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[]=[ \" 123 \" , \" 2,5000 \" , \" wwweer2-=! \" ] " )
244
+ func testParsingQueryParameterStringsArray( ) async throws {
245
+ var eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[]=[ \" 123 \" , \" 2,5000 \" , \" wwweer2-=! \" ] " )
245
246
XCTAssert ( eip681Code != nil )
246
247
guard eip681Code != nil else { return }
247
248
248
249
XCTAssertEqual ( eip681Code!. parameters [ 0 ] . type, . array( type: . string, length: 0 ) )
249
250
var data = eip681Code!. parameters [ 0 ] . value as? [ String ]
250
251
XCTAssertEqual ( data, [ " 123 " , " 2,5000 " , " wwweer2-=! " ] )
251
252
252
- eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[]=[123,2,5000,wwweer2-=!] " )
253
+ eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[]=[123,2,5000,wwweer2-=!] " )
253
254
XCTAssert ( eip681Code != nil )
254
255
guard eip681Code != nil else { return }
255
256
@@ -258,8 +259,8 @@ class EIP681Tests: LocalTestCase {
258
259
XCTAssertEqual ( data, [ " 123 " , " 2 " , " 5000 " , " wwweer2-=! " ] )
259
260
}
260
261
261
- func testParsingQueryParameterArrayOfStringsArrays( ) throws {
262
- var eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[][]=[[ \" 123 \" , \" 2,5000 \" , \" wwweer2-=! \" ],[ \" test1 \" , \" demo \" ]] " )
262
+ func testParsingQueryParameterArrayOfStringsArrays( ) async throws {
263
+ var eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[][]=[[ \" 123 \" , \" 2,5000 \" , \" wwweer2-=! \" ],[ \" test1 \" , \" demo \" ]] " )
263
264
XCTAssert ( eip681Code != nil )
264
265
guard eip681Code != nil else { return }
265
266
@@ -268,7 +269,7 @@ class EIP681Tests: LocalTestCase {
268
269
XCTAssertEqual ( data ? [ 0 ] , [ " 123 " , " 2,5000 " , " wwweer2-=! " ] )
269
270
XCTAssertEqual ( data ? [ 1 ] , [ " test1 " , " demo " ] )
270
271
271
- eip681Code = Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[][]=[[123,2,5000,wwweer2-=!],[test1,demo]] " )
272
+ eip681Code = await Web3 . EIP681CodeParser. parse ( " ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[][]=[[123,2,5000,wwweer2-=!],[test1,demo]] " )
272
273
XCTAssert ( eip681Code != nil )
273
274
guard eip681Code != nil else { return }
274
275
@@ -278,7 +279,7 @@ class EIP681Tests: LocalTestCase {
278
279
XCTAssertEqual ( data ? [ 1 ] , [ " test1 " , " demo " ] )
279
280
}
280
281
281
- func testMakeEIP681Link( ) throws {
282
+ func testMakeEIP681Link( ) async throws {
282
283
var eip681Link = Web3 . EIP681Code ( Web3 . EIP681Code. TargetAddress. ethereumAddress ( EthereumAddress ( " 0x9aBbDB06A61cC686BD635484439549D45c2449cc " ) !) )
283
284
284
285
eip681Link. functionName = " setData "
0 commit comments