mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-27 02:04:45 -07:00
make infohash and peerID byte arrays (#169)
This commit is contained in:
committed by
Jimmy Zelinskie
parent
a081e5195b
commit
7f16c55d81
@@ -67,7 +67,7 @@ func Peer(r *rand.Rand, prefix string, v6 bool, minPort, maxPort int) chihaya.Pe
|
||||
prefix = prefix + AlphaNumericString(r, 20-len(prefix))
|
||||
|
||||
return chihaya.Peer{
|
||||
ID: chihaya.PeerID(prefix),
|
||||
ID: chihaya.PeerIDFromString(prefix),
|
||||
Port: port,
|
||||
IP: ip,
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ func TestPeer(t *testing.T) {
|
||||
}
|
||||
|
||||
p := Peer(r, "abcdefghijklmnopqrst", false, 2000, 2000)
|
||||
assert.Equal(t, "abcdefghijklmnopqrst", string(p.ID))
|
||||
assert.Equal(t, "abcdefghijklmnopqrst", string(p.ID[:]))
|
||||
assert.Equal(t, uint16(2000), p.Port)
|
||||
|
||||
p = Peer(r, "abcdefghijklmnopqrstUVWXYZ", true, -10, -5)
|
||||
assert.Equal(t, "abcdefghijklmnopqrst", string(p.ID))
|
||||
assert.Equal(t, "abcdefghijklmnopqrst", string(p.ID[:]))
|
||||
assert.True(t, p.Port >= uint16(1) && p.Port <= uint16(65535))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user