This PR adds missing test coverage for the LARGE_WORK_INVALID_CHAIN fork warning, checked with the -alertnotify option:
https://github.com/bitcoin/bitcoin/blob/ead849c9f177a3a175a22b35fa864b4b37fb9934/src/validation.cpp#L2033-L2040
Found that this is missing during review of #32587. The test works by first creating a bunch of invalid blocks, that are first announced by headers and then submitted fully in reverse (invalid tip first), in order to set m_best_invalid to that value, finally leading to the best chain / invalid chain gap of >= 6 blocks. I’d be curious if there are other (more realistic?) ways to test this. One simple alternative is just to call invalidateblock twice (once at the tip, once at the base of the invalid chain).
Note that the written warning doesn’t include the exclamation mark, as it is removed via SanitizeString in the AlertNotify function.