Commit some staged changes

This commit is contained in:
Justin Li 2014-07-21 10:53:26 -04:00
parent 044333a75c
commit af57763882
3 changed files with 4 additions and 11 deletions

View file

@ -30,24 +30,19 @@ func TestPublicAnnounce(t *testing.T) {
peer2 := makePeerParams("peer2", true)
peer3 := makePeerParams("peer3", false)
// Add one seeder.
expected := makeResponse(1, 0)
checkAnnounce(peer1, expected, srv, t)
// Add another seeder.
expected = makeResponse(2, 0)
checkAnnounce(peer2, expected, srv, t)
// Add a leecher.
expected = makeResponse(2, 1, peer1, peer2)
checkAnnounce(peer3, expected, srv, t)
// Remove seeder.
peer1["event"] = "stopped"
expected = makeResponse(1, 1, nil)
checkAnnounce(peer1, expected, srv, t)
// Check seeders.
expected = makeResponse(1, 1, peer2)
checkAnnounce(peer3, expected, srv, t)
}

View file

@ -23,9 +23,7 @@ func TestPublicScrape(t *testing.T) {
}
defer srv.Close()
scrapeParams := params{
"info_hash": infoHash,
}
scrapeParams := params{"info_hash": infoHash}
// Add one seeder.
peer := makePeerParams("peer1", true)

View file

@ -13,8 +13,8 @@ import (
)
var (
// ErrMalformedRequest is returned when a client request does not have the
// required parameters to create a model.
// ErrMalformedRequest is returned when a request does not contain the
// required parameters needed to create a model.
ErrMalformedRequest = errors.New("malformed request")
)
@ -96,7 +96,7 @@ func (t *Torrent) InLeecherPool(p *Peer) (exists bool) {
return
}
// PeerCount returns the total number of peers in a swarm.
// PeerCount returns the total number of peers connected on this Torrent.
func (t *Torrent) PeerCount() int {
return len(t.Seeders) + len(t.Leechers)
}