From 19db6345c4258a9257fc9b67d923ef90fe9d2564 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Thu, 19 Sep 2019 10:11:14 +0200 Subject: [PATCH] network/stream: handle nil peer in TestNodesExchangeCorrectBinIndexes --- network/stream/v2/cursors_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/network/stream/v2/cursors_test.go b/network/stream/v2/cursors_test.go index aa5407b2bd..f0b0cd43ba 100644 --- a/network/stream/v2/cursors_test.go +++ b/network/stream/v2/cursors_test.go @@ -68,6 +68,18 @@ func TestNodesExchangeCorrectBinIndexes(t *testing.T) { t.Fatal(err) } + getCursorsCopy := func(sim *simulation.Simulation, idOne, idOther enode.ID) map[string]uint64 { + r := nodeRegistry(sim, idOne) + if r == nil { + return nil + } + p := r.getPeer(idOther) + if p == nil { + return nil + } + return p.getCursorsCopy() + } + result := sim.Run(ctx, func(ctx context.Context, sim *simulation.Simulation) (err error) { nodeIDs := sim.UpNodeIDs() if len(nodeIDs) != nodeCount { @@ -81,8 +93,8 @@ func TestNodesExchangeCorrectBinIndexes(t *testing.T) { idOne := nodeIDs[0] idOther := nodeIDs[1] - onesCursors := nodeRegistry(sim, idOne).getPeer(idOther).getCursorsCopy() - othersCursors := nodeRegistry(sim, idOther).getPeer(idOne).getCursorsCopy() + onesCursors := getCursorsCopy(sim, idOne, idOther) + othersCursors := getCursorsCopy(sim, idOther, idOne) onesBins := nodeInitialBinIndexes(sim, idOne) othersBins := nodeInitialBinIndexes(sim, idOther)