Fix: parsing of universal link broken

pull/1255/head
Hwee-Boon Yar 5 years ago
parent 93ca71a9ee
commit 5a126d73ce
  1. 2
      AlphaWallet/Core/Types/AlphaWalletAddress.swift
  2. 12
      AlphaWalletTests/Market/UniversalLinkHandlerTests.swift

@ -17,6 +17,7 @@ extension AlphaWallet {
}
init?(string: String) {
let string = string.add0x
guard string.count == 42 else { return nil }
guard let address = TrustKeystore.Address(string: string) else { return nil }
self = .ethereumAddress(eip55String: address.eip55String)
@ -24,6 +25,7 @@ extension AlphaWallet {
//TODO not sure if we should keep this
init?(uncheckedAgainstNullAddress string: String) {
let string = string.add0x
guard string.count == 42 else { return nil }
guard let address = TrustKeystore.Address(uncheckedAgainstNullAddress: string) else { return nil }
self = .ethereumAddress(eip55String: address.eip55String)

@ -12,12 +12,13 @@ class UniversalLinkHandlerTests: XCTestCase {
func testUniversalLinkParser() {
let server: RPCServer = .main
let testUrl = "https://aw.app/AQAAAAAAAACjNHyO0TRETCUWmHLJCmNg1Cs2kQFxEtQiQ269SZP2r2Y6CETiCqCE3HGQa63LYjsaCOccJi0mj9bpsmnZCwFkjVcNaaJ6Ed8lVU83UiGILQZ4CcFhHA=="
if let signedOrder = UniversalLinkHandler(server: server).parseUniversalLink(url: testUrl, prefix: RPCServer.main.magicLinkPrefix.absoluteString) {
XCTAssertGreaterThanOrEqual(signedOrder.signature.count, 130)
let url = UniversalLinkHandler(server: server).createUniversalLink(signedOrder: signedOrder)
print(url)
XCTAssertEqual(testUrl, url)
guard let signedOrder = UniversalLinkHandler(server: server).parseUniversalLink(url: testUrl, prefix: RPCServer.main.magicLinkPrefix.absoluteString) else {
XCTFail("Not able to extract an order from MagicLink")
return
}
XCTAssertGreaterThanOrEqual(signedOrder.signature.count, 130)
let url = UniversalLinkHandler(server: server).createUniversalLink(signedOrder: signedOrder)
XCTAssertEqual(testUrl, url)
}
func testCreateUniversalLink() {
@ -40,7 +41,6 @@ class UniversalLinkHandlerTests: XCTestCase {
// let account = try! EtherKeystore().getAccount(for: Address(string: "0x007bEe82BDd9e866b2bd114780a47f2261C684E3")!)
// let signedOrder = try! OrderHandler().signOrders(orders: testOrders, account: account!)
// let url = UniversalLinkHandler().createUniversalLink(signedOrder: signedOrder[0])
// print(url)
}
}

Loading…
Cancel
Save