Skip to content

Commit

Permalink
fix race conditions with ReceivePersistentActorTests (#7194)
Browse files Browse the repository at this point in the history
Subscriptions to the `EventStream` need to happen _before_ the actor emitting events starts, otherwise we can end up in a scenario where everything works but the assertion fails.
  • Loading branch information
Aaronontheweb committed May 22, 2024
1 parent e470000 commit 3f0be58
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public void Given_persistent_actor_with_no_receive_command_specified_When_receiv
//Given
var pid = "p-1";
WriteEvents(pid, 1, 2, 3);
var actor = Sys.ActorOf(Props.Create(() => new NoCommandActor(pid)), "no-receive-specified");
Sys.EventStream.Subscribe(TestActor, typeof(UnhandledMessage));

var actor = Sys.ActorOf(Props.Create(() => new NoCommandActor(pid)), "no-receive-specified");

//When
actor.Tell("Something");

Expand All @@ -50,8 +50,8 @@ public void Given_persistent_actor_with_no_receive_event_specified_When_receivin
WriteEvents(pid, "Something");

// when
var actor = Sys.ActorOf(Props.Create(() => new NoEventActor(pid)), "no-receive-specified");
Sys.EventStream.Subscribe(TestActor, typeof(UnhandledMessage));
var actor = Sys.ActorOf(Props.Create(() => new NoEventActor(pid)), "no-receive-specified");

//Then
ExpectMsg<UnhandledMessage>(m => ((string)m.Message) == "Something" && Equals(m.Recipient, actor));
Expand Down

0 comments on commit 3f0be58

Please sign in to comment.