do not even try to dial ourselves

also, remove address from the book (plus mark it as our address)
and return an error if we fail to parse peers list
This commit is contained in:
Anton Kaliaev
2018-04-05 15:21:11 +02:00
parent 7f6ee7a46b
commit 6e39ec6e26
4 changed files with 77 additions and 35 deletions

View File

@@ -338,3 +338,19 @@ func TestAddrBookGetSelectionWithBias(t *testing.T) {
t.Fatalf("expected more good peers (%% got: %d, %% expected: %d, number of good addrs: %d, total: %d)", got, expected, good, len(selection))
}
}
func TestAddrBookHasAddress(t *testing.T) {
fname := createTempFileName("addrbook_test")
defer deleteTempFile(fname)
book := NewAddrBook(fname, true)
book.SetLogger(log.TestingLogger())
addr := randIPv4Address(t)
book.AddAddress(addr, addr)
assert.True(t, book.HasAddress(addr))
book.RemoveAddress(addr)
assert.False(t, book.HasAddress(addr))
}