dedis / popstellar

Proof-of-personhood System
GNU Affero General Public License v3.0
35 stars 8 forks source link

[BUG] ActorRef injection through PublishSubscribe creates inconsistencies in tests #1870

Closed DanielTavaresA closed 5 months ago

DanielTavaresA commented 5 months ago

Description (Actual behavior)

When running the full test suite in Scala, test("rumor handler should process messages received in a rumor") fails, but when running only RumorHandlerSuite this test passes.

Expected behavior

We expect that tests shouldn't have dependencies and test("rumor handler should process messages received in a rumor") should succeed independently of previous tests

How to reproduce

  1. Run all scala test suite at once
  2. Run only RumorHandlerSuite

Version & Environment

This bug was reproduced on:

Front-ends:
Back-ends:

Workaround

PoP System is still usable as usual, this issue only raises in tests. To still be able to test, failing test should be uncommented and run only `RumorHandlerSuite

Impact

This issue prevents two different tests suites from testing if the processing of messages received within a Rumor or GetMsgByIdAns is done correctly.

Possible root cause

Root cause comes from PublishSubscribe.buildGraph injection of reference for the dbActor. RumorHandlerSuitetries to reference a dbActor that was created within GetMessagesByIdResponseHandlerSuiteSystem, which fails because it was terminated. This reference comes from different handlers that rely on getDbActorReffrom PublishSubscribe. This injection is necessary to test that messages are handled correctly, but if done in two separate test suites, it seems that some classes still reference and old one.

DanielTavaresA commented 5 months ago

Reference from Db is shared between tests through objects handlers. final lazy val handlerInstance is created once, with first ActorSystem sharing its dbRef. This dbRef is then shared accross tests causing errors.

DanielTavaresA commented 5 months ago

Creating a MessageRegistery calls ElectionHandler, RollcallHandler, SocialHandler and WitnessHandler . Once a call to this handler happens in one test, the instance is set and final for all test suites.