File: shaper_test.go

package info (click to toggle)
golang-github-xtaci-smux 1.5.15%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 180 kB
  • sloc: sh: 63; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 519 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package smux

import (
	"container/heap"
	"testing"
)

func TestShaper(t *testing.T) {
	w1 := writeRequest{prio: 10}
	w2 := writeRequest{prio: 10}
	w3 := writeRequest{prio: 20}
	w4 := writeRequest{prio: 100}

	var reqs shaperHeap
	heap.Push(&reqs, w4)
	heap.Push(&reqs, w3)
	heap.Push(&reqs, w2)
	heap.Push(&reqs, w1)

	var lastPrio uint64
	for len(reqs) > 0 {
		w := heap.Pop(&reqs).(writeRequest)
		if w.prio < lastPrio {
			t.Fatal("incorrect shaper priority")
		}

		t.Log("prio:", w.prio)
		lastPrio = w.prio
	}
}