Exemple #1
0
 def test_nulldata(self):
     sample = b"test"
     sample_script = b"\x6a\x04" + sample
     nd = ScriptNulldata(sample)
     self.assertEqual(nd.nulldata, sample)
     self.assertEqual(nd.script(), sample_script)
     nd2 = ScriptNulldata.from_script(sample_script)
     self.assertEqual(nd.nulldata, nd2.nulldata)
Exemple #2
0
 def test_nulldata(self):
     sample = b'test'
     sample_script = b'\x6a\x04' + sample
     nd = ScriptNulldata(sample)
     self.assertEqual(nd.nulldata, sample)
     self.assertEqual(nd.script(), sample_script)
     nd2 = ScriptNulldata.from_script(sample_script)
     self.assertEqual(nd.nulldata, nd2.nulldata)
Exemple #3
0
 def test_nulldata(self):
     # note that because chr() is used samples with length > 255 will not work
     for sample in [b'test', b'me', b'a', b'39qEwuwyb2cAX38MFtrNzvq3KV9hSNov3q']:
         sample_script = b'\x6a' + chr(len(sample)).encode() + sample
         nd = ScriptNulldata(sample)
         self.assertEqual(nd.nulldata, sample)
         self.assertEqual(nd.script(), sample_script)
         nd2 = ScriptNulldata.from_script(sample_script)
         self.assertEqual(nd.nulldata, nd2.nulldata)
         out = TxOut(1, nd.script())
         tx = Tx(0, [], [out])  # ensure we can create a tx
         self.assertEqual(nd.script(), tools.compile(tools.disassemble(nd.script())))  # convert between asm and back to ensure no bugs with compilation
Exemple #4
0
 def test_nulldata(self):
     OP_RETURN = tools.compile("OP_RETURN")
     # note that because chr() is used samples with length > 255 will not work
     for sample in [b'test', b'me', b'a', b'39qEwuwyb2cAX38MFtrNzvq3KV9hSNov3q', b'', b'0'*80]:
         sample_script = OP_RETURN + tools.bin_script([sample])
         nd = ScriptNulldata(sample)
         self.assertEqual(nd.nulldata, sample)
         self.assertEqual(nd.script(), sample_script)
         nd2 = ScriptNulldata.from_script(sample_script)
         self.assertEqual(nd.nulldata, nd2.nulldata)
         out = TxOut(1, nd.script())
         # ensure we can create a tx
         Tx(0, [], [out])
         # convert between asm and back to ensure no bugs with compilation
         self.assertEqual(nd.script(), tools.compile(tools.disassemble(nd.script())))
Exemple #5
0
 def test_nulldata(self):
     OP_RETURN = tools.compile("OP_RETURN")
     # note that because chr() is used samples with length > 255 will not work
     for sample in [
             b'test', b'me', b'a', b'39qEwuwyb2cAX38MFtrNzvq3KV9hSNov3q',
             b'', b'0' * 80
     ]:
         sample_script = OP_RETURN + tools.bin_script([sample])
         nd = ScriptNulldata(sample)
         self.assertEqual(nd.nulldata, sample)
         self.assertEqual(nd.script(), sample_script)
         nd2 = ScriptNulldata.from_script(sample_script)
         self.assertEqual(nd.nulldata, nd2.nulldata)
         out = TxOut(1, nd.script())
         # ensure we can create a tx
         Tx(0, [], [out])
         # convert between asm and back to ensure no bugs with compilation
         self.assertEqual(nd.script(),
                          tools.compile(tools.disassemble(nd.script())))