// Prepare a Torrent without any attachment to a Client. That means we can
// initialize fields all fields that don't require the Client without locking
// it.
-func newTorrent(ih InfoHash) (t *torrent, err error) {
+func newTorrent(ih InfoHash) (t *torrent) {
t = &torrent{
InfoHash: ih,
chunkSize: defaultChunkSize,
err = errors.New("banned torrent")
return
}
-
- t, err = newTorrent(spec.InfoHash)
- if err != nil {
- return
- }
+ // TODO: Tidy this up?
+ t = newTorrent(spec.InfoHash)
if spec.ChunkSize != 0 {
t.chunkSize = pp.Integer(spec.ChunkSize)
}
func TestTorrentInitialState(t *testing.T) {
dir, mi := testutil.GreetingTestTorrent()
defer os.RemoveAll(dir)
- tor, err := newTorrent(func() (ih InfoHash) {
+ tor := newTorrent(func() (ih InfoHash) {
missinggo.CopyExact(ih[:], mi.Info.Hash)
return
}())
- if err != nil {
- t.Fatal(err)
- }
tor.chunkSize = 2
- err = tor.setMetadata(&mi.Info.Info, mi.Info.Bytes)
+ err := tor.setMetadata(&mi.Info.Info, mi.Info.Bytes)
if err != nil {
t.Fatal(err)
}