@@ -220,24 +220,34 @@ final class DistributedReceptionistTests: ClusterSystemXCTestCase {
220220
221221 // ==== ----------------------------------------------------------------------------------------------------------------
222222
223- // func test_receptionist_shouldNotRegisterTheSameRefTwice() throws {
224- // let receptionist = SystemReceptionist(ref: try system._spawn("receptionist", self.receptionistBehavior))
225- // let lookupProbe: ActorTestProbe<_Reception.Listing<_ActorRef<String>>> = self.testKit.makeTestProbe()
226- //
227- // let ref: _ActorRef<String> = try system._spawn(.anonymous, .receiveMessage { _ in .same })
228- //
229- // let key = _Reception.Key(_ActorRef<String>.self, id: "test")
230- //
231- // receptionist.checkIn(ref, with: key)
232- // receptionist.checkIn(ref, with: key)
233- //
234- // receptionist.lookup(key, replyTo: lookupProbe.ref)
235- //
236- // let listing = try lookupProbe.expectMessage()
237- //
238- // listing.refs.count.shouldEqual(1)
239- // }
240- //
223+ func test_receptionist_shouldNotRegisterTheSameRefTwice( ) async throws {
224+ let ref = Forwarder ( probe: nil , name: " D " , actorSystem: system)
225+
226+ await system. receptionist. checkIn ( ref, with: . forwarders)
227+ await system. receptionist. checkIn ( ref, with: . forwarders)
228+
229+ let listing = await system. receptionist. lookup ( . forwarders)
230+
231+ listing. count. shouldEqual ( 1 )
232+ }
233+
234+ func test_receptionist_happyPath_lookup( ) async throws {
235+ let ( first, second) = await self . setUpPair ( ) { settings in
236+ settings. enabled = true
237+ }
238+
239+ let ref = Forwarder ( probe: nil , name: " D " , actorSystem: first)
240+ await first. receptionist. checkIn ( ref, with: . forwarders)
241+
242+ first. cluster. join ( node: second. cluster. uniqueNode. node)
243+ try await first. cluster. joined ( node: second. cluster. uniqueNode, within: . seconds( 30 ) )
244+
245+ let listing = await second. receptionist. lookup ( . forwarders)
246+
247+ listing. count. shouldEqual ( 1 )
248+ listing. first!. id. shouldEqual ( ref. id)
249+ }
250+
241251// func test_receptionist_shouldRemoveAndAddNewSingletonRef() throws {
242252// let receptionist = SystemReceptionist(ref: try system._spawn("receptionist", self.receptionistBehavior))
243253// let lookupProbe: ActorTestProbe<_Reception.Listing<_ActorRef<String>>> = self.testKit.makeTestProbe()
0 commit comments