31
31
from rlp .utils import int_to_big_endian
32
32
33
33
class TestMsgEthereumSigntx (common .KeepKeyTest ):
34
- @unittest .expectedFailure # Safety check fails
35
34
def test_ethereum_tx_xfer_acc1 (self ):
36
35
self .setup_mnemonic_nopin_nopassphrase ()
37
36
self .client .apply_policy ('ShapeShift' , 1 )
@@ -41,21 +40,21 @@ def test_ethereum_tx_xfer_acc1(self):
41
40
nonce = 0 ,
42
41
gas_price = 20 ,
43
42
gas_limit = 20 ,
44
- value = 12345678901234567890 ,
45
- to_n = [0x8000002c , 0x8000003c , 1 , 0 , 0 ],
46
- address_type = 1 ,
43
+ value = 1234567890 ,
44
+ to_n = [0x8000002c , 0x8000003c , 0x80000001 , 0 , 0 ],
45
+ address_type = proto_types .TRANSFER ,
46
+ chain_id = 1 ,
47
47
)
48
48
49
- self .assertEqual (sig_v , 27 )
50
- self .assertEqual (binascii .hexlify (sig_r ), '99f70cb618893ed3489add3de2adc0a3597bb59f683b67feb67f14145bef6766 ' )
51
- self .assertEqual (binascii .hexlify (sig_s ), '03c76425482270f1c720cb3c457a91b3d9e55848f21fdbde949e075fda344ab7 ' )
52
- self .assertEqual (binascii .hexlify (hash ), '4cc3cd55e89f68f3bab16eeb94bc50c53fec6e8946e749a85be390b06cd09f42 ' )
53
- self .assertEqual (binascii .hexlify (signature_der ), '304502210099f70cb618893ed3489add3de2adc0a3597bb59f683b67feb67f14145bef6766022003c76425482270f1c720cb3c457a91b3d9e55848f21fdbde949e075fda344ab7 ' )
49
+ self .assertEqual (sig_v , 37 )
50
+ self .assertEqual (binascii .hexlify (sig_r ), '72b87b41a92dbad6dffcd7f9441102029adad4864291f867726abaaa3572dee7 ' )
51
+ self .assertEqual (binascii .hexlify (sig_s ), '26814243d29bea4dddaef6da5b8af6836e499c2c7ccaa0877204f5465edc8290 ' )
52
+ self .assertEqual (binascii .hexlify (hash ), 'f8cb6ffe80afaa7f651e66933e62667c3250a0168fcc29b1f46529511bf53fe6 ' )
53
+ self .assertEqual (binascii .hexlify (signature_der ), '3044022072b87b41a92dbad6dffcd7f9441102029adad4864291f867726abaaa3572dee7022026814243d29bea4dddaef6da5b8af6836e499c2c7ccaa0877204f5465edc8290 ' )
54
54
55
55
#reset policy ("ShapeShift")
56
56
self .client .apply_policy ('ShapeShift' , 0 )
57
57
58
- @unittest .expectedFailure # Safety check fails
59
58
def test_ethereum_tx_xfer_acc2 (self ):
60
59
self .setup_mnemonic_nopin_nopassphrase ()
61
60
self .client .apply_policy ('ShapeShift' , 1 )
@@ -65,21 +64,21 @@ def test_ethereum_tx_xfer_acc2(self):
65
64
nonce = 0 ,
66
65
gas_price = 20 ,
67
66
gas_limit = 20 ,
68
- value = 12345678901234567890 ,
69
- to_n = [0x8000002c , 0x8000003c , 2 , 0 , 0 ],
70
- address_type = 1 ,
67
+ value = 1234567890 ,
68
+ to_n = [0x8000002c , 0x8000003c , 0x80000002 , 0 , 0 ],
69
+ address_type = proto_types .TRANSFER ,
70
+ chain_id = 1 ,
71
71
)
72
72
73
- self .assertEqual (sig_v , 28 )
74
- self .assertEqual (binascii .hexlify (sig_r ), '1c1949e8a261f8abfc40f4b6230fd69d7ce14c8d5ca7629af61ceb4ba0ea0b45 ' )
75
- self .assertEqual (binascii .hexlify (sig_s ), '59c450dce64d38aba22527353a8708255859c9c25abbfca07a19cf180d5a3858 ' )
76
- self .assertEqual (binascii .hexlify (hash ), '77e95b8843f6fd5f27c37a3ced1a1369a236e566ed0fea45a7a57d278c590860 ' )
77
- self .assertEqual (binascii .hexlify (signature_der ), '304402201c1949e8a261f8abfc40f4b6230fd69d7ce14c8d5ca7629af61ceb4ba0ea0b45022059c450dce64d38aba22527353a8708255859c9c25abbfca07a19cf180d5a3858 ' )
73
+ self .assertEqual (sig_v , 37 )
74
+ self .assertEqual (binascii .hexlify (sig_r ), '24b978c585e12ef9bb816105718adcdd11824262919489c22b63d9c71873535f ' )
75
+ self .assertEqual (binascii .hexlify (sig_s ), '079f2a155bec09d7a7e23189aa5f6a4305df839605eed23a720486a919306259 ' )
76
+ self .assertEqual (binascii .hexlify (hash ), '9d78419c4bbe60057b4ce5e3b8115b8a486589890dc9751b87c2bece0ed2f4a1 ' )
77
+ self .assertEqual (binascii .hexlify (signature_der ), '3044022024b978c585e12ef9bb816105718adcdd11824262919489c22b63d9c71873535f0220079f2a155bec09d7a7e23189aa5f6a4305df839605eed23a720486a919306259 ' )
78
78
79
79
#reset policy ("ShapeShift")
80
80
self .client .apply_policy ('ShapeShift' , 0 )
81
81
82
- @unittest .expectedFailure # Safety check fails
83
82
def test_ethereum_xfer_account_path_error_0 (self ):
84
83
self .setup_mnemonic_nopin_nopassphrase ()
85
84
self .client .apply_policy ('ShapeShift' , 1 )
@@ -89,9 +88,10 @@ def test_ethereum_xfer_account_path_error_0(self):
89
88
nonce = 0 ,
90
89
gas_price = 20 ,
91
90
gas_limit = 20 ,
92
- value = 12345678901234567890 ,
93
- to_n = [0x8000002c , 0x8000003c , 2 , 0 , 0 ],
94
- address_type = 1 ,
91
+ value = 1234567890 ,
92
+ to_n = [0x8000002c , 0x8000003c , 0x80000002 , 0 , 0 ],
93
+ address_type = proto_types .TRANSFER ,
94
+ chain_id = 1 ,
95
95
)
96
96
97
97
try :
@@ -100,10 +100,11 @@ def test_ethereum_xfer_account_path_error_0(self):
100
100
nonce = 0 ,
101
101
gas_price = 20 ,
102
102
gas_limit = 20 ,
103
- to_n = [0x8000002a , 0x8000003c , 1 , 0 , 0 ],
104
- #error here -^-
105
- value = 12345678901234567890 ,
106
- address_type = 1 ,
103
+ to_n = [0x8000002c , 0x8000003c , 2 , 0 , 0 ],
104
+ #error here -^-
105
+ value = 1234567890 ,
106
+ address_type = proto_types .TRANSFER ,
107
+ chain_id = 1 ,
107
108
)
108
109
except CallException as e :
109
110
self .assertEndsWith (e .args [1 ], 'Failed to compile output' )
@@ -114,21 +115,25 @@ def test_ethereum_xfer_account_path_error_0(self):
114
115
#reset policy ("ShapeShift")
115
116
self .client .apply_policy ('ShapeShift' , 0 )
116
117
117
- @unittest .expectedFailure # Safety check fails
118
118
def test_ethereum_xfer_account_path_error_1 (self ):
119
119
self .setup_mnemonic_nopin_nopassphrase ()
120
120
self .client .apply_policy ('ShapeShift' , 1 )
121
121
122
+ # Really we should warn instead in this case, and show:
123
+ # "Transfer 0.001234 ETH to m/44'/60'/1'/0/0/"
124
+ # on the device, rathern than erroring out.
125
+
122
126
try :
123
127
signature_der = self .client .ethereum_sign_tx (
124
128
n = [0 , 0 ],
125
129
nonce = 0 ,
126
130
gas_price = 20 ,
127
131
gas_limit = 20 ,
128
- to_n = [0x8000002c , 0x80000030 , 1 , 0 , 0 ],
129
- #error here -^-
130
- value = 12345678901234567890 ,
131
- address_type = 1 ,
132
+ to_n = [0x8000002c , 0x8000003c , 1 , 0 , 0 ],
133
+ #error here -^-
134
+ value = 1234000000000000 ,
135
+ address_type = proto_types .TRANSFER ,
136
+ chain_id = 1 ,
132
137
)
133
138
except CallException as e :
134
139
self .assertEndsWith (e .args [1 ], 'Failed to compile output' )
@@ -139,7 +144,6 @@ def test_ethereum_xfer_account_path_error_1(self):
139
144
#reset policy ("ShapeShift")
140
145
self .client .apply_policy ('ShapeShift' , 0 )
141
146
142
- @unittest .expectedFailure # Safety check fails
143
147
def test_ethereum_xfer_account_path_error_2 (self ):
144
148
self .setup_mnemonic_nopin_nopassphrase ()
145
149
self .client .apply_policy ('ShapeShift' , 1 )
@@ -153,8 +157,9 @@ def test_ethereum_xfer_account_path_error_2(self):
153
157
gas_limit = 20 ,
154
158
to_n = [0x8000002c , 0x8000003c , 1 , 1 , 0 ],
155
159
#error here -^-
156
- value = 12345678901234567890 ,
157
- address_type = 1 ,
160
+ value = 1234567890 ,
161
+ address_type = proto_types .TRANSFER ,
162
+ chain_id = 1 ,
158
163
)
159
164
except CallException as e :
160
165
self .assertEndsWith (e .args [1 ], 'Failed to compile output' )
@@ -165,7 +170,6 @@ def test_ethereum_xfer_account_path_error_2(self):
165
170
#reset policy ("ShapeShift")
166
171
self .client .apply_policy ('ShapeShift' , 0 )
167
172
168
- @unittest .expectedFailure # Safety check fails
169
173
def test_ethereum_xfer_account_path_error_3 (self ):
170
174
self .setup_mnemonic_nopin_nopassphrase ()
171
175
self .client .apply_policy ('ShapeShift' , 1 )
@@ -178,8 +182,9 @@ def test_ethereum_xfer_account_path_error_3(self):
178
182
gas_limit = 20 ,
179
183
to_n = [0x8000002c , 0x8000003c , 1 , 0 , 1 ],
180
184
#error here -^-
181
- value = 12345678901234567890 ,
182
- address_type = 1 ,
185
+ value = 1234567890 ,
186
+ address_type = proto_types .TRANSFER ,
187
+ chain_id = 1 ,
183
188
)
184
189
except CallException as e :
185
190
self .assertEndsWith (e .args [1 ], 'Failed to compile output' )
0 commit comments