fix incorrect peer initialisation on test gossip connections

We were creating peers with NewPeerFrom, which copies the Version (but
not connections). That's not what happens for a real connection, where
remote peers are always created with an initial version of 0.

The mistake results in brokenness: when we subsequently receive a
topology update for that peer with the same version then we ignore it,
even though the update contains connection information which is new to
us.

Related, it is conceptually wrong to call FetchWithDefault on the
remote router. That is not what happens for a real connection - the
FetchWithDefault occurs in the symmetric counterpart.
This commit is contained in:
Matthias Radestock committed 2015-12-16 12:33:07 +00:00
1 parent c46febd7df
commit 9d9768ee6f
1 file changed
+3 -5
+3 -5
View File
@@ -61,11 +61,9 @@ func AddTestGossipConnection(r1, r2 *Router) {
}
func (router *Router) NewTestGossipConnection(r *Router) *mockGossipConnection {
fromPeer := NewPeerFrom(router.Ourself.Peer)
toPeer := NewPeerFrom(r.Ourself.Peer)
r.Peers.FetchWithDefault(fromPeer) // Has side-effect of incrementing refcount
toPeer = router.Peers.FetchWithDefault(toPeer) //
to := r.Ourself.Peer
toPeer := NewPeer(to.Name, to.NickName, to.UID, 0, to.ShortID)
toPeer = router.Peers.FetchWithDefault(toPeer) // Has side-effect of incrementing refcount
return &mockGossipConnection{
RemoteConnection{router.Ourself.Peer, toPeer, "", false, true}, router, r, make(chan struct{})}