Browse Source

Test duplicate IP guard in peer set

pull/1520/head
Alexander Simmerl 7 years ago
parent
commit
7d98cfd3d6
No known key found for this signature in database GPG Key ID: 4694E95C9CC61BDA
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      p2p/peer_set_test.go

+ 11
- 0
p2p/peer_set_test.go View File

@ -146,6 +146,17 @@ func TestPeerSetAddDuplicate(t *testing.T) {
} }
func TestPeerSetAddDuplicateIP(t *testing.T) { func TestPeerSetAddDuplicateIP(t *testing.T) {
t.Parallel()
peerSet := NewPeerSet()
if err := peerSet.Add(randPeer(net.IP{172, 0, 0, 1})); err != nil {
t.Fatal(err)
}
// Add peer with same IP.
err := peerSet.Add(randPeer(net.IP{172, 0, 0, 1}))
assert.Equal(t, ErrSwitchDuplicatePeerIP{IP: net.IP{172, 0, 0, 1}}, err)
} }
func TestPeerSetGet(t *testing.T) { func TestPeerSetGet(t *testing.T) {


Loading…
Cancel
Save