func TestSchedulerFullScenario(t *testing.T) {
	s, _, links := simpleScenario()
	links[0].Upload(Data{"1-0-0", 100})
	links[1].Upload(Data{"2-0-0", 50})
	s.Schedule()
	links[1].Upload(Data{"2-0-1", 50})
	s.Schedule()
	if len(links[0].Download()) != 0 {
		t.Fatalf("Link 1-0 transmitted: %s", len(links[0].Download()))
	}
	if len(links[1].Download()) != 1 {
		t.Fatalf("Link 2-0 not transmitted: %s", len(links[1].Download()))
	}
	links[0].Upload(Data{"1-0-1", 100})
	s.Schedule()
	if len(links[0].Download()) != 1 {
		t.Fatalf("Link 1-0 not transmitted: %s", len(links[0].Download()))
	}
	if len(links[1].Download()) != 2 {
		t.Fatalf("Link 2-0 not transmitted: %s", len(links[1].Download()))
	}
	s.Schedule()
	if len(links[0].Download()) != 2 {
		t.Fatalf("Link 1-0 not transmitted: %s", len(links[0].Download()))
	}
	if len(links[1].Download()) != 2 {
		t.Fatalf("Link 2-0 not transmitted: %s", len(links[1].Download()))
	}
	assertEqual(t, Data{"1-0-0", 100}, <-links[0].Download())
	assertEqual(t, Data{"1-0-1", 100}, <-links[0].Download())
	assertEqual(t, Data{"2-0-0", 50}, <-links[1].Download())
	assertEqual(t, Data{"2-0-1", 50}, <-links[1].Download())
}
/* Scheduler full scenario test.
package capacity
import (
	. "github.com/danalex97/Speer/interfaces"
	"sync"
	"testing"
)
func assertEqual(t *testing.T, a interface{}, b interface{}) {
	if a != b {
		t.Fatalf("%s != %s", a, b)
	}
}
type link struct {
	from int
	to   int
}
func simpleScenario() (s *scheduler, nodes []NodeCapacity, links []Link) {
	s = NewScheduler(10).(*scheduler)
	nodes = []NodeCapacity{
		&node{10, 0},
		&node{0, 30},
		&node{0, 20},
	}
	links = []Link{
		NewPerfectLink(nodes[1], nodes[0]),
		NewPerfectLink(nodes[2], nodes[0]),
	}
	s.RegisterLink(links[0])
	s.RegisterLink(links[1])
	return
}
func TestSchedulerSmallPackets(t *testing.T) {
	s, _, links := simpleScenario()
	links[0].Upload(Data{"1", 1})
	links[0].Upload(Data{"2", 1})
	links[0].Upload(Data{"3", 1})
	links[0].Upload(Data{"4", 1})
	s.Schedule()
	s.Schedule()
	s.Schedule()
	assertEqual(t, Data{"1", 1}, <-links[0].Download())
	assertEqual(t, Data{"2", 1}, <-links[0].Download())
	assertEqual(t, Data{"3", 1}, <-links[0].Download())
	assertEqual(t, Data{"4", 1}, <-links[0].Download())
}
func TestSchedulerConcurrent(t *testing.T) {
	for i := 0; i < 10; i++ {
		s, _, links := simpleScenario()
		var wg sync.WaitGroup
		wg.Add(2)
		go func() {
			defer wg.Done()
			links[0].Upload(Data{"1-0-0", 100})
			links[0].Upload(Data{"1-0-1", 100})
		}()
		go func() {
			defer wg.Done()
			links[1].Upload(Data{"2-0-0", 50})
			links[1].Upload(Data{"2-0-1", 50})
		}()
		wg.Wait()
		go s.Schedule()
		go s.Schedule()
		go s.Schedule()
		go s.Schedule()
		wg.Add(2)
		go func() {
			defer wg.Done()
			assertEqual(t, Data{"1-0-0", 100}, <-links[0].Download())
			assertEqual(t, Data{"1-0-1", 100}, <-links[0].Download())
		}()
		go func() {
			defer wg.Done()
			assertEqual(t, Data{"2-0-0", 50}, <-links[1].Download())
			assertEqual(t, Data{"2-0-1", 50}, <-links[1].Download())
		}()
		wg.Wait()
	}
}