Skip to content

Commit c9492d7

Browse files
committed
refactor: replace direct byte comparison with WaitAssert for improved reliability in test case validation
1 parent ea890c8 commit c9492d7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/net-questdb-client-tests/JsonSpecTestRunner.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ public async Task RunTcp(TestCase testCase)
116116
{
117117
if (testCase.Result.BinaryBase64 != null)
118118
{
119-
var received = srv.GetReceivedBytes();
120119
var expected = Convert.FromBase64String(testCase.Result.BinaryBase64);
121-
Assert.That(received, Is.EqualTo(expected));
120+
WaitAssert(srv, expected);
122121
}
123122
else if (testCase.Result.AnyLines == null || testCase.Result.AnyLines.Length == 0)
124123
{
@@ -236,6 +235,17 @@ private static void WaitAssert(DummyIlpServer srv, string expected)
236235
Assert.That(srv.GetTextReceived(), Is.EqualTo(expected));
237236
}
238237

238+
private static void WaitAssert(DummyIlpServer srv, byte[] expected)
239+
{
240+
var expectedLen = expected.Length;
241+
for (var i = 0; i < 500 && srv.TotalReceived < expectedLen; i++)
242+
{
243+
Thread.Sleep(10);
244+
}
245+
246+
Assert.That(srv.GetReceivedBytes(), Is.EqualTo(expected));
247+
}
248+
239249
private DummyIlpServer CreateTcpListener(int port, bool tls = false)
240250
{
241251
return new DummyIlpServer(port, tls);

0 commit comments

Comments
 (0)