Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE2] rumor message process #1876

Merged
merged 4 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ object ProcessMessagesHandler extends AskPatternConstants {
}

def rumorHandler(messageRegistry: MessageRegistry, rumor: Rumor)(implicit system: ActorSystem): Boolean = {
true
val msgMap = rumor.messages.map((chan, list) => (chan, list.toSet))
processMsgMap(msgMap, messageRegistry)
}

private def processMsgMap(msgMap: Map[Channel, Set[Message]], messageRegistry: MessageRegistry)(implicit system: ActorSystem): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,26 @@ class RumorHandlerSuite extends TestKit(ActorSystem("RumorActorSuiteActorSystem"
case _ => 1 shouldBe 0
}

// https://github.com/dedis/popstellar/issues/1870
/*test("rumor handler should process messages received in a rumor") {
val dbRef = PublishSubscribe.getDbActorRef
val output = Source.single(Right(rumorRequest)).via(rumorHandler).runWith(Sink.head)
val outputResult = Await.result(output, processDuration)
val ask = dbActorRef ? DbActor.GetAllChannels()
val channelsInDb = Await.result(ask, MAX_TIME) match {
case DbActor.DbActorGetAllChannelsAck(channels) => channels
case err @ _ => Matchers.fail(err.toString)
}
val channelsInRumor = rumor.messages.keySet
channelsInRumor.diff(channelsInDb) should equal(Set.empty)
val messagesInDb: Set[Message] = channelsInDb.foldLeft(Set.empty: Set[Message])((acc, channel) => acc ++ getMessages(channel))
val messagesInRumor = rumor.messages.values.foldLeft(Set.empty: Set[Message])((acc, set) => acc ++ set)
messagesInRumor.diff(messagesInDb) should equal(Set.empty)
}*/

}
Loading