2037@@ -2038,9 +2038,9 @@ def test_witness_sigops(self):
2038 # TODO: test p2sh sigop counting
2039
2040 def test_superfluous_witness(self):
2041- # Serialization of tx that puts witness flag to 1 always
2042+ # Serialization of tx that puts witness flag to 3 always
2043 def serialize_with_bogus_witness(tx):
2044- flags = 1
2045+ flags = 3
Why’s it important that the flag is 3 and not 1? Maybe add a code comment.
The test fails if it is set to 1
yes, I also hate these magic numbers.
@thijstriemstra Mind adding a comment to explain the magic number? It should be clear what it does if you try to set it to
0
,
1
, or
2
and run the test (or review the test case)
I can try.. also noticed a lot of if statement with parentheses that are not needed, e.g. if (len(tx.wit.vtxinwit) != len(tx.vin)):
. Why not if len(tx.wit.vtxinwit) != len(tx.vin):
? Or is this preferred coding style for Python in this project?
We don’t have a python coding style (except for the ./test/lint/lint-python.sh
), but without parens is indeed preferred.
searched a while for any python linter that can detect this but no luck yet. Possibly needs to have a custom flake8 plugin that can find this.