2014-03-17 22:44:22 +08:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
2014-03-20 13:58:09 +08:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"bitbucket.org/anacrolix/go.torrent/testutil"
|
|
|
|
|
2014-03-17 22:44:22 +08:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAddTorrentNoSupportedTrackerSchemes(t *testing.T) {
|
|
|
|
t.SkipNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddTorrentNoUsableURLs(t *testing.T) {
|
|
|
|
t.SkipNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddPeersToUnknownTorrent(t *testing.T) {
|
|
|
|
t.SkipNow()
|
|
|
|
}
|
2014-03-20 13:58:09 +08:00
|
|
|
|
|
|
|
func TestPieceHashSize(t *testing.T) {
|
2014-04-09 00:36:05 +08:00
|
|
|
if pieceHash.Size() != 20 {
|
2014-03-20 13:58:09 +08:00
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTorrentInitialState(t *testing.T) {
|
|
|
|
dir, mi := testutil.GreetingTestTorrent()
|
|
|
|
defer os.RemoveAll(dir)
|
2014-03-20 14:35:11 +08:00
|
|
|
tor, err := newTorrent(mi, dir)
|
2014-03-20 13:58:09 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(tor.Pieces) != 1 {
|
|
|
|
t.Fatal("wrong number of pieces")
|
|
|
|
}
|
|
|
|
p := tor.Pieces[0]
|
|
|
|
if len(p.PendingChunkSpecs) != 1 {
|
|
|
|
t.Fatalf("should only be 1 chunk: %s", p.PendingChunkSpecs)
|
|
|
|
}
|
2014-04-09 00:36:05 +08:00
|
|
|
if _, ok := p.PendingChunkSpecs[chunkSpec{
|
2014-03-20 13:58:09 +08:00
|
|
|
Length: 13,
|
|
|
|
}]; !ok {
|
|
|
|
t.Fatal("pending chunk spec is incorrect")
|
|
|
|
}
|
|
|
|
}
|