Closed DanielTavaresA closed 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.
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.
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 onlyRumorHandlerSuite
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 testsHow to reproduce
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
orGetMsgByIdAns
is done correctly.Possible root cause
Root cause comes from PublishSubscribe.buildGraph injection of reference for the dbActor.
RumorHandlerSuite
tries to reference a dbActor that was created withinGetMessagesByIdResponseHandlerSuiteSystem
, which fails because it was terminated. This reference comes from different handlers that rely ongetDbActorRef
from 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.