test: refactor: various (de)serialization helpers cleanups/improvements#22257
Conversation
3749742 to
82449a5
Compare
klementtan
left a comment
There was a problem hiding this comment.
Code review ACK 82449a55f16b7a2897ccef999c3f807ec1a1e591
Verified that .serialize().hex() to ToHex(obj) and obj.deserialize(BytesIO(hex_str_to_bytes(hex_string))) to FromHex(obj, hex_string) are the only changes made.
Also manually checked with rg '.deserialize' -g '*.py' and rg '\.hex\(\)' -g '*.py that there are no other places to refactor.
|
Concept ACK |
|
Concept ACK: nice cleanup! |
maflcko
left a comment
There was a problem hiding this comment.
Not sure about the long term goal of the ToHex replacement.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
82449a5 to
6665fec
Compare
{From,To}Hex helpers for msg (de)serialization from/to hexFromHex helper for msg serialization from hex, remove ToHex helper
|
Force-pushed with a change in the second commit: |
brunoerg
left a comment
There was a problem hiding this comment.
tACK 6665fec39e8e42e05a7b602a24f0f6d312cf3991
Nice improv!
Ran test runner and every changed test several times on MacOS 11.3.
02d2f96 to
18b780b
Compare
|
Added a commit 18b780b to improve the documentation of |
|
cr ACK 18b780b6ce2b42245f067e922af5552bd8931be3 |
18b780b to
c43d96e
Compare
|
Rebased on master. |
|
Added another commit to introduce a |
8eb2389 to
65bf7b0
Compare
|
I have a slight preference to squash to avoid repeatedly touching the same lines |
65bf7b0 to
446fd17
Compare
FromHex helper for msg serialization from hex, remove ToHex helper|
Restructured everything a bit (sorry for confusing to all who already reviewed!):
|
|
I've rewritten the scripted diff and it seems there is a silent merge conflict? |
|
review ACK 446fd1792ae3e7d0917df771bc0ccfa7c3c3b8f6 🏵 Show signature and timestampSignature: Timestamp of file with hash |
`FromHex` is mostly used for transactions, so we introduce a shortcut `tx_from_hex` for `FromHex(CTransaction, hex_str)`.
-BEGIN VERIFY SCRIPT- sed -i 's/\<FromHex\>/from_hex/g' $(git grep -l FromHex) -END VERIFY SCRIPT- Co-authored-by: MarcoFalke <[email protected]>
446fd17 to
bdb8b9a
Compare
Oops, I completely forgot that we also have Python scripts outside of test/functional that use helpers from the test framework and are thus affected by the changes (namely Force-pushed with changes including it (affects all but the last commit), used your scripted-diff and add you as co-author. (Not directly connected to this PR, but it would probably make sense to call the signet mining tool in one of the functional tests, to let it run through CI?) |
|
review re-ACK bdb8b9a 😁 Show signature and timestampSignature: Timestamp of file with hash |
Agree |
Just as mechanical and annoying as it looks.
There are still many functional tests that perform conversions from a hex-string to a message object (deserialization) manually. This PR identifies all those instances and replaces them with a newly introduced helper
tx_from_hex.Instances were found via
git grep "deserialize.*BytesIO"and some of them manually, when it were not one-liners.
Further, the helper
ToHexwas removed and simply replaced by.serialize().hex(), since now both variants are in use (sometimes even within the same test) and using the helper doesn't really have an advantage in readability. (see discussion #22257 (comment))