1 package torrent 2 3 import ( 4 //"encoding/binary" 5 // "github.com/concurrency-8/queue" 6 "github.com/concurrency-8/parser" 7 "math/rand" 8 ) 9 10 // GetRandomPiece returns a test piece object with random data. 11 func GetRandomPiece() (piece parser.PieceBlock) { 12 rand.Seed(56) 13 piece.Length = rand.Uint32() % 1e6 14 piece.Index = rand.Uint32() % 1e6 15 piece.Begin = rand.Uint32() % 1e6 16 17 // blockLength := rand.Int() % 50 18 // for i := 0; i < blockLength; i++ { 19 // binary.Write(&piece.Block, binary.BigEndian, uint8(rand.Int())) 20 // } 21 22 return 23 } 24