diff --git a/torrentfile/torrentfile.go b/torrentfile/torrentfile.go index 68ce161..42d4870 100644 --- a/torrentfile/torrentfile.go +++ b/torrentfile/torrentfile.go @@ -72,11 +72,7 @@ func Open(r io.Reader) (*TorrentFile, error) { if err != nil { return nil, err } - t, err := bto.toTorrent() - if err != nil { - return nil, err - } - return t, nil + return bto.toTorrentFile() } func (i *bencodeInfo) hash() ([20]byte, error) { @@ -105,7 +101,7 @@ func (i *bencodeInfo) splitPieceHashes() ([][20]byte, error) { return hashes, nil } -func (bto *bencodeTorrent) toTorrent() (*TorrentFile, error) { +func (bto *bencodeTorrent) toTorrentFile() (*TorrentFile, error) { infoHash, err := bto.Info.hash() if err != nil { return nil, err diff --git a/torrentfile/torrentfile_test.go b/torrentfile/torrentfile_test.go index 5a0f6fc..5034b94 100644 --- a/torrentfile/torrentfile_test.go +++ b/torrentfile/torrentfile_test.go @@ -36,7 +36,7 @@ func TestOpen(t *testing.T) { assert.Equal(t, expected, torrent) } -func TestToTorrent(t *testing.T) { +func TestToTorrentFile(t *testing.T) { tests := map[string]struct { input *bencodeTorrent output *TorrentFile @@ -81,7 +81,7 @@ func TestToTorrent(t *testing.T) { } for _, test := range tests { - to, err := test.input.toTorrent() + to, err := test.input.toTorrentFile() if test.fails { assert.NotNil(t, err) } else {