1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-28 18:38:39 +00:00
trezor-firmware/tests/device_tests/test_msg_getaddress_segwit.py

41 lines
2.3 KiB
Python
Raw Normal View History

2017-01-07 16:50:40 +00:00
import unittest
import common
import trezorlib.ckd_public as bip32
from trezorlib import messages as proto
2017-06-23 19:31:42 +00:00
2017-01-07 16:50:40 +00:00
class TestMsgGetaddressSegwit(common.TrezorTest):
def test_show_segwit(self):
self.setup_mnemonic_allallall()
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"),
True, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
2017-01-07 16:50:40 +00:00
'2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX')
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"),
False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
2017-01-07 16:50:40 +00:00
'2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp')
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
2017-01-07 16:50:40 +00:00
'2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc')
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
False, None, script_type=proto.InputScriptType.SPENDADDRESS),
2017-01-07 16:50:40 +00:00
'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q')
2017-01-07 16:50:40 +00:00
def test_show_multisig_3(self):
self.setup_mnemonic_allallall()
2017-06-23 19:31:42 +00:00
nodes = map(lambda index: self.client.get_public_node(self.client.expand_path("999'/1'/%d'" % index)), range(1, 4))
multisig1 = proto.MultisigRedeemScriptType(
pubkeys=list(map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 0]), nodes)),
2017-01-07 16:50:40 +00:00
signatures=[b'', b'', b''],
m=2,
)
# multisig2 = proto.MultisigRedeemScriptType(
# pubkeys=map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
2017-06-23 19:31:42 +00:00
# signatures=[b'', b'', b''],
# m=2,
# )
2017-01-07 16:50:40 +00:00
for i in [1, 2, 3]:
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
False, multisig1, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
2017-06-23 19:31:42 +00:00
'2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y')