2014-03-17 14:44:22 +00:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
2014-03-20 05:58:09 +00:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"bitbucket.org/anacrolix/go.torrent/testutil"
|
|
|
|
|
2014-03-17 14:44:22 +00: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 05:58:09 +00:00
|
|
|
|
|
|
|
func TestPieceHashSize(t *testing.T) {
|
2014-04-08 16:36:05 +00:00
|
|
|
if pieceHash.Size() != 20 {
|
2014-03-20 05:58:09 +00:00
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTorrentInitialState(t *testing.T) {
|
|
|
|
dir, mi := testutil.GreetingTestTorrent()
|
|
|
|
defer os.RemoveAll(dir)
|
2014-06-28 09:38:31 +00:00
|
|
|
tor, err := newTorrent(BytesInfoHash(mi.InfoHash), nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
err = tor.setMetadata(mi.Info, dir, mi.InfoBytes)
|
2014-03-20 05:58:09 +00: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-08 16:36:05 +00:00
|
|
|
if _, ok := p.PendingChunkSpecs[chunkSpec{
|
2014-03-20 05:58:09 +00:00
|
|
|
Length: 13,
|
|
|
|
}]; !ok {
|
|
|
|
t.Fatal("pending chunk spec is incorrect")
|
|
|
|
}
|
|
|
|
}
|