66
77import XCTest
88import BigInt
9+ import Core
910
1011@testable import web3swift
1112
12- class EIP681Tests : LocalTestCase {
13+ class EIP681Tests : XCTestCase {
1314
14- func testParsing( ) throws {
15+ func testParsing( ) async throws {
1516 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 " )
1718 XCTAssert ( eip681Code != nil )
1819 guard let eip681Code = eip681Code else { return }
1920 switch eip681Code. targetAddress {
@@ -26,9 +27,9 @@ class EIP681Tests: LocalTestCase {
2627 XCTAssertEqual ( eip681Code. amount, BigUInt ( 2014000000000000000 ) )
2728 }
2829
29- func testParsingWithEncoding( ) throws {
30+ func testParsingWithEncoding( ) async throws {
3031 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) !)
3233 XCTAssert ( eip681Code != nil )
3334 guard let eip681Code = eip681Code else { return }
3435 switch eip681Code. targetAddress {
@@ -40,9 +41,9 @@ class EIP681Tests: LocalTestCase {
4041 XCTAssertEqual ( eip681Code. amount, BigUInt ( 2014000000000000000 ) )
4142 }
4243
43- func testParsing2( ) throws {
44+ func testParsing2( ) async throws {
4445 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 " )
4647 XCTAssert ( eip681Code != nil )
4748 guard let eip681Code = eip681Code else { return }
4849 switch eip681Code. targetAddress {
@@ -60,9 +61,9 @@ class EIP681Tests: LocalTestCase {
6061 XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
6162 }
6263
63- func testParsing2WithEncoding( ) throws {
64+ func testParsing2WithEncoding( ) async throws {
6465 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 "
6667 . addingPercentEncoding ( withAllowedCharacters: . urlQueryAllowed) !)
6768 XCTAssert ( eip681Code != nil )
6869 guard let eip681Code = eip681Code else { return }
@@ -81,9 +82,9 @@ class EIP681Tests: LocalTestCase {
8182 XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
8283 }
8384
84- func testENSParsing( ) throws {
85+ func testENSParsing( ) async throws {
8586 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 " )
8788 XCTAssert ( eip681Code != nil )
8889 guard let eip681Code = eip681Code else { return }
8990 switch eip681Code. targetAddress {
@@ -103,9 +104,9 @@ class EIP681Tests: LocalTestCase {
103104 XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
104105 }
105106
106- func testENSParsingWithEncoding( ) throws {
107+ func testENSParsingWithEncoding( ) async throws {
107108 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) !)
109110 XCTAssert ( eip681Code != nil )
110111 guard let eip681Code = eip681Code else { return }
111112 switch eip681Code. targetAddress {
@@ -125,10 +126,10 @@ class EIP681Tests: LocalTestCase {
125126 XCTAssertEqual ( eip681Code. parameters [ 1 ] . value as? BigUInt , BigUInt ( 1 ) )
126127 }
127128
128- func testParsingOfArrayOfBytesAsParameter( ) throws {
129+ func testParsingOfArrayOfBytesAsParameter( ) async throws {
129130 let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
130131 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] " )
132133 XCTAssert ( eip681Code != nil )
133134 guard let eip681Code = eip681Code else { return }
134135 switch eip681Code. targetAddress {
@@ -155,10 +156,10 @@ class EIP681Tests: LocalTestCase {
155156 XCTAssertEqual ( data ? [ 2 ] , Data . fromHex ( " 0x005e9F5BB83481d5627aA8c48527C174579bC428 " ) !)
156157 }
157158
158- func testParsingOfArrayOfBytesAsParameterWithEncoding( ) throws {
159+ func testParsingOfArrayOfBytesAsParameterWithEncoding( ) async throws {
159160 let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
160161 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) !)
162163 XCTAssert ( eip681Code != nil )
163164 guard let eip681Code = eip681Code else { return }
164165 switch eip681Code. targetAddress {
@@ -185,10 +186,10 @@ class EIP681Tests: LocalTestCase {
185186 XCTAssertEqual ( data ? [ 2 ] , Data . fromHex ( " 0x005e9F5BB83481d5627aA8c48527C174579bC428 " ) !)
186187 }
187188
188- func testParsingOfArrayOfIntAsParameter( ) throws {
189+ func testParsingOfArrayOfIntAsParameter( ) async throws {
189190 let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
190191 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] " )
192193 XCTAssert ( eip681Code != nil )
193194 guard let eip681Code = eip681Code else { return }
194195 switch eip681Code. targetAddress {
@@ -207,10 +208,10 @@ class EIP681Tests: LocalTestCase {
207208 XCTAssertEqual ( data, Array < BigInt > ( arrayLiteral: 1 , 2 , 5000 , 3 , 4 , 10000 ) )
208209 }
209210
210- func testParsingOfArrayOfIntOfFixedLengthAsParameter( ) throws {
211+ func testParsingOfArrayOfIntOfFixedLengthAsParameter( ) async throws {
211212 let testAddress = " 0x9aBbDB06A61cC686BD635484439549D45c2449cc "
212213 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] " )
214215 XCTAssert ( eip681Code != nil )
215216 guard let eip681Code = eip681Code else { return }
216217 switch eip681Code. targetAddress {
@@ -229,27 +230,27 @@ class EIP681Tests: LocalTestCase {
229230 XCTAssertEqual ( data, Array < BigInt > ( arrayLiteral: 1 , 2 , 5000 ) )
230231 }
231232
232- func testParsingQueryParameterFixedLengthArray( ) throws {
233+ func testParsingQueryParameterFixedLengthArray( ) async throws {
233234 /// 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] " )
235236 XCTAssert ( eip681Code != nil )
236237 XCTAssert ( eip681Code? . parameters. count == 0 )
237238 /// 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] " )
239240 XCTAssert ( eip681Code != nil )
240241 XCTAssert ( eip681Code? . parameters. count == 0 )
241242 }
242243
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-=! \" ] " )
245246 XCTAssert ( eip681Code != nil )
246247 guard eip681Code != nil else { return }
247248
248249 XCTAssertEqual ( eip681Code!. parameters [ 0 ] . type, . array( type: . string, length: 0 ) )
249250 var data = eip681Code!. parameters [ 0 ] . value as? [ String ]
250251 XCTAssertEqual ( data, [ " 123 " , " 2,5000 " , " wwweer2-=! " ] )
251252
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-=!] " )
253254 XCTAssert ( eip681Code != nil )
254255 guard eip681Code != nil else { return }
255256
@@ -258,8 +259,8 @@ class EIP681Tests: LocalTestCase {
258259 XCTAssertEqual ( data, [ " 123 " , " 2 " , " 5000 " , " wwweer2-=! " ] )
259260 }
260261
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 \" ]] " )
263264 XCTAssert ( eip681Code != nil )
264265 guard eip681Code != nil else { return }
265266
@@ -268,7 +269,7 @@ class EIP681Tests: LocalTestCase {
268269 XCTAssertEqual ( data ? [ 0 ] , [ " 123 " , " 2,5000 " , " wwweer2-=! " ] )
269270 XCTAssertEqual ( data ? [ 1 ] , [ " test1 " , " demo " ] )
270271
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]] " )
272273 XCTAssert ( eip681Code != nil )
273274 guard eip681Code != nil else { return }
274275
@@ -278,7 +279,7 @@ class EIP681Tests: LocalTestCase {
278279 XCTAssertEqual ( data ? [ 1 ] , [ " test1 " , " demo " ] )
279280 }
280281
281- func testMakeEIP681Link( ) throws {
282+ func testMakeEIP681Link( ) async throws {
282283 var eip681Link = Web3 . EIP681Code ( Web3 . EIP681Code. TargetAddress. ethereumAddress ( EthereumAddress ( " 0x9aBbDB06A61cC686BD635484439549D45c2449cc " ) !) )
283284
284285 eip681Link. functionName = " setData "
0 commit comments