newreno exchange testing
This commit is contained in:
parent
613da510d1
commit
33f5df8f35
57
udp/congestion/newreno/exchange_test.go
Normal file
57
udp/congestion/newreno/exchange_test.go
Normal file
@ -0,0 +1,57 @@
|
||||
package newreno
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewReno_InitialHandle(t *testing.T) {
|
||||
t.Run("InitialAckNackAreZero", func(t *testing.T) {
|
||||
// ASSIGN
|
||||
a := NewNewReno()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// ACT
|
||||
initial, err := a.Initial(ctx)
|
||||
|
||||
ack := binary.LittleEndian.Uint32(initial[0:4])
|
||||
nack := binary.LittleEndian.Uint32(initial[4:8])
|
||||
|
||||
// ASSERT
|
||||
require.Nil(t, err)
|
||||
|
||||
assert.Zero(t, ack)
|
||||
assert.Zero(t, nack)
|
||||
})
|
||||
|
||||
t.Run("InitialHandledWithAck", func(t *testing.T) {
|
||||
// ASSIGN
|
||||
a := NewNewReno()
|
||||
b := NewNewReno()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// ACT
|
||||
initial, err := a.Initial(ctx)
|
||||
require.Nil(t, err)
|
||||
|
||||
initialSeq := binary.LittleEndian.Uint32(initial[8:12])
|
||||
|
||||
response, data, err := b.Handle(ctx , initial)
|
||||
|
||||
ack := binary.LittleEndian.Uint32(response[0:4])
|
||||
nack := binary.LittleEndian.Uint32(response[4:8])
|
||||
|
||||
// ASSERT
|
||||
require.Nil(t, err)
|
||||
|
||||
assert.Equal(t, initialSeq, ack)
|
||||
assert.Zero(t, nack)
|
||||
|
||||
assert.Nil(t, data)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user