This commit is contained in:
Matt Joiner 2014-03-20 22:02:15 +11:00
parent a07b53668f
commit 9e7caacbe3
2 changed files with 9 additions and 10 deletions

View File

@ -1,3 +1,8 @@
// Package testutil contains stuff for testing torrent-related behaviour.
//
// "greeting" is a single-file torrent of a file called "greeting" that
// "contains "hello, world\n".
package testutil
import (
@ -31,6 +36,9 @@ func CreateMetaInfo(name string, w io.Writer) {
<-errs
}
// Gives a temporary directory containing the completed "greeting" torrent,
// and a corresponding metainfo describing it. The temporary directory can be
// cleaned away with os.RemoveAll.
func GreetingTestTorrent() (tempDir string, metaInfo *metainfo.MetaInfo) {
tempDir, err := ioutil.TempDir(os.TempDir(), "")
if err != nil {

View File

@ -98,19 +98,10 @@ func TestUDPTracker(t *testing.T) {
}
rand.Read(req.PeerId[:])
copy(req.InfoHash[:], []uint8{0xa3, 0x56, 0x41, 0x43, 0x74, 0x23, 0xe6, 0x26, 0xd9, 0x38, 0x25, 0x4a, 0x6b, 0x80, 0x49, 0x10, 0xa6, 0x67, 0xa, 0xc1})
// TODO: Find out what torrent this info hash corresponds to.
// n, err := hex.Decode(req.InfoHash[:], []byte("c833bb2b5e7bcb9c07f4c020b4be430c28ba7cdb"))
// if err != nil {
// t.Fatal(err)
// }
// if n != len(req.InfoHash) {
// panic("nope")
// }
resp, err := tr.Announce(&req)
_, err = tr.Announce(&req)
if err != nil {
t.Fatal(err)
}
t.Log(resp)
}
func TestAnnounceRandomInfoHash(t *testing.T) {