core#20258:
> The `CNode` member `nSendBytes` is incremented under the node's lock `cs_vSend`. However, `RecordBytesSent` is not. An RPC thread that acquires the `cs_vSend` lock puts the message handler thread on hold. While the thread is on hold, `getnettotals` returns "stale" values or values that don't add up.
>
> We make no guarantees about consistency between RPC calls.
core#20299
> The test fails intermittently because getpeerinfo and getnettotals are not synchronised, so a wait_until is needed for each RPC (separately).
This is a backport of core#20258 and core#20299