Skip to content

Commit a11febb

Browse files
chore: added tests to check that EIP681 link is URL encoded and that it's a valid URL
1 parent 8093b3e commit a11febb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Tests/web3swiftTests/localTests/EIP681Tests.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ class EIP681Tests: LocalTestCase {
303303
Web3.EIP681Code.EIP681Parameter(type: .string,
304304
value: "this is EIP681 query parameter string" as AnyObject)]
305305

306-
XCTAssertEqual(eip681Link.makeEIP681Link(), "ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc/setData?bytes32[]=[0x1234789565875498655487123478956587549865548712347895658754980000,0x1234789565875498655487123478956587549865548712347895658754986554]&bytes[]=[0x12345607,0x8965abcdef]&uint256=98986565&int256=155445566&address=0x9aBbDB06A61cC686BD635484439549D45c2449cc&bytes5=0x9abbdb06a6&bytes3=0x9abbdb&bytes=0x11009abbdb87879898656545&string=this is EIP681 query parameter string")
306+
let unencodedResult = "ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc/setData?bytes32[]=[0x1234789565875498655487123478956587549865548712347895658754980000,0x1234789565875498655487123478956587549865548712347895658754986554]&bytes[]=[0x12345607,0x8965abcdef]&uint256=98986565&int256=155445566&address=0x9aBbDB06A61cC686BD635484439549D45c2449cc&bytes5=0x9abbdb06a6&bytes3=0x9abbdb&bytes=0x11009abbdb87879898656545&string=this is EIP681 query parameter string"
307+
308+
XCTAssertEqual(eip681Link.makeEIP681Link(), unencodedResult)
309+
let encodedOutputLink = eip681Link.makeEIP681Link(urlEncode: true)
310+
XCTAssertEqual(encodedOutputLink, unencodedResult.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)
311+
XCTAssertNotNil(encodedOutputLink)
312+
XCTAssertNotNil(URL(string: encodedOutputLink ?? ""))
307313
}
308314
}

0 commit comments

Comments
 (0)