Skip to content

Commit

Permalink
update style, logs
Browse files Browse the repository at this point in the history
add unsubscribe to networking interactor
  • Loading branch information
llbartekll committed Aug 19, 2022
1 parent a3239f8 commit 70d85d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
23 changes: 4 additions & 19 deletions Example/IntegrationTests/Auth/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Combine
final class AuthTests: XCTestCase {
var app: AuthClient!
var wallet: AuthClient!
let prvKey = Data(hex: "462c1dad6832d7d96ccf87bd6a686a4110e114aaaebd5512e552c0e3a87b480f")
private var publishers = [AnyCancellable]()

override func setUp() {
Expand Down Expand Up @@ -67,11 +68,9 @@ final class AuthTests: XCTestCase {
try! await wallet.pair(uri: uri)
wallet.authRequestPublisher.sink { [unowned self] (id, message) in
Task(priority: .high) {
print("responding")
let prvKey = Data(hex: "462c1dad6832d7d96ccf87bd6a686a4110e114aaaebd5512e552c0e3a87b480f")
let sig = try! MessageSigner(signer: Signer()).sign(message: message, privateKey: prvKey)
let cacaoSig = CacaoSignature(t: "eip191", s: sig)
try! await wallet.respond(.success(RespondParams(id: id, signature: cacaoSig)))
let signature = try! MessageSigner(signer: Signer()).sign(message: message, privateKey: prvKey)
let cacaoSignature = CacaoSignature(t: "eip191", s: signature)
try! await wallet.respond(.success(RespondParams(id: id, signature: cacaoSignature)))
}
}
.store(in: &publishers)
Expand All @@ -83,17 +82,3 @@ final class AuthTests: XCTestCase {
wait(for: [responseExpectation], timeout: 2)
}
}

extension RespondParams {
static func stub(id: RPCID) -> RespondParams {
RespondParams(
id: id,
signature: CacaoSignature.stub())
}
}

extension CacaoSignature {
static func stub() -> CacaoSignature {
return CacaoSignature(t: "eip191", s: "438effc459956b57fcd9f3dac6c675f9cee88abf21acab7305e8e32aa0303a883b06dcbd956279a7a2ca21ffa882ff55cc22e8ab8ec0f3fe90ab45f306938cfa1b")
}
}
2 changes: 1 addition & 1 deletion Sources/Auth/Services/App/AppRequestService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ actor AppRequestService {
let params = AuthRequestParams(requester: requester, payloadParams: payload)
let request = RPCRequest(method: "wc_authRequest", params: params)
try kms.setPublicKey(publicKey: pubKey, for: responseTopic)
logger.debug("Subscribibg for response topic: \(responseTopic)")
logger.debug("AppRequestService: Subscribibg for response topic: \(responseTopic)")
try await networkingInteractor.requestNetworkAck(request, topic: topic, tag: AuthRequestParams.tag)
try await networkingInteractor.subscribe(topic: responseTopic)
}
Expand Down
8 changes: 7 additions & 1 deletion Sources/Auth/Services/Common/NetworkingInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ class NetworkingInteractor: NetworkInteracting {
}

func unsubscribe(topic: String) {
// fatalError("not implemented")
relayClient.unsubscribe(topic: topic) { [unowned self] error in
if let error = error {
logger.error(error)
} else {
rpcHistory.deleteAll(forTopic: topic)
}
}
}

func request(_ request: RPCRequest, topic: String, tag: Int, envelopeType: Envelope.EnvelopeType) async throws {
Expand Down

0 comments on commit 70d85d4

Please sign in to comment.