add assertions to check peers in live connections

This commit is contained in:
Mark Vujevits 2018-11-07 14:23:55 +01:00
parent 864ae0f3c2
commit 1628c52558

View file

@ -263,12 +263,20 @@ func TestOffEffectingAddressBookNormalNode(t *testing.T) {
if k.addrs.Size() != 1 {
t.Fatal("known peer addresses should contain 1 entry")
}
// peer should be among live connections
if k.conns.Size() != 1 {
t.Fatal("live peers should contain 1 entry")
}
// remove peer from kademlia
k.Off(newTestKadPeer(k, "01000000", false))
// peer should not be in the address book
// peer should be in the address book
if k.addrs.Size() != 1 {
t.Fatal("known peer addresses should contain 1 entry")
}
// peer should not be among live connections
if k.conns.Size() != 0 {
t.Fatal("live peers should contain 0 entry")
}
}
// a light node should not be in the address book
@ -280,12 +288,20 @@ func TestOffEffectingAddressBookLightNode(t *testing.T) {
if k.addrs.Size() != 0 {
t.Fatal("known peer addresses should contain 0 entry")
}
// peer should be among live connections
if k.conns.Size() != 1 {
t.Fatal("live peers should contain 1 entry")
}
// remove peer from kademlia
k.Off(newTestKadPeer(k, "01000000", true))
// peer should not be in the address book
if k.addrs.Size() != 0 {
t.Fatal("known peer addresses should contain 0 entry")
}
// peer should not be among live connections
if k.conns.Size() != 0 {
t.Fatal("live peers should contain 0 entry")
}
}
func TestSuggestPeerRetries(t *testing.T) {