From 8071942c8e210df879f9cecc635800bf60881c7a Mon Sep 17 00:00:00 2001 From: ain ghazal Date: Wed, 31 Jan 2024 19:06:42 +0100 Subject: [PATCH] add more unit tests --- internal/reliabletransport/receiver.go | 4 ++-- internal/reliabletransport/receiver_test.go | 13 +++++++++++++ internal/session/manager.go | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/reliabletransport/receiver.go b/internal/reliabletransport/receiver.go index de3f8e4b..2f81581b 100644 --- a/internal/reliabletransport/receiver.go +++ b/internal/reliabletransport/receiver.go @@ -108,11 +108,11 @@ type reliableReceiver struct { lastConsumed model.PacketID } -func newReliableReceiver(logger model.Logger, i chan incomingPacketSeen) *reliableReceiver { +func newReliableReceiver(logger model.Logger, ch chan incomingPacketSeen) *reliableReceiver { return &reliableReceiver{ logger: logger, incomingPackets: make([]*model.Packet, 0), - incomingSeen: i, + incomingSeen: ch, lastConsumed: 0, } } diff --git a/internal/reliabletransport/receiver_test.go b/internal/reliabletransport/receiver_test.go index 21c727ac..b5083201 100644 --- a/internal/reliabletransport/receiver_test.go +++ b/internal/reliabletransport/receiver_test.go @@ -12,6 +12,19 @@ import ( // tests for reliableReceiver // +func Test_newReliableReceiver(t *testing.T) { + rr := newReliableReceiver(log.Log, make(chan incomingPacketSeen)) + if rr.logger == nil { + t.Errorf("newReliableReceiver() should not have nil logger") + } + if rr.incomingPackets == nil { + t.Errorf("newReliableReceiver() should not have nil incomingPackets ch") + } + if rr.lastConsumed != 0 { + t.Errorf("newReliableReceiver() should have lastConsumed == 0") + } +} + func Test_reliableQueue_MaybeInsertIncoming(t *testing.T) { log.SetLevel(log.DebugLevel) diff --git a/internal/session/manager.go b/internal/session/manager.go index d86b64b7..7b54c4ab 100644 --- a/internal/session/manager.go +++ b/internal/session/manager.go @@ -87,7 +87,6 @@ type Manager struct { // Ready is a channel where we signal that we can start accepting data, because we've // successfully generated key material for the data channel. - // TODO(ainghazal): find a better way? Ready chan any }