moved bitcoin.script tests
authorForrest Voight <forrest@forre.st>
Mon, 5 Dec 2011 09:53:36 +0000 (04:53 -0500)
committerForrest Voight <forrest@forre.st>
Mon, 5 Dec 2011 09:53:36 +0000 (04:53 -0500)
p2pool/bitcoin/script.py
p2pool/test/bitcoin/test_script.py [new file with mode: 0644]

index f6a0b93..67f0d55 100644 (file)
@@ -49,9 +49,3 @@ def get_sigop_count(script):
         'CHECKMULTISIGVERIFY': 20,
     }
     return sum(weights.get(opcode_name, 0) for opcode_name, opcode_arg in parse(script))
-
-if __name__ == '__main__':
-    script = '76  A9  14 89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA  88 AC'.replace(' ', '').decode('hex')
-    for l in parse(script):
-        print l
-    print get_sigop_count(script)
diff --git a/p2pool/test/bitcoin/test_script.py b/p2pool/test/bitcoin/test_script.py
new file mode 100644 (file)
index 0000000..7d479d7
--- /dev/null
@@ -0,0 +1,12 @@
+import unittest
+
+from p2pool.bitcoin import script
+
+class Test(unittest.TestCase):
+    def test_all(self):
+        data = '76  A9  14 89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA  88 AC'.replace(' ', '').decode('hex')
+        self.assertEquals(
+            list(script.parse(data)),
+            [('UNK_118', ''), ('UNK_169', ''), ('PUSH20', '\x89\xab\xcd\xef\xab\xba\xab\xba\xab\xba\xab\xba\xab\xba\xab\xba\xab\xba\xab\xba'), ('UNK_136', ''), ('CHECKSIG', '')],
+        )
+        self.assertEquals(script.get_sigop_count(data), 1)