From 48a66ab7c994280162bea5f63887c1792d6e3d72 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Thu, 28 Sep 2023 12:47:50 +0800 Subject: [PATCH] Fix unit test consistency (#333) --- .../test/kotlin/io/libp2p/mux/yamux/YamuxHandlerTest.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libp2p/src/test/kotlin/io/libp2p/mux/yamux/YamuxHandlerTest.kt b/libp2p/src/test/kotlin/io/libp2p/mux/yamux/YamuxHandlerTest.kt index 7f66d1c6..098df2f4 100644 --- a/libp2p/src/test/kotlin/io/libp2p/mux/yamux/YamuxHandlerTest.kt +++ b/libp2p/src/test/kotlin/io/libp2p/mux/yamux/YamuxHandlerTest.kt @@ -261,8 +261,11 @@ class YamuxHandlerTest : MuxHandlerAbstractTest() { val range = 1..messagesToSend - // 100 window updates should be sent to ensure buffer is flushed and all messages are sent so will send them at random times - val windowUpdatesIndices = (range).shuffled().take(100).toSet() + // 100 window updates should be sent to ensure buffer is flushed and all messages are sent + // so will send them at random times ensuring maxBufferedConnectionWrites can never be reached + val windowUpdatesIndices = (range).chunked(100).flatMap { + it.shuffled().take(20) + } for (i in range) { if (i in windowUpdatesIndices) {