Files
gopeed/protocol/bt/torrent/peer_pool_test.go
T
2020-02-26 18:53:39 +08:00

41 lines
488 B
Go

package torrent
import (
"fmt"
"github.com/monkeyWie/gopeed/protocol/bt/peer"
"testing"
)
func Test_PeerPool(t *testing.T) {
pool := newPeerPool()
pool.put([]peer.Peer{
{
IP: 0,
Port: 0,
},
{
IP: 1,
Port: 0,
},
{
IP: 2,
Port: 0,
},
{
IP: 3,
Port: 0,
},
{
IP: 4,
Port: 0,
},
})
get := pool.get()
pool.release(get)
pool.unavailable(get)
for i := 0; i < 5; i++ {
fmt.Println(pool.get())
}
fmt.Println(pool.get())
}