mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
add assertions to check peers in live connections
This commit is contained in:
parent
864ae0f3c2
commit
1628c52558
1 changed files with 17 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue