newreno exchange testing
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Jake Hillion 2021-05-12 00:43:51 +01:00
parent 613da510d1
commit 33f5df8f35

View 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)
})
}