-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix totalLost count error in receiverStream
Fixes #157
- Loading branch information
Showing
2 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package report | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestReceiverStream(t *testing.T) { | ||
t.Run("can use entire history size", func(t *testing.T) { | ||
stream := newReceiverStream(12345, 90000) | ||
maxPackets := stream.size * packetsPerHistoryEntry | ||
|
||
// We shouldn't wrap around so long as we only try maxPackets worth. | ||
for seq := uint16(0); seq < maxPackets; seq++ { | ||
require.False(t, stream.getReceived(seq), "packet with SN %v shouldn't be received yet", seq) | ||
stream.setReceived(seq) | ||
require.True(t, stream.getReceived(seq), "packet with SN %v should now be received", seq) | ||
} | ||
|
||
// Delete should also work. | ||
for seq := uint16(0); seq < maxPackets; seq++ { | ||
require.True(t, stream.getReceived(seq), "packet with SN %v should still be marked as received", seq) | ||
stream.delReceived(seq) | ||
require.False(t, stream.getReceived(seq), "packet with SN %v should no longer be received", seq) | ||
} | ||
}) | ||
|
||
} |