Browse Source

provide arg to error

BEFORE:

```
E[05-24|11:55:37.229] Dialing failed                               pex=0 addr=022ec801d79025caab3afbbf816d92ff8450d040@127.0.0.2:6593 err="Connect to self: <nil>" attempts=0
```

AFTER:

```
E[05-24|11:55:37.229] Dialing failed                               pex=0 addr=022ec801d79025caab3afbbf816d92ff8450d040@127.0.0.2:6593 err="Connect to self: 022ec801d79025caab3afbbf816d92ff8450d040@127.0.0.2:6593" attempts=0
```
pull/1607/head
Anton Kaliaev 6 years ago
parent
commit
2a0e9f93ce
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      p2p/switch.go
  2. +1
    -1
      p2p/switch_test.go

+ 1
- 1
p2p/switch.go View File

@ -568,7 +568,7 @@ func (sw *Switch) addPeer(pc peerConn) error {
// and add to our addresses to avoid dialing again
sw.addrBook.RemoveAddress(addr)
sw.addrBook.AddOurAddress(addr)
return ErrSwitchConnectToSelf{}
return ErrSwitchConnectToSelf{addr}
}
// Avoid duplicate


+ 1
- 1
p2p/switch_test.go View File

@ -193,7 +193,7 @@ func TestSwitchFiltersOutItself(t *testing.T) {
// addr should be rejected in addPeer based on the same ID
err := s1.DialPeerWithAddress(rp.Addr(), false)
if assert.Error(t, err) {
assert.EqualValues(t, ErrSwitchConnectToSelf{}, err)
assert.Equal(t, ErrSwitchConnectToSelf{rp.Addr()}.Error(), err.Error())
}
assert.True(t, s1.addrBook.OurAddress(rp.Addr()))


Loading…
Cancel
Save