diff --git a/src/core/Akka.Cluster.Tests/ClusterLogSpec.cs b/src/core/Akka.Cluster.Tests/ClusterLogSpec.cs index e9bf697ed63..a2593514f11 100644 --- a/src/core/Akka.Cluster.Tests/ClusterLogSpec.cs +++ b/src/core/Akka.Cluster.Tests/ClusterLogSpec.cs @@ -68,7 +68,15 @@ await WithinAsync(TimeSpan.FromSeconds(10), async () => { await EventFilter .Info(contains: expected) - .ExpectOneAsync(async () => _cluster.Join(_selfAddress)); + .ExpectOneAsync(async () => { + var tcs = new TaskCompletionSource(); + _cluster.RegisterOnMemberUp(() => + { + tcs.TrySetResult(true); + }); + _cluster.Join(_selfAddress); + await tcs.Task.ShouldCompleteWithin(Remaining); + }); }); } @@ -82,7 +90,16 @@ await WithinAsync(TimeSpan.FromSeconds(10), async () => { await EventFilter .Info(contains: expected) - .ExpectOneAsync(async () => _cluster.Down(_selfAddress)); + .ExpectOneAsync(async () => + { + var tcs = new TaskCompletionSource(); + _cluster.RegisterOnMemberRemoved(() => + { + tcs.TrySetResult(true); + }); + _cluster.Down(_selfAddress); + await tcs.Task.ShouldCompleteWithin(Remaining); + }); }); } }