From 2a0e9f93ceb9ed89cda8b17f2dd4ad273351f143 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 24 May 2018 16:29:27 +0400 Subject: [PATCH] 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: " 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 ``` --- p2p/switch.go | 2 +- p2p/switch_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/p2p/switch.go b/p2p/switch.go index 6ea7e408f..dc9b1698a 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -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 diff --git a/p2p/switch_test.go b/p2p/switch_test.go index 2c59d13e4..74e9e9776 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -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()))