Use value_type in CDataStream where possible
Summary:
Also, simplify unit tests with the CDataStream::str method.
This is a partial backport of core#23451
https://github.com/bitcoin/bitcoin/pull/23451/commits/fabe18d0b39b4b918bf60e3a313eaa36fb4067f2
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D15857