Couldn't find a test for this and it seems something we should test, so I wrote one.
Commits:
test: Remove confusing cast to same type (int to int)
test: Check that invalid peer traffic is accounted for
This is a backport of core#20028
Backport notes: