Update some tests now that adding connections is more reliable

This commit is contained in:
Matt Joiner 2018-06-13 22:02:30 +10:00
parent a1d2a32b20
commit c9187bf736
1 changed files with 3 additions and 21 deletions

View File

@ -498,17 +498,8 @@ func TestSeedAfterDownloading(t *testing.T) {
}() }()
done := make(chan struct{}) done := make(chan struct{})
defer close(done) defer close(done)
go func() {
for {
go leecherGreeting.AddClientPeer(seeder) go leecherGreeting.AddClientPeer(seeder)
go leecherGreeting.AddClientPeer(leecherLeecher) go leecherGreeting.AddClientPeer(leecherLeecher)
select {
case <-done:
return
case <-time.After(time.Second):
}
}
}()
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
@ -860,16 +851,7 @@ func testDownloadCancel(t *testing.T, ps testDownloadCancelParams) {
leecherGreeting.cl.mu.Unlock() leecherGreeting.cl.mu.Unlock()
done := make(chan struct{}) done := make(chan struct{})
defer close(done) defer close(done)
go func() { go leecherGreeting.AddClientPeer(seeder)
for {
leecherGreeting.AddClientPeer(seeder)
select {
case <-done:
return
case <-time.After(time.Second):
}
}
}()
completes := make(map[int]bool, 3) completes := make(map[int]bool, 3)
expected := func() map[int]bool { expected := func() map[int]bool {
if ps.Cancel { if ps.Cancel {