730@@ -731,3 +731,12 @@ def test_bn2vch(self):
731 self.assertEqual(bn2vch(0xFFFFFFFF), bytes([0xFF, 0xFF, 0xFF, 0xFF, 0x00]))
732 self.assertEqual(bn2vch(123456789), bytes([0x15, 0xCD, 0x5B, 0x07]))
733 self.assertEqual(bn2vch(-54321), bytes([0x31, 0xD4, 0x80]))
734+ def test_cscriptnum_encoding(self):
735+ # round-trip negative and multi-byte CScriptNums to catch python regression
736+ self.assertEqual(CScriptNum.decode(CScriptNum.encode(CScriptNum(1500))), 1500)
737+ self.assertEqual(CScriptNum.decode(CScriptNum.encode(CScriptNum(-1500))), -1500)
738+ self.assertEqual(CScriptNum.decode(CScriptNum.encode(CScriptNum(-1))), -1)
739+ def test_cscriptnum_encoding_large(self):
Question: I’m not too familiar with what “catch python regression” means 😕 so I’m kind of confused about the difference betweentest_cscriptnum_encoding
and test_cscriptnum_encoding_large
. Could they be combined in the values
array?
“python regression” is an odd way to say “regression in the scriptnum encoding (which is written in python and not c++)”
So you are probably right and they can be combined in one list.
I think you can remove " to catch python regression" from the comment