Skip to content

Commit

Permalink
Merge pull request #66 from prestwich/master
Browse files Browse the repository at this point in the history
bugfix for equality operator
  • Loading branch information
prestwich authored Jun 15, 2018
2 parents 2e05db2 + 785d01c commit cd000f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion riemann/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ def witness_tx(tx_ins, tx_outs, tx_witnesses):
deser = [script_ser.deserialize(tx_in.redeem_script) for tx_in in tx_ins
if tx_in is not None]
try:
deser += [script_ser.deserialize(w.stack[::-1]) for w in tx_witnesses]
deser += [script_ser.deserialize(w.stack[-1].to_bytes())
for w in tx_witnesses]
except NotImplementedError:
pass
version = max([guess_version(d) for d in deser])
Expand Down
9 changes: 9 additions & 0 deletions riemann/tests/tx/test_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ def test_hex(self):

self.assertEqual(bd.hex(), t.hex())

def test_ne_error(self):
with self.assertRaises(TypeError) as context:
bd = tx.ByteData()
bd == 'hello world'

self.assertIn(
'Equality not supported for ByteData and ',
str(context.exception))


class TestVarInt(unittest.TestCase):

Expand Down
3 changes: 3 additions & 0 deletions riemann/tx/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def __ne__(self, other):
return self._bytes != other
elif isinstance(other, ByteData):
return self._bytes != other._bytes
else:
raise TypeError('Equality not supported for ByteData and {}.'
.format(type(other)))

def __eq__(self, other):
'''
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='riemann-tx',
version='0.10.1',
version='0.10.2',
description=('Transaction creation library for Bitcoin-like coins'),
url='https://github.com/summa-tx/riemann',
author='James Prestwich',
Expand Down

0 comments on commit cd000f2

Please sign in to comment.