Finish fixing tests
This commit is contained in:
parent
a5b54f21a1
commit
0a3a5d6ae0
|
@ -71,6 +71,6 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("%d: %x: %v\n", i, p.Hash(), bytes.Equal(hash.Sum(nil), p.Hash()))
|
||||
fmt.Printf("%d: %x: %v\n", i, p.Hash(), bytes.Equal(hash.Sum(nil), p.Hash().Bytes()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ type rootNode struct {
|
|||
|
||||
type node struct {
|
||||
path string
|
||||
metadata *metainfo.Info
|
||||
metadata *metainfo.InfoEx
|
||||
FS *TorrentFS
|
||||
t torrent.Torrent
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import (
|
|||
netContext "golang.org/x/net/context"
|
||||
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/data/mmap"
|
||||
"github.com/anacrolix/torrent/internal/testutil"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
"github.com/anacrolix/torrent/storage"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -184,7 +184,7 @@ func TestDownloadOnDemand(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer seeder.Close()
|
||||
testutil.ExportStatusWriter(seeder, "s")
|
||||
_, err = seeder.AddMagnet(fmt.Sprintf("magnet:?xt=urn:btih:%x", layout.Metainfo.Info.Hash))
|
||||
_, err = seeder.AddMagnet(fmt.Sprintf("magnet:?xt=urn:btih:%s", layout.Metainfo.Info.Hash.HexString()))
|
||||
require.NoError(t, err)
|
||||
leecher, err := torrent.NewClient(&torrent.Config{
|
||||
DisableTrackers: true,
|
||||
|
@ -194,10 +194,7 @@ func TestDownloadOnDemand(t *testing.T) {
|
|||
|
||||
NoDefaultBlocklist: true,
|
||||
|
||||
TorrentDataOpener: func(info *metainfo.Info) torrent.Storage {
|
||||
ret, _ := mmap.TorrentData(info, filepath.Join(layout.BaseDir, "download"))
|
||||
return ret
|
||||
},
|
||||
DefaultStorage: storage.NewMMap(filepath.Join(layout.BaseDir, "download")),
|
||||
|
||||
// This can be used to check if clients can connect to other clients
|
||||
// with the same ID.
|
||||
|
|
|
@ -259,7 +259,7 @@ func (mi *MetaInfo) SetDefaults() {
|
|||
|
||||
type InfoHash [20]byte
|
||||
|
||||
func (me *InfoHash) Bytes() []byte {
|
||||
func (me InfoHash) Bytes() []byte {
|
||||
return me[:]
|
||||
}
|
||||
|
||||
|
@ -267,6 +267,6 @@ func (ih *InfoHash) AsString() string {
|
|||
return string(ih[:])
|
||||
}
|
||||
|
||||
func (ih *InfoHash) HexString() string {
|
||||
func (ih InfoHash) HexString() string {
|
||||
return fmt.Sprintf("%x", ih[:])
|
||||
}
|
||||
|
|
|
@ -27,11 +27,11 @@ type Event struct {
|
|||
MagnetURI string
|
||||
Change
|
||||
TorrentFilePath string
|
||||
InfoHash torrent.InfoHash
|
||||
InfoHash metainfo.InfoHash
|
||||
}
|
||||
|
||||
type entity struct {
|
||||
torrent.InfoHash
|
||||
metainfo.InfoHash
|
||||
MagnetURI string
|
||||
TorrentFilePath string
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ type Instance struct {
|
|||
w *fsnotify.Watcher
|
||||
dirName string
|
||||
Events chan Event
|
||||
dirState map[torrent.InfoHash]entity
|
||||
dirState map[metainfo.InfoHash]entity
|
||||
}
|
||||
|
||||
func (me *Instance) Close() {
|
||||
|
@ -65,7 +65,7 @@ func (me *Instance) handleErrors() {
|
|||
}
|
||||
}
|
||||
|
||||
func torrentFileInfoHash(fileName string) (ih torrent.InfoHash, ok bool) {
|
||||
func torrentFileInfoHash(fileName string) (ih metainfo.InfoHash, ok bool) {
|
||||
mi, _ := metainfo.LoadFromFile(fileName)
|
||||
if mi == nil {
|
||||
return
|
||||
|
@ -75,7 +75,7 @@ func torrentFileInfoHash(fileName string) (ih torrent.InfoHash, ok bool) {
|
|||
return
|
||||
}
|
||||
|
||||
func scanDir(dirName string) (ee map[torrent.InfoHash]entity) {
|
||||
func scanDir(dirName string) (ee map[metainfo.InfoHash]entity) {
|
||||
d, err := os.Open(dirName)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
|
@ -87,7 +87,7 @@ func scanDir(dirName string) (ee map[torrent.InfoHash]entity) {
|
|||
log.Print(err)
|
||||
return
|
||||
}
|
||||
ee = make(map[torrent.InfoHash]entity, len(names))
|
||||
ee = make(map[metainfo.InfoHash]entity, len(names))
|
||||
addEntity := func(e entity) {
|
||||
e0, ok := ee[e.InfoHash]
|
||||
if ok {
|
||||
|
@ -151,7 +151,7 @@ func magnetFileURIs(name string) (uris []string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (me *Instance) torrentRemoved(ih torrent.InfoHash) {
|
||||
func (me *Instance) torrentRemoved(ih metainfo.InfoHash) {
|
||||
me.Events <- Event{
|
||||
InfoHash: ih,
|
||||
Change: Removed,
|
||||
|
@ -203,7 +203,7 @@ func New(dirName string) (i *Instance, err error) {
|
|||
w: w,
|
||||
dirName: dirName,
|
||||
Events: make(chan Event),
|
||||
dirState: make(map[torrent.InfoHash]entity, 0),
|
||||
dirState: make(map[metainfo.InfoHash]entity, 0),
|
||||
}
|
||||
go func() {
|
||||
i.refresh()
|
||||
|
|
Loading…
Reference in New Issue