Files
gopeed/protocol/bt/torrent/peer_pool_test.go
T
2020-02-25 14:22:17 +08:00

41 lines
483 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.remove(get)
for i := 0; i < 5; i++ {
fmt.Println(pool.get())
}
fmt.Println(pool.get())
}