diff --git a/Examples/xx-messenger/Package.swift b/Examples/xx-messenger/Package.swift index 7a0357bdb8d200d2e7147fce3c90f15fc48aab35..77b97a0f38f4516e0ae9b60feeb18364dbb02247 100644 --- a/Examples/xx-messenger/Package.swift +++ b/Examples/xx-messenger/Package.swift @@ -135,6 +135,7 @@ let package = Package( dependencies: [ .target(name: "AppCore"), .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), + .product(name: "XXClient", package: "elixxir-dapps-sdk-swift"), .product(name: "XXMessengerClient", package: "elixxir-dapps-sdk-swift"), .product(name: "XXModels", package: "client-ios-db"), ], diff --git a/Examples/xx-messenger/Sources/RegisterFeature/RegisterFeature.swift b/Examples/xx-messenger/Sources/RegisterFeature/RegisterFeature.swift index 8e1f35411fdd0ec6d952f556420f9c72073c1e1f..b55cae7d08a0ce6aade8858e4a1e7dd17b63d097 100644 --- a/Examples/xx-messenger/Sources/RegisterFeature/RegisterFeature.swift +++ b/Examples/xx-messenger/Sources/RegisterFeature/RegisterFeature.swift @@ -2,6 +2,7 @@ import AppCore import ComposableArchitecture import Foundation import XCTestDynamicOverlay +import XXClient import XXMessengerClient import XXModels @@ -81,7 +82,11 @@ public let registerReducer = Reducer<RegisterState, RegisterAction, RegisterEnvi do { let db = try env.db() try env.messenger.register(username: username) - let contact = env.messenger.e2e()!.getContact() + var contact = try env.messenger.e2e.tryGet().getContact() + var facts: [Fact] = (try? contact.getFacts()) ?? [] + facts.removeAll(where: { $0.type == 0 }) + facts.append(Fact(fact: username, type: 0)) + try contact.setFacts(facts) try db.saveContact(Contact( id: try contact.getId(), marshaled: contact.data, diff --git a/Examples/xx-messenger/Tests/RegisterFeatureTests/RegisterFeatureTests.swift b/Examples/xx-messenger/Tests/RegisterFeatureTests/RegisterFeatureTests.swift index a2aad5bd7977dbd210a163d8cdac9001de239723..12addba7f1a5901fcf2d9424d44e791db8ab4904 100644 --- a/Examples/xx-messenger/Tests/RegisterFeatureTests/RegisterFeatureTests.swift +++ b/Examples/xx-messenger/Tests/RegisterFeatureTests/RegisterFeatureTests.swift @@ -16,6 +16,7 @@ final class RegisterFeatureTests: XCTestCase { let now = Date() let mainQueue = DispatchQueue.test let bgQueue = DispatchQueue.test + var didSetFactsOnContact: [[XXClient.Fact]] = [] var dbDidSaveContact: [XXModels.Contact] = [] var messengerDidRegisterUsername: [String] = [] @@ -30,6 +31,11 @@ final class RegisterFeatureTests: XCTestCase { e2e.getContact.run = { var contact = XXClient.Contact.unimplemented("contact-data".data(using: .utf8)!) contact.getIdFromContact.run = { _ in "contact-id".data(using: .utf8)! } + contact.getFactsFromContact.run = { _ in [] } + contact.setFactsOnContact.run = { data, facts in + didSetFactsOnContact.append(facts) + return data + } return contact } return e2e @@ -57,6 +63,7 @@ final class RegisterFeatureTests: XCTestCase { bgQueue.advance() XCTAssertNoDifference(messengerDidRegisterUsername, ["NewUser"]) + XCTAssertNoDifference(didSetFactsOnContact, [[Fact(fact: "NewUser", type: 0)]]) XCTAssertNoDifference(dbDidSaveContact, [ XXModels.Contact( id: "contact-id".data(using: .utf8)!,