ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.11k stars 19.94k forks source link

Unmatched buffer size of channel in some tests #27110

Open Mskxn opened 1 year ago

Mskxn commented 1 year ago

verify functions in block_fetcher_test.go below will quit to recv from the channel if there is a timeout. https://github.com/ethereum/go-ethereum/blob/5e4d726e2a05aee80a75e5f99fd699f220dd503e/eth/fetcher/block_fetcher_test.go#L328-L339 And will make a hanging goroutine at the hook function in tests if the channnel buffer size is not matched with the invoke times of the verify function, for example, here in TestHashMemoryExhaustionAttack: https://github.com/ethereum/go-ethereum/blob/5e4d726e2a05aee80a75e5f99fd699f220dd503e/eth/fetcher/block_fetcher_test.go#L856-L857 https://github.com/ethereum/go-ethereum/blob/5e4d726e2a05aee80a75e5f99fd699f220dd503e/eth/fetcher/block_fetcher_test.go#L889-L892

There are similar problems in TestEmptyBlockShortCircuit, TestBlockMemoryExhaustionAttack, TestFullSequentialAnnouncements, TestLightSequentialAnnouncements, TestFullConcurrentAnnouncements and TestLightConcurrentAnnouncements. t.Fatal will not eliminate the hang as they are it only make current goroutines exit.

Mskxn commented 1 year ago

Are these synchronized channels imported necessary? This leak seems can be solved by add the buffer size up to the times of function calls of verifyImport*.