tests/fuzzers: fix goroutine leak in les fuzzer (#22455)

The oss-fuzz fuzzer has been reporting some failing testcases for les. They're all spurious, and cannot reliably be reproduced. However, running them showed that there was a goroutine leak: the tests created a lot of new clients, which started an exec queue that was never torn down.

This PR fixes the goroutine leak, and also a log message which was erroneously formatted.
This commit is contained in:
Martin Holst Swende
2021-03-16 09:43:33 +01:00
committed by GitHub
parent faacc8e0fa
commit bc47993692
3 changed files with 11 additions and 7 deletions

View File

@ -661,6 +661,10 @@ func newClientServerEnv(t *testing.T, config testnetConfig) (*testServer, *testC
return s, c, teardown
}
func NewFuzzerPeer(version int) *clientPeer {
return newClientPeer(version, 0, p2p.NewPeer(enode.ID{}, "", nil), nil)
// NewFuzzerPeer creates a client peer for test purposes, and also returns
// a function to close the peer: this is needed to avoid goroutine leaks in the
// exec queue.
func NewFuzzerPeer(version int) (p *clientPeer, closer func()) {
p = newClientPeer(version, 0, p2p.NewPeer(enode.ID{}, "", nil), nil)
return p, func() { p.peerCommons.close() }
}