Skip to content

Commit

Permalink
Merge pull request #1876 from dedis/work-be2-daniel-rumor-message-pro…
Browse files Browse the repository at this point in the history
…cess

[BE2] rumor message process
  • Loading branch information
DanielTavaresA authored May 19, 2024
2 parents abf0af1 + 6e30aa3 commit 96fe8df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
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)
}*/

}

0 comments on commit 96fe8df

Please sign in to comment.