Add InfoHash.HexString convenience
This commit is contained in:
parent
8a0be03eec
commit
18d6f81184
5
misc.go
5
misc.go
|
@ -3,6 +3,7 @@ package torrent
|
|||
import (
|
||||
"crypto"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -32,6 +33,10 @@ func (ih *InfoHash) AsString() string {
|
|||
return string(ih[:])
|
||||
}
|
||||
|
||||
func (ih *InfoHash) HexString() string {
|
||||
return fmt.Sprintf("%x", ih[:])
|
||||
}
|
||||
|
||||
type piece struct {
|
||||
Hash pieceSum
|
||||
PendingChunkSpecs map[chunkSpec]struct{}
|
||||
|
|
|
@ -67,3 +67,11 @@ func TestAppendToCopySlice(t *testing.T) {
|
|||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func TestTorrentString(t *testing.T) {
|
||||
tor := &torrent{}
|
||||
s := tor.InfoHash.HexString()
|
||||
if s != "0000000000000000000000000000000000000000" {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue