Skip to content

Commit c86ff95

Browse files
committed
EOS: test slip48 additions
1 parent 43fe80a commit c86ff95

File tree

1 file changed

+60
-26
lines changed

1 file changed

+60
-26
lines changed

tests/test_msg_eos_signtx.py

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -224,42 +224,64 @@ def action_voteproducer_cancel(self):
224224
proto.EosActionVoteProducer(
225225
voter=eos.name_to_number('memememememe')))
226226

227-
def action_updateauth(self):
227+
def action_updateauth(self, is_slip48):
228228
return (proto.EosActionCommon(
229229
account=eos.name_to_number('eosio'),
230230
name=eos.name_to_number('updateauth'),
231231
authorization=[
232232
proto.EosPermissionLevel(
233233
actor=eos.name_to_number('eosio'),
234-
permission=eos.name_to_number('active'))
234+
permission=eos.name_to_number('owner'))
235235
]),
236236
proto.EosActionUpdateAuth(
237237
account=eos.name_to_number('memememememe'),
238238
permission=eos.name_to_number('active'),
239239
parent=eos.name_to_number('momomomomom'),
240-
auth=self.authorization()))
240+
auth=self.authorization(is_slip48)))
241+
242+
def authorization(self, is_slip48):
243+
if is_slip48:
244+
# SLIP48 permissions
245+
return proto.EosAuthorization(
246+
threshold=1,
247+
keys=[
248+
proto.EosAuthorizationKey(
249+
type=1,
250+
address_n=parse_path("m/48'/4'/1'/0'/0'"),
251+
weight=1)
252+
],
253+
accounts=[
254+
proto.EosAuthorizationAccount(
255+
account=proto.EosPermissionLevel(
256+
actor=eos.name_to_number('memememememe'),
257+
permission=eos.name_to_number('active')),
258+
weight=1)
259+
],
260+
waits=[
261+
])
241262

242-
def authorization(self):
243-
return proto.EosAuthorization(
244-
threshold=2,
245-
keys=[
246-
proto.EosAuthorizationKey(
247-
type=1,
248-
address_n=parse_path("m/44'/194'/0'/0/0"),
249-
weight=2)
250-
],
251-
accounts=[
252-
proto.EosAuthorizationAccount(
253-
account=proto.EosPermissionLevel(
254-
actor=eos.name_to_number('memememememe'),
255-
permission=eos.name_to_number('active')),
256-
weight=1)
257-
],
258-
waits=[
259-
proto.EosAuthorizationWait(
260-
wait_sec=3600,
261-
weight=1)
262-
])
263+
else:
264+
# SLIP44 / Exodus-style permissions
265+
return proto.EosAuthorization(
266+
threshold=2,
267+
keys=[
268+
proto.EosAuthorizationKey(
269+
type=1,
270+
address_n=parse_path("m/44'/194'/0'/0/0"),
271+
weight=2)
272+
],
273+
accounts=[
274+
proto.EosAuthorizationAccount(
275+
account=proto.EosPermissionLevel(
276+
actor=eos.name_to_number('memememememe'),
277+
permission=eos.name_to_number('active')),
278+
weight=1)
279+
],
280+
waits=[
281+
proto.EosAuthorizationWait(
282+
wait_sec=3600,
283+
weight=1)
284+
])
263285

264286
def action_deleteauth(self):
265287
return (proto.EosActionCommon(
@@ -527,15 +549,27 @@ def test_updateauth(self):
527549
self.setup_mnemonic_nopin_nopassphrase()
528550
self.client.apply_policy('Experimental', 1)
529551

552+
self.client.set_buttonwait(5)
553+
530554
res = self.client.eos_sign_tx_raw(
531555
proto.EosSignTx(
532556
address_n=parse_path("m/44'/194'/0'/0/0"),
533557
chain_id=EOS_CHAIN_ID,
534558
header=self.header(),
535559
num_actions=1),
536-
[self.action_updateauth()])
560+
[self.action_updateauth(False)])
561+
562+
self.assertEqual(binascii.hexlify(res.hash), "0282c00575f451a47e99902ab2a51243499ea004df309148d1f2e23c007520b7")
563+
564+
res = self.client.eos_sign_tx_raw(
565+
proto.EosSignTx(
566+
address_n=parse_path("m/48'/4'/0'/0'/0'"),
567+
chain_id=EOS_CHAIN_ID,
568+
header=self.header(),
569+
num_actions=1),
570+
[self.action_updateauth(True)])
537571

538-
self.assertEqual(binascii.hexlify(res.hash), "51afb4e1285b8a273a4ebe3feb8b8fb3c4d00c69ee0077e27a4cc36a0126754a")
572+
self.assertEqual(binascii.hexlify(res.hash), "63e2440c33abb0dccce44d634d24c6fd33eecab879439c7995cf65d1cb7d9acc")
539573

540574
def test_deleteauth(self):
541575
self.setup_mnemonic_nopin_nopassphrase()

0 commit comments

Comments
 (0)