Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

network/stream: handle nil peer in TestNodesExchangeCorrectBinIndexes #1779

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions network/stream/v2/cursors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down