diff --git a/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs b/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs index 76f309a1f..27b8cec53 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs @@ -53,14 +53,16 @@ public async Task SubscribeTipChangedEvent() lastCommit: GenerateBlockCommit(BlockChain.Tip.Index, BlockChain.Tip.Hash, GenesisValidators)); BlockChain.Append(block, GenerateBlockCommit(block.Index, block.Hash, GenesisValidators)); - var result = await ExecuteSubscriptionQueryAsync("subscription { tipChanged { index hash } }"); - // var data = (Dictionary)((ExecutionNode) result.Data!).ToValue()!; + + Assert.Equal(index, BlockChain.Tip.Index); + await Task.Delay(TimeSpan.FromSeconds(1)); + + var result = await ExecuteSubscriptionQueryAsync("subscription { tipChanged { index hash } }"); Assert.IsType(result); var subscribeResult = (SubscriptionExecutionResult)result; - Assert.Equal(index, BlockChain.Tip.Index); var stream = subscribeResult.Streams!.Values.FirstOrDefault(); - var rawEvents = await stream.Take((int)index); + var rawEvents = await stream.Take(1); Assert.NotNull(rawEvents); var events = (Dictionary)((ExecutionNode)rawEvents.Data!).ToValue()!; diff --git a/NineChronicles.Headless/GraphTypes/StandaloneSubscription.cs b/NineChronicles.Headless/GraphTypes/StandaloneSubscription.cs index 4fdf34bac..7ff4b2054 100644 --- a/NineChronicles.Headless/GraphTypes/StandaloneSubscription.cs +++ b/NineChronicles.Headless/GraphTypes/StandaloneSubscription.cs @@ -122,7 +122,7 @@ public PreloadStateType() private BlockHeader? _tipHeader; - private ISubject _subject = new ReplaySubject(); + private ISubject _subject = new ReplaySubject(1); private ISubject _transactionSubject = new Subject();