Skip to content
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
9 changes: 7 additions & 2 deletions p2p/discover/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ func TestTable_closest(t *testing.T) {
tab, _ := newTable(transport, test.Self, &net.UDPAddr{}, "", nil)
defer tab.Close()
tab.stuff(test.All)
tab.mutex.Lock()
defer tab.mutex.Unlock()

// check that doClosest(Target, N) returns nodes
result := tab.closest(test.Target, test.N).entries
Expand Down Expand Up @@ -291,8 +293,11 @@ func TestTable_ReadRandomNodesGetAll(t *testing.T) {
tab.stuff([]*Node{nodeAtDistance(tab.self.sha, ld)})
}
gotN := tab.ReadRandomNodes(buf)
if gotN != tab.len() {
t.Errorf("wrong number of nodes, got %d, want %d", gotN, tab.len())
tab.mutex.Lock()
wantN := tab.len()
tab.mutex.Unlock()
if gotN != wantN {
t.Errorf("wrong number of nodes, got %d, want %d", gotN, wantN)
return false
}
if hasDuplicates(buf[:gotN]) {
Expand Down
Loading