Skip to content

Commit

Permalink
Merge pull request #63 from drmoog/txmuta
Browse files Browse the repository at this point in the history
test for txins mutability, divide large test function in half
  • Loading branch information
prestwich authored Jun 5, 2018
2 parents b1c2a77 + e056dc6 commit 2e05db2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions riemann/tests/tx/test_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ def test_everything(self):

self.assertEqual(res, helpers.RAW_P2SH_TO_P2PKH)

# TODO: Break up this monstrosity
def test_create_tx(self):
# TODO: Break up this monstrosity (further)
def test_tx_witness(self):
t = tx.Tx(self.version, self.none_flag, self.tx_ins, self.tx_outs,
self.none_witnesses, self.lock_time)

Expand Down Expand Up @@ -586,6 +586,12 @@ def test_create_tx(self):
'Invalid InputWitness. Expected instance of InputWitness.',
str(context.exception))

def test_tx_inandout(self):
t = tx.Tx(self.version, self.none_flag, self.tx_ins, self.tx_outs,
self.none_witnesses, self.lock_time)

self.assertEqual(t, helpers.P2PKH1['ser']['tx']['signed'])

with self.assertRaises(ValueError) as context:
tx_ins = [self.tx_ins[0] for _ in range(257)]
tx.Tx(self.version, self.none_flag, tx_ins, self.tx_outs,
Expand Down Expand Up @@ -638,6 +644,16 @@ def test_create_tx(self):
'Tx is too large. Expect less than 100kB. Got: ',
str(context.exception))

def test_tx_inout_mutation(self):
t = tx.Tx(self.version, self.none_flag, self.tx_ins, self.tx_outs,
self.none_witnesses, self.lock_time)

with self.assertRaises(TypeError, msg='That\'s immutable, honey'):
t.tx_ins = t.tx_ins + (1,)

with self.assertRaises(TypeError, msg='That\'s immutable, honey'):
t.tx_outs = t.tx_outs + (1,)

def test_tx_id(self):
t = tx.Tx(self.version, self.none_flag, self.tx_ins, self.tx_outs,
self.none_witnesses, self.lock_time)
Expand Down

0 comments on commit 2e05db2

Please sign in to comment.