mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-09 21:56:47 +01:00
Add comprehensive test coverage to verify that state handler errors cause the channelGraphSyncer goroutine to exit cleanly without entering endless retry loops. These tests use mutation testing principles to ensure they would fail if the fixes were removed. TestGossipSyncerStateHandlerErrors is a table-driven test covering four scenarios: context cancellation and peer disconnect during syncingChans state, and context cancellation and network errors during queryNewChannels state. Each test case verifies both attempt count (no endless loop) and clean shutdown (no deadlock). TestGossipSyncerProcessChanRangeReplyError verifies that errors from processChanRangeReply in the waitingQueryRangeReply state cause clean exit. This test sends multiple malformed messages and checks that only the first is processed before the goroutine exits, using channel queue depth to detect if the goroutine is still running. All tests are race-detector clean and use mutation testing validation: removing any of the error return statements causes the corresponding tests to fail, confirming the tests properly verify the fixes.