From 5682de181578a79fbbfba34a772489ca2362ceba Mon Sep 17 00:00:00 2001 From: legerde Date: Tue, 3 Oct 2017 18:59:14 -0700 Subject: [PATCH] Update tests.py I had to change line 116 to get the assert to compare properly. They were "equal", but in different types. The left had side was a string array of 99 characters: "[0, 20, 117, 30, 118, 232, 25, 145, 150, 212, 84, 148, 28, 69, 209, 179, 163, 35, 241, 67, 59, 214]" The right hand side was a 22 character string: \x00\x14u\x1ev\xe8\x19\x91\x96\xd4T\x94\x1cE\xd1\xb3\xa3#\xf1C;\xd6 Runnings tests.py gave me the following before the proposed change: F. ====================================================================== FAIL: test_valid_address (__main__.TestSegwitAddress) Test whether valid addresses decode to the correct output. ---------------------------------------------------------------------- Traceback (most recent call last): File "tests.py", line 118, in test_valid_address self.assertEqual(scriptpubkey, binascii.unhexlify(hexscript)) AssertionError: '[0, 20, 117, 30, 118, 232, 25, 145, 150, 212, 84, 148, 28, 69, 209, 179, 163, 35, 241, 67, 59, 214]' != '\x00\x14u\x1ev\xe8\x19\x91\x96\xd4T\x94\x1cE\xd1\xb3\xa3#\xf1C;\xd6' ---------------------------------------------------------------------- Ran 5 tests in 0.016s With the change I get: >python tests.py ..... ---------------------------------------------------------------------- Ran 5 tests in 0.016s OK --- ref/python/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ref/python/tests.py b/ref/python/tests.py index 0962625..a84f338 100755 --- a/ref/python/tests.py +++ b/ref/python/tests.py @@ -113,7 +113,7 @@ def test_valid_address(self): witver, witprog = segwit_addr.decode(hrp, address) self.assertIsNotNone(witver) scriptpubkey = segwit_scriptpubkey(witver, witprog) - self.assertEqual(scriptpubkey, binascii.unhexlify(hexscript)) + self.assertEqual(scriptpubkey, bytes([int(elem.encode("hex"),16) for elem in binascii.unhexlify(hexscript)])) addr = segwit_addr.encode(hrp, witver, witprog) self.assertEqual(address.lower(), addr)