diff --git a/node/src/tests/test-DataConsumer.ts b/node/src/tests/test-DataConsumer.ts index 3cbf674958..a23c4c32ae 100644 --- a/node/src/tests/test-DataConsumer.ts +++ b/node/src/tests/test-DataConsumer.ts @@ -71,7 +71,7 @@ test('transport.consumeData() succeeds', async () => expect(dataConsumer1.label).toBe('foo'); expect(dataConsumer1.protocol).toBe('bar'); expect(dataConsumer1.paused).toBe(false); - expect(dataConsumer1.subchannels).toEqual([ 0, 1, 2, 100, 65535 ]); + expect(dataConsumer1.subchannels.sort()).toEqual([ 0, 1, 2, 100, 65535 ]); expect(dataConsumer1.appData).toEqual({ baz: 'LOL' }); const dump = await router.dump(); @@ -134,7 +134,7 @@ test('dataConsumer.setSubchannels() succeeds', async () => { await dataConsumer1.setSubchannels([ 999, 999, 998, 65536 ]); - expect(dataConsumer1.subchannels).toEqual([ 0, 998, 999 ]); + expect(dataConsumer1.subchannels.sort()).toEqual([ 0, 998, 999 ]); }, 2000); test('transport.consumeData() on a DirectTransport succeeds', async () => diff --git a/rust/tests/integration/data_consumer.rs b/rust/tests/integration/data_consumer.rs index 93cf5bf559..3636c336cf 100644 --- a/rust/tests/integration/data_consumer.rs +++ b/rust/tests/integration/data_consumer.rs @@ -153,7 +153,11 @@ fn consume_data_succeeds() { } assert_eq!(data_consumer.label().as_str(), "foo"); assert_eq!(data_consumer.protocol().as_str(), "bar"); - assert_eq!(data_consumer.subchannels(), [0, 1, 2, 100, 65535]); + + let mut sorted_subchannels = data_consumer.subchannels(); + sorted_subchannels.sort(); + + assert_eq!(sorted_subchannels, [0, 1, 2, 100, 65535]); assert_eq!( data_consumer .app_data() @@ -324,12 +328,10 @@ fn set_subchannels() { let data_consumer = transport1 .consume_data({ - let options = DataConsumerOptions::new_sctp_unordered_with_life_time( + DataConsumerOptions::new_sctp_unordered_with_life_time( data_producer.id(), 4000, ); - - options }) .await .expect("Failed to consume data"); @@ -339,7 +341,10 @@ fn set_subchannels() { .await .expect("Failed to set data consumer subchannels"); - assert_eq!(data_consumer.subchannels(), [0, 998, 999]); + let mut sorted_subchannels = data_consumer.subchannels(); + sorted_subchannels.sort(); + + assert_eq!(sorted_subchannels, [0, 998, 999]); }); } diff --git a/worker/include/RTC/DataConsumer.hpp b/worker/include/RTC/DataConsumer.hpp index cbe7132ae9..f732726c83 100644 --- a/worker/include/RTC/DataConsumer.hpp +++ b/worker/include/RTC/DataConsumer.hpp @@ -6,7 +6,7 @@ #include "Channel/ChannelSocket.hpp" #include "RTC/SctpDictionaries.hpp" #include "RTC/Shared.hpp" -#include +#include #include namespace RTC @@ -126,7 +126,7 @@ namespace RTC RTC::SctpStreamParameters sctpStreamParameters; std::string label; std::string protocol; - absl::btree_set subchannels; + absl::flat_hash_set subchannels; bool transportConnected{ false }; bool sctpAssociationConnected{ false }; bool paused{ false };