1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-25 00:48:19 +00:00

fix unittests using client.get_public_node method

This commit is contained in:
Pavol Rusnak 2014-10-22 00:26:07 +02:00
parent 2ceef0f07c
commit 06214d52b4
5 changed files with 16 additions and 18 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
build/
dist/
python_trezor.egg-info/
trezor.egg-info/
*.pyc
*.bin
*.py.cache

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "trezor-common"]
path = trezor-common
url = https://github.com/trezor/trezor-common.git

View File

@ -9,7 +9,7 @@ class TestMsgEncryptmessage(common.TrezorTest):
def test_encrypt(self):
self.setup_mnemonic_nopin_nopassphrase()
pubkey1 = self.client.get_public_node([1]).public_key
pubkey1 = self.client.get_public_node([1]).node.public_key
enc = self.client.encrypt_message(pubkey1, 'testing message!', display_only=False)
self.assertEqual(binascii.hexlify(enc), '42494531025bef848e6a92f9361eeb23ba4f7d642191c9be17d6868b3e17839d8cb4b96045bbb05c7936312088ea97d473bcfbbe020c6c67028130601022ec45ec7b34c8eb47ee785922c308c9ad25da259aa59ec21a89e327af30e4213da31f3fc70ff5ae')
@ -17,7 +17,7 @@ class TestMsgEncryptmessage(common.TrezorTest):
enc = self.client.encrypt_message(pubkey1, 'testing message!', display_only=True)
self.assertEqual(binascii.hexlify(enc), '42494531025bef848e6a92f9361eeb23ba4f7d642191c9be17d6868b3e17839d8cb4b96045bbb05c7936312088ea97d473bcfbbe02f14a9778cbb1c5b75f8cef70581ad2c34acb7f9eb7918b17ea323123148251d8eb6d63d16ac8a86f3623855450b70d95')
pubkey2 = self.client.get_public_node([1, -2]).public_key
pubkey2 = self.client.get_public_node([1, -2]).node.public_key
enc = self.client.encrypt_message(pubkey2, 'testing message!', display_only=False)
self.assertEqual(binascii.hexlify(enc), '424945310238cba33fd1ed1d2adebd4cc4bbd89913ecb34922c1b387c3a10d70d9de6d9ea627b49044ce1dbf26cca8a727a40366dcb1f9c9a2d5eafa90817fd0d967ca25127bea98a5e93c150544bf457b48fdd667c72b8c9c31ccd0ad2aea2f1b50ec0ce6')

View File

@ -27,8 +27,8 @@ class TestMsgGetaddress(common.TrezorTest):
def test_public_ckd(self):
self.setup_mnemonic_nopin_nopassphrase()
node = self.client.get_public_node([])
node_sub1 = self.client.get_public_node([1])
node = self.client.get_public_node([]).node
node_sub1 = self.client.get_public_node([1]).node
node_sub2 = bip32.public_ckd(node, [1])
self.assertEqual(node_sub1.chain_code, node_sub2.chain_code)

View File

@ -6,23 +6,23 @@ class TestMsgGetpublic_key(common.TrezorTest):
def test_btc(self):
self.setup_mnemonic_nopin_nopassphrase()
self.assertEqual(bip32.serialize(self.client.get_public_node([]), 0x0488B21E), 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
self.assertEqual(bip32.serialize(self.client.get_public_node([1]), 0x0488B21E), 'xpub68zNxjsTrV8y9AadThLW7dTAqEpZ7xBLFSyJ3X9pjTv6Njg6kxgjXJkzxq8u3ttnjBw1jupQHMP3gpGZzZqd1eh5S4GjkaMhPR18vMyUi8N')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]), 0x0488B21E), 'xpub6A3FoZqYXj1AbW4thRwBh26YwZWbmoyjTaZwwxJjY1oKUpefLepL3RFS9DHKQrjAfxDrzDepYMDZPqXN6upQm3bHQ9xaXD5a3mqni3goF4v')
self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]), 0x0488B21E), 'xpub6A2h5mzLDfYginoD7q7wCWbq18wTbN9gducRr2w5NRTwdLeoT3cJSwefFqW7uXTpVFGtpUyDMBNYs3DNvvXx6NPjF9YEbUQrtxFSWnPtVrv')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]), 0x0488B21E), 'xpub6A3FoZqQEK6iwLZ4HFkqSo5fb35BH4bpjC4SPZ63prfLdGYPwYxEuC6o91bUvFFdMzKWe5rs3axHRUjxJaSvBnKKFtnfLwDACRxPxabsv2r')
self.assertEqual(bip32.serialize(self.client.get_public_node([]).node, 0x0488B21E), 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
self.assertEqual(bip32.serialize(self.client.get_public_node([1]).node, 0x0488B21E), 'xpub68zNxjsTrV8y9AadThLW7dTAqEpZ7xBLFSyJ3X9pjTv6Njg6kxgjXJkzxq8u3ttnjBw1jupQHMP3gpGZzZqd1eh5S4GjkaMhPR18vMyUi8N')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]).node, 0x0488B21E), 'xpub6A3FoZqYXj1AbW4thRwBh26YwZWbmoyjTaZwwxJjY1oKUpefLepL3RFS9DHKQrjAfxDrzDepYMDZPqXN6upQm3bHQ9xaXD5a3mqni3goF4v')
self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x0488B21E), 'xpub6A2h5mzLDfYginoD7q7wCWbq18wTbN9gducRr2w5NRTwdLeoT3cJSwefFqW7uXTpVFGtpUyDMBNYs3DNvvXx6NPjF9YEbUQrtxFSWnPtVrv')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]).node, 0x0488B21E), 'xpub6A3FoZqQEK6iwLZ4HFkqSo5fb35BH4bpjC4SPZ63prfLdGYPwYxEuC6o91bUvFFdMzKWe5rs3axHRUjxJaSvBnKKFtnfLwDACRxPxabsv2r')
def test_ltc(self):
self.setup_mnemonic_nopin_nopassphrase()
self.assertEqual(bip32.serialize(self.client.get_public_node([]), 0x019dA462), 'Ltub2SSUS19CirucVPGDKDBatBDBEM2s9UbH66pBURfaKrMocCPLhQ7Z7hecy5VYLHA5fRdXwB2e61j2VJCNzVsqKTCVEU1vECjqi5EyczFX9xp')
self.assertEqual(bip32.serialize(self.client.get_public_node([1]), 0x019dA462), 'Ltub2VRVRP5VjvSyPXra4BLVyVZPv397sjhUNjBGsbtw6xko77JuQyBULxFSKheviJJ3KQLbL3Cx8P2RnudguTw4raUVjCACRG7jsumUptYx55C')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]), 0x019dA462), 'Ltub2WUNGD3aRAKAqsLqHuwBYtCn2MqAXbVsarmvn33quWe2DCHTzfK4s4jsW5oM5G8RGAdSaM3NPNrwVvtV1ourbyNhhHr3BtqcYGc8caf5GoT')
self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]), 0x019dA462), 'Ltub2WToYRCN76rgyA59iK7w4Ni45wG2M9fpmBpQg7gBjvJeMiHc7473Gb96ci29Zvs55TgUQcMmCD1vy8aVqpdPwJB9YHRhGAAuPT1nRLLXmFu')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]), 0x019dA462), 'Ltub2WUNGD3S7kQjBhpzsjkqJfBtfqPk2r7xrUGRDdqACMW3MeBCbZSyiqbEVt7WaeesxCj6EDFQtcbfXa75DUYN2i6jZ2g81cyCgvijs9J2u2n')
self.assertEqual(bip32.serialize(self.client.get_public_node([]).node, 0x019dA462), 'Ltub2SSUS19CirucVPGDKDBatBDBEM2s9UbH66pBURfaKrMocCPLhQ7Z7hecy5VYLHA5fRdXwB2e61j2VJCNzVsqKTCVEU1vECjqi5EyczFX9xp')
self.assertEqual(bip32.serialize(self.client.get_public_node([1]).node, 0x019dA462), 'Ltub2VRVRP5VjvSyPXra4BLVyVZPv397sjhUNjBGsbtw6xko77JuQyBULxFSKheviJJ3KQLbL3Cx8P2RnudguTw4raUVjCACRG7jsumUptYx55C')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]).node, 0x019dA462), 'Ltub2WUNGD3aRAKAqsLqHuwBYtCn2MqAXbVsarmvn33quWe2DCHTzfK4s4jsW5oM5G8RGAdSaM3NPNrwVvtV1ourbyNhhHr3BtqcYGc8caf5GoT')
self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x019dA462), 'Ltub2WToYRCN76rgyA59iK7w4Ni45wG2M9fpmBpQg7gBjvJeMiHc7473Gb96ci29Zvs55TgUQcMmCD1vy8aVqpdPwJB9YHRhGAAuPT1nRLLXmFu')
self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]).node, 0x019dA462), 'Ltub2WUNGD3S7kQjBhpzsjkqJfBtfqPk2r7xrUGRDdqACMW3MeBCbZSyiqbEVt7WaeesxCj6EDFQtcbfXa75DUYN2i6jZ2g81cyCgvijs9J2u2n')
def test_tbtc(self):
self.setup_mnemonic_nopin_nopassphrase()
self.assertEqual(bip32.serialize(self.client.get_public_node([111, 42]), 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz')
self.assertEqual(bip32.serialize(self.client.get_public_node([111, 42]).node, 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz')
if __name__ == '__main__':
unittest.main()