]> Sergey Matveev's repositories - btrtrc.git/blobdiff - connection_test.go
It's working and the tests are usually passing
[btrtrc.git] / connection_test.go
index 36832b9f1c93bb4b746ef540d419580c034a58fe..77dbb53b50551b43b7e0dcb175cfa72763ca7e86 100644 (file)
@@ -4,7 +4,6 @@ import (
        "testing"
        "time"
 
-       "github.com/bradfitz/iter"
        "github.com/stretchr/testify/assert"
 
        "github.com/anacrolix/torrent/internal/pieceordering"
@@ -63,38 +62,3 @@ func pieceOrderingAsSlice(po *pieceordering.Instance) (ret []int) {
 func testRequestOrder(expected []int, ro *pieceordering.Instance, t *testing.T) {
        assert.EqualValues(t, pieceOrderingAsSlice(ro), expected)
 }
-
-// Tests the request ordering based on a connections priorities.
-func TestPieceRequestOrder(t *testing.T) {
-       c := connection{
-               pieceRequestOrder: pieceordering.New(),
-               piecePriorities:   []int{1, 4, 0, 3, 2},
-       }
-       testRequestOrder(nil, c.pieceRequestOrder, t)
-       c.pendPiece(2, PiecePriorityNone, nil)
-       testRequestOrder(nil, c.pieceRequestOrder, t)
-       c.pendPiece(1, PiecePriorityNormal, nil)
-       c.pendPiece(2, PiecePriorityNormal, nil)
-       testRequestOrder([]int{2, 1}, c.pieceRequestOrder, t)
-       c.pendPiece(0, PiecePriorityNormal, nil)
-       testRequestOrder([]int{2, 0, 1}, c.pieceRequestOrder, t)
-       c.pendPiece(1, PiecePriorityReadahead, nil)
-       testRequestOrder([]int{1, 2, 0}, c.pieceRequestOrder, t)
-       c.pendPiece(4, PiecePriorityNow, nil)
-       // now(4), r(1), normal(0, 2)
-       testRequestOrder([]int{4, 1, 2, 0}, c.pieceRequestOrder, t)
-       c.pendPiece(2, PiecePriorityReadahead, nil)
-       // N(4), R(1, 2), N(0)
-       testRequestOrder([]int{4, 2, 1, 0}, c.pieceRequestOrder, t)
-       c.pendPiece(1, PiecePriorityNow, nil)
-       // now(4, 1), readahead(2), normal(0)
-       // in the same order, the keys will be: -15+6, -15+12, -5, 1
-       // so we test that a very low priority (for this connection), "now"
-       // piece has been placed after a readahead piece.
-       testRequestOrder([]int{4, 2, 1, 0}, c.pieceRequestOrder, t)
-       // Note this intentially sets to None a piece that's not in the order.
-       for i := range iter.N(5) {
-               c.pendPiece(i, PiecePriorityNone, nil)
-       }
-       testRequestOrder(nil, c.pieceRequestOrder, t)
-}