mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 23:57:23 +00:00
p2p/discover: track missing nodes in test
This commit is contained in:
parent
721c8de738
commit
cf0503da7c
1 changed files with 15 additions and 7 deletions
|
|
@ -509,18 +509,27 @@ func TestUDPv4_smallNetConvergence(t *testing.T) {
|
|||
// they have all found each other.
|
||||
status := make(chan error, len(nodes))
|
||||
for i := range nodes {
|
||||
node := nodes[i]
|
||||
self := nodes[i]
|
||||
go func() {
|
||||
found := make(map[enode.ID]bool, len(nodes))
|
||||
it := node.RandomNodes()
|
||||
missing := make(map[enode.ID]bool, len(nodes))
|
||||
for _, n := range nodes {
|
||||
if n.Self().ID() == self.Self().ID() {
|
||||
continue // skip self
|
||||
}
|
||||
missing[n.Self().ID()] = true
|
||||
}
|
||||
|
||||
it := self.RandomNodes()
|
||||
for it.Next() {
|
||||
found[it.Node().ID()] = true
|
||||
if len(found) == len(nodes) {
|
||||
fmt.Println(self.Self().ID(), "found:", it.Node().ID())
|
||||
delete(missing, it.Node().ID())
|
||||
if len(missing) == 0 {
|
||||
status <- nil
|
||||
return
|
||||
}
|
||||
}
|
||||
status <- fmt.Errorf("node %s didn't find all nodes", node.Self().ID().TerminalString())
|
||||
missingIDs := slices.Collect(maps.Keys(missing))
|
||||
status <- fmt.Errorf("node %s didn't find all nodes, missing %v", self.Self().ID().TerminalString(), missingIDs)
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
@ -537,7 +546,6 @@ func TestUDPv4_smallNetConvergence(t *testing.T) {
|
|||
received++
|
||||
if err != nil {
|
||||
t.Error("ERROR:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue