@@ -9,10 +9,9 @@ class TestSaplingTx(unittest.TestCase):
9
9
10
10
def setUp (self ):
11
11
riemann .select_network ('zcash_sapling_main' )
12
- self .helpers = sapling_helpers .TXNS
13
12
14
13
def test_from_hex (self ):
15
- for txn in self . helpers :
14
+ for txn in sapling_helpers . TXNS :
16
15
test_tx = sapling .SaplingTx .from_hex (txn ['hex' ])
17
16
self .assertEqual (
18
17
test_tx .binding_sig .hex (),
@@ -40,3 +39,36 @@ def test_from_hex(self):
40
39
def test_init_errors (self ):
41
40
# TODO
42
41
pass
42
+
43
+ def test_sighash (self ):
44
+ # TODO: Check blake2b implementation
45
+ for txn in sapling_helpers .SIGHASH :
46
+ test_tx = sapling .SaplingTx .from_hex (txn ['hex' ])
47
+ self .assertEqual (
48
+ test_tx ._hash_prevouts (anyone_can_pay = False ).hex (),
49
+ txn ['hashPrevouts' ])
50
+ self .assertEqual (
51
+ test_tx ._hash_sequence (
52
+ sighash_type = txn ['sighash_type' ],
53
+ anyone_can_pay = False ).hex (),
54
+ txn ['hashSequence' ])
55
+ self .assertEqual (
56
+ test_tx ._hash_outputs (
57
+ sighash_type = txn ['sighash_type' ],
58
+ index = txn ['index' ]).hex (),
59
+ txn ['hashOutputs' ])
60
+ self .assertEqual (
61
+ test_tx ._hash_joinsplits ().hex (),
62
+ txn ['hashJoinSplits' ])
63
+ self .assertEqual (
64
+ test_tx ._hash_shielded_spends ().hex (),
65
+ txn ['hashShieldedSpends' ])
66
+ self .assertEqual (
67
+ test_tx ._hash_shielded_outputs ().hex (),
68
+ txn ['hashShieldedOutputs' ])
69
+ self .assertEqual (
70
+ test_tx .sighash (
71
+ sighash_type = txn ['sighash_type' ],
72
+ index = txn ['index' ],
73
+ joinsplit = txn ['joinsplit' ]).hex (),
74
+ txn ['sighash' ])
0 commit comments