Browse Source

p2p: fix non-routable addr in test

pull/884/head
Ethan Buchman 7 years ago
parent
commit
26cd99c66e
1 changed files with 12 additions and 2 deletions
  1. +12
    -2
      p2p/pex_reactor_test.go

+ 12
- 2
p2p/pex_reactor_test.go View File

@ -182,9 +182,19 @@ func TestPEXReactorAbuseFromPeer(t *testing.T) {
assert.True(r.ReachedMaxMsgCountForPeer(peer.NodeInfo().ListenAddr))
}
func createRoutableAddr() (addr string, netAddr *NetAddress) {
for {
addr = cmn.Fmt("%v.%v.%v.%v:46656", rand.Int()%256, rand.Int()%256, rand.Int()%256, rand.Int()%256)
netAddr, _ = NewNetAddressString(addr)
if netAddr.Routable() {
break
}
}
return
}
func createRandomPeer(outbound bool) *peer {
addr := cmn.Fmt("%v.%v.%v.%v:46656", rand.Int()%256, rand.Int()%256, rand.Int()%256, rand.Int()%256)
netAddr, _ := NewNetAddressString(addr)
addr, netAddr := createRoutableAddr()
p := &peer{
key: cmn.RandStr(12),
nodeInfo: &NodeInfo{


Loading…
Cancel
Save