mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
device tests: simplify, drop unittest dependency
This commit is contained in:
parent
1881b0e6fd
commit
70e6d13c23
@ -18,8 +18,8 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
import hashlib
|
||||
from binascii import hexlify, unhexlify
|
||||
import pytest
|
||||
import os
|
||||
|
||||
from trezorlib.client import TrezorClient, TrezorClientDebugLink
|
||||
@ -85,9 +85,9 @@ elif UDP_ENABLED:
|
||||
print('Using Emulator (v2=udp)')
|
||||
|
||||
|
||||
class TrezorTest(unittest.TestCase):
|
||||
class TrezorTest(object):
|
||||
|
||||
def setUp(self):
|
||||
def setup_method(self, method):
|
||||
wirelink, debuglink = get_transport()
|
||||
self.client = TrezorClientDebugLink(wirelink)
|
||||
self.client.set_debuglink(debuglink)
|
||||
@ -107,8 +107,9 @@ class TrezorTest(unittest.TestCase):
|
||||
self.client.wipe_device()
|
||||
self.client.transport.session_begin()
|
||||
|
||||
print("Setup finished")
|
||||
print("--------------")
|
||||
def teardown_method(self, method):
|
||||
self.client.transport.session_end()
|
||||
self.client.close()
|
||||
|
||||
def setup_mnemonic_allallall(self):
|
||||
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic_all, pin='', passphrase_protection=False, label='test', language='english')
|
||||
@ -122,16 +123,14 @@ class TrezorTest(unittest.TestCase):
|
||||
def setup_mnemonic_pin_passphrase(self):
|
||||
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=True, label='test', language='english')
|
||||
|
||||
def tearDown(self):
|
||||
self.client.transport.session_end()
|
||||
self.client.close()
|
||||
|
||||
|
||||
def generate_entropy(strength, internal_entropy, external_entropy):
|
||||
'''
|
||||
strength - length of produced seed. One of 128, 192, 256
|
||||
random - binary stream of random data from external HRNG
|
||||
'''
|
||||
import hashlib
|
||||
|
||||
if strength not in (128, 192, 256):
|
||||
raise ValueError("Invalid strength")
|
||||
|
||||
|
@ -16,20 +16,20 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages
|
||||
|
||||
|
||||
class TestBasic(common.TrezorTest):
|
||||
class TestBasic(TrezorTest):
|
||||
|
||||
def test_features(self):
|
||||
features = self.client.call(messages.Initialize())
|
||||
self.assertEqual(features, self.client.features)
|
||||
assert features == self.client.features
|
||||
|
||||
def test_ping(self):
|
||||
ping = self.client.call(messages.Ping(message='ahoj!'))
|
||||
self.assertEqual(ping, messages.Success(message='ahoj!'))
|
||||
assert ping == messages.Success(message='ahoj!')
|
||||
|
||||
def test_device_id_same(self):
|
||||
id1 = self.client.get_device_id()
|
||||
@ -37,10 +37,10 @@ class TestBasic(common.TrezorTest):
|
||||
id2 = self.client.get_device_id()
|
||||
|
||||
# ID must be at least 12 characters
|
||||
self.assertTrue(len(id1) >= 12)
|
||||
assert len(id1) >= 12
|
||||
|
||||
# Every resulf of UUID must be the same
|
||||
self.assertEqual(id1, id2)
|
||||
assert id1 == id2
|
||||
|
||||
def test_device_id_different(self):
|
||||
id1 = self.client.get_device_id()
|
||||
@ -48,4 +48,4 @@ class TestBasic(common.TrezorTest):
|
||||
id2 = self.client.get_device_id()
|
||||
|
||||
# Device ID must be fresh after every reset
|
||||
self.assertNotEqual(id1, id2)
|
||||
assert id1 != id2
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
import time
|
||||
|
||||
|
||||
class TestBip32Speed(common.TrezorTest):
|
||||
class TestBip32Speed(TrezorTest):
|
||||
|
||||
def test_public_ckd(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -35,7 +35,7 @@ class TestBip32Speed(common.TrezorTest):
|
||||
delay = time.time() - start
|
||||
expected = (depth + 1) * 0.26
|
||||
print("DEPTH", depth, "EXPECTED DELAY", expected, "REAL DELAY", delay)
|
||||
self.assertLessEqual(delay, expected)
|
||||
assert delay <= expected
|
||||
|
||||
def test_private_ckd(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -48,7 +48,7 @@ class TestBip32Speed(common.TrezorTest):
|
||||
delay = time.time() - start
|
||||
expected = (depth + 1) * 0.26
|
||||
print("DEPTH", depth, "EXPECTED DELAY", expected, "REAL DELAY", delay)
|
||||
self.assertLessEqual(delay, expected)
|
||||
assert delay <= expected
|
||||
|
||||
def test_cache(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -67,4 +67,4 @@ class TestBip32Speed(common.TrezorTest):
|
||||
print("CACHED TIME", cache_time)
|
||||
|
||||
# Cached time expected to be at least 2x faster
|
||||
self.assertLessEqual(cache_time, nocache_time / 2.)
|
||||
assert cache_time <= nocache_time / 2.
|
||||
|
@ -16,20 +16,19 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
import hashlib
|
||||
from .common import *
|
||||
|
||||
from hashlib import sha256
|
||||
from trezorlib import ed25519raw, ed25519cosi
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestCosi(common.TrezorTest):
|
||||
class TestCosi(TrezorTest):
|
||||
|
||||
def test_cosi_commit(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
|
||||
digest = hashlib.sha256(b'this is a message').digest()
|
||||
digest = sha256(b'this is a message').digest()
|
||||
|
||||
c0 = self.client.cosi_commit(self.client.expand_path("10018'/0'"), digest)
|
||||
c1 = self.client.cosi_commit(self.client.expand_path("10018'/1'"), digest)
|
||||
@ -43,7 +42,7 @@ class TestCosi(common.TrezorTest):
|
||||
assert c0.commitment != c2.commitment
|
||||
assert c1.commitment != c2.commitment
|
||||
|
||||
digestb = hashlib.sha256(b'this is a different message').digest()
|
||||
digestb = sha256(b'this is a different message').digest()
|
||||
|
||||
c0b = self.client.cosi_commit(self.client.expand_path("10018'/0'"), digestb)
|
||||
c1b = self.client.cosi_commit(self.client.expand_path("10018'/1'"), digestb)
|
||||
@ -60,7 +59,7 @@ class TestCosi(common.TrezorTest):
|
||||
def test_cosi_sign(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
|
||||
digest = hashlib.sha256(b'this is a message').digest()
|
||||
digest = sha256(b'this is a message').digest()
|
||||
|
||||
c0 = self.client.cosi_commit(self.client.expand_path("10018'/0'"), digest)
|
||||
c1 = self.client.cosi_commit(self.client.expand_path("10018'/1'"), digest)
|
||||
|
@ -16,35 +16,34 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestDebuglink(common.TrezorTest):
|
||||
class TestDebuglink(TrezorTest):
|
||||
|
||||
def test_layout(self):
|
||||
layout = self.client.debug.read_layout()
|
||||
self.assertEqual(len(layout), 1024)
|
||||
assert len(layout) == 1024
|
||||
|
||||
def test_mnemonic(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
mnemonic = self.client.debug.read_mnemonic()
|
||||
self.assertEqual(mnemonic, self.mnemonic12)
|
||||
assert mnemonic == self.mnemonic12
|
||||
|
||||
def test_pin(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
|
||||
# Manually trigger PinMatrixRequest
|
||||
resp = self.client.call_raw(proto.Ping(message='test', pin_protection=True))
|
||||
self.assertIsInstance(resp, proto.PinMatrixRequest)
|
||||
assert isinstance(resp, proto.PinMatrixRequest)
|
||||
|
||||
pin = self.client.debug.read_pin()
|
||||
self.assertEqual(pin[0], '1234')
|
||||
self.assertNotEqual(pin[1], '')
|
||||
assert pin[0] == '1234'
|
||||
assert pin[1] != ''
|
||||
|
||||
pin_encoded = self.client.debug.read_pin_encoded()
|
||||
resp = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
@ -16,18 +16,17 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgApplysettings(common.TrezorTest):
|
||||
class TestMsgApplysettings(TrezorTest):
|
||||
|
||||
def test_apply_settings(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
self.assertEqual(self.client.features.label, 'test')
|
||||
assert self.client.features.label == 'test'
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.PinMatrixRequest(),
|
||||
@ -36,11 +35,11 @@ class TestMsgApplysettings(common.TrezorTest):
|
||||
proto.Features()])
|
||||
self.client.apply_settings(label='new label')
|
||||
|
||||
self.assertEqual(self.client.features.label, 'new label')
|
||||
assert self.client.features.label == 'new label'
|
||||
|
||||
def test_invalid_language(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
self.assertEqual(self.client.features.language, 'english')
|
||||
assert self.client.features.language == 'english'
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.PinMatrixRequest(),
|
||||
@ -49,12 +48,12 @@ class TestMsgApplysettings(common.TrezorTest):
|
||||
proto.Features()])
|
||||
self.client.apply_settings(language='nonexistent')
|
||||
|
||||
self.assertEqual(self.client.features.language, 'english')
|
||||
assert self.client.features.language == 'english'
|
||||
|
||||
def test_apply_settings_passphrase(self):
|
||||
self.setup_mnemonic_pin_nopassphrase()
|
||||
|
||||
self.assertEqual(self.client.features.passphrase_protection, False)
|
||||
assert self.client.features.passphrase_protection is False
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.PinMatrixRequest(),
|
||||
@ -63,7 +62,7 @@ class TestMsgApplysettings(common.TrezorTest):
|
||||
proto.Features()])
|
||||
self.client.apply_settings(use_passphrase=True)
|
||||
|
||||
self.assertEqual(self.client.features.passphrase_protection, True)
|
||||
assert self.client.features.passphrase_protection is True
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(),
|
||||
@ -71,7 +70,7 @@ class TestMsgApplysettings(common.TrezorTest):
|
||||
proto.Features()])
|
||||
self.client.apply_settings(use_passphrase=False)
|
||||
|
||||
self.assertEqual(self.client.features.passphrase_protection, False)
|
||||
assert self.client.features.passphrase_protection is False
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(),
|
||||
@ -79,7 +78,7 @@ class TestMsgApplysettings(common.TrezorTest):
|
||||
proto.Features()])
|
||||
self.client.apply_settings(use_passphrase=True)
|
||||
|
||||
self.assertEqual(self.client.features.passphrase_protection, True)
|
||||
assert self.client.features.passphrase_protection is True
|
||||
|
||||
def test_apply_homescreen(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
|
@ -16,204 +16,203 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgChangepin(common.TrezorTest):
|
||||
class TestMsgChangepin(TrezorTest):
|
||||
|
||||
def test_set_pin(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertFalse(features.pin_protection)
|
||||
assert features.pin_protection is False
|
||||
|
||||
# Check that there's no PIN protection
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# Let's set new PIN
|
||||
ret = self.client.call_raw(proto.ChangePin())
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
|
||||
# Press button
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
# Send the PIN for first time
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Send the PIN for second time
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Now we're done
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# Check that there's PIN protection now
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(features.pin_protection)
|
||||
assert features.pin_protection is True
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
# Check that the PIN is correct
|
||||
self.assertEqual(self.client.debug.read_pin()[0], self.pin6)
|
||||
assert self.client.debug.read_pin()[0] == self.pin6
|
||||
|
||||
def test_change_pin(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(features.pin_protection)
|
||||
assert features.pin_protection is True
|
||||
|
||||
# Check that there's PIN protection
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
# Check current PIN value
|
||||
self.assertEqual(self.client.debug.read_pin()[0], self.pin4)
|
||||
assert self.client.debug.read_pin()[0] == self.pin4
|
||||
|
||||
# Let's change PIN
|
||||
ret = self.client.call_raw(proto.ChangePin())
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
|
||||
# Press button
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
# Send current PIN
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.read_pin_encoded()
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Send new PIN for first time
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Send the PIN for second time
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Now we're done
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# Check that there's still PIN protection now
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(features.pin_protection)
|
||||
assert features.pin_protection is True
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
# Check that the PIN is correct
|
||||
self.assertEqual(self.client.debug.read_pin()[0], self.pin6)
|
||||
assert self.client.debug.read_pin()[0] == self.pin6
|
||||
|
||||
def test_remove_pin(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(features.pin_protection)
|
||||
assert features.pin_protection is True
|
||||
|
||||
# Check that there's PIN protection
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
# Let's remove PIN
|
||||
ret = self.client.call_raw(proto.ChangePin(remove=True))
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
|
||||
# Press button
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
# Send current PIN
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.read_pin_encoded()
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Now we're done
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# Check that there's no PIN protection now
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertFalse(features.pin_protection)
|
||||
assert features.pin_protection is False
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
def test_set_failed(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertFalse(features.pin_protection)
|
||||
assert features.pin_protection is False
|
||||
|
||||
# Check that there's no PIN protection
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# Let's set new PIN
|
||||
ret = self.client.call_raw(proto.ChangePin())
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
|
||||
# Press button
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
# Send the PIN for first time
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Send the PIN for second time, but with typo
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin4)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Now it should fail, because pins are different
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
|
||||
# Check that there's still no PIN protection now
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertFalse(features.pin_protection)
|
||||
assert features.pin_protection is False
|
||||
ret = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
def test_set_failed_2(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(features.pin_protection)
|
||||
assert features.pin_protection is True
|
||||
|
||||
# Let's set new PIN
|
||||
ret = self.client.call_raw(proto.ChangePin())
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
|
||||
# Press button
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
# Send current PIN
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.read_pin_encoded()
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Send the PIN for first time
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Send the PIN for second time, but with typo
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6 + '3')
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Now it should fail, because pins are different
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
|
||||
# Check that there's still old PIN protection
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(features.pin_protection)
|
||||
self.assertEqual(self.client.debug.read_pin()[0], self.pin4)
|
||||
assert features.pin_protection is True
|
||||
assert self.client.debug.read_pin()[0] == self.pin4
|
||||
|
@ -16,72 +16,73 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
|
||||
class TestMsgCipherkeyvalue(common.TrezorTest):
|
||||
class TestMsgCipherkeyvalue(TrezorTest):
|
||||
|
||||
def test_encrypt(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
# different ask values
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'676faf8f13272af601776bc31bc14e8f')
|
||||
assert hexlify(res) == b'676faf8f13272af601776bc31bc14e8f'
|
||||
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=False)
|
||||
self.assertEqual(binascii.hexlify(res), b'5aa0fbcb9d7fa669880745479d80c622')
|
||||
assert hexlify(res) == b'5aa0fbcb9d7fa669880745479d80c622'
|
||||
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=False, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'958d4f63269b61044aaedc900c8d6208')
|
||||
assert hexlify(res) == b'958d4f63269b61044aaedc900c8d6208'
|
||||
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message!", ask_on_encrypt=False, ask_on_decrypt=False)
|
||||
self.assertEqual(binascii.hexlify(res), b'e0cf0eb0425947000eb546cc3994bc6c')
|
||||
assert hexlify(res) == b'e0cf0eb0425947000eb546cc3994bc6c'
|
||||
|
||||
# different key
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test2", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'de247a6aa6be77a134bb3f3f925f13af')
|
||||
assert hexlify(res) == b'de247a6aa6be77a134bb3f3f925f13af'
|
||||
|
||||
# different message
|
||||
res = self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing message! it is different", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d')
|
||||
assert hexlify(res) == b'676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d'
|
||||
|
||||
# different path
|
||||
res = self.client.encrypt_keyvalue([0, 1, 3], b"test", b"testing message!", ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(binascii.hexlify(res), b'b4811a9d492f5355a5186ddbfccaae7b')
|
||||
assert hexlify(res) == b'b4811a9d492f5355a5186ddbfccaae7b'
|
||||
|
||||
def test_decrypt(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
# different ask values
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", unhexlify("676faf8f13272af601776bc31bc14e8f"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
assert res == b'testing message!'
|
||||
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("5aa0fbcb9d7fa669880745479d80c622"), ask_on_encrypt=True, ask_on_decrypt=False)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", unhexlify("5aa0fbcb9d7fa669880745479d80c622"), ask_on_encrypt=True, ask_on_decrypt=False)
|
||||
assert res == b'testing message!'
|
||||
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("958d4f63269b61044aaedc900c8d6208"), ask_on_encrypt=False, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", unhexlify("958d4f63269b61044aaedc900c8d6208"), ask_on_encrypt=False, ask_on_decrypt=True)
|
||||
assert res == b'testing message!'
|
||||
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("e0cf0eb0425947000eb546cc3994bc6c"), ask_on_encrypt=False, ask_on_decrypt=False)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", unhexlify("e0cf0eb0425947000eb546cc3994bc6c"), ask_on_encrypt=False, ask_on_decrypt=False)
|
||||
assert res == b'testing message!'
|
||||
|
||||
# different key
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test2", binascii.unhexlify("de247a6aa6be77a134bb3f3f925f13af"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test2", unhexlify("de247a6aa6be77a134bb3f3f925f13af"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
assert res == b'testing message!'
|
||||
|
||||
# different message
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", binascii.unhexlify("676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message! it is different')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 2], b"test", unhexlify("676faf8f13272af601776bc31bc14e8f3ae1c88536bf18f1b44f1e4c2c4a613d"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
assert res == b'testing message! it is different'
|
||||
|
||||
# different path
|
||||
res = self.client.decrypt_keyvalue([0, 1, 3], b"test", binascii.unhexlify("b4811a9d492f5355a5186ddbfccaae7b"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
self.assertEqual(res, b'testing message!')
|
||||
res = self.client.decrypt_keyvalue([0, 1, 3], b"test", unhexlify("b4811a9d492f5355a5186ddbfccaae7b"), ask_on_encrypt=True, ask_on_decrypt=True)
|
||||
assert res == b'testing message!'
|
||||
|
||||
def test_encrypt_badlen(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertRaises(Exception, self.client.encrypt_keyvalue, [0, 1, 2], b"test", b"testing")
|
||||
with pytest.raises(Exception):
|
||||
self.client.encrypt_keyvalue([0, 1, 2], b"test", b"testing")
|
||||
|
||||
def test_decrypt_badlen(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertRaises(Exception, self.client.decrypt_keyvalue, [0, 1, 2], b"test", b"testing")
|
||||
with pytest.raises(Exception):
|
||||
self.client.decrypt_keyvalue([0, 1, 2], b"test", b"testing")
|
||||
|
@ -16,14 +16,13 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgClearsession(common.TrezorTest):
|
||||
class TestMsgClearsession(TrezorTest):
|
||||
|
||||
def test_clearsession(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
@ -31,13 +30,13 @@ class TestMsgClearsession(common.TrezorTest):
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
with self.client:
|
||||
# pin and passphrase are cached
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
self.client.clear_session()
|
||||
|
||||
@ -45,10 +44,10 @@ class TestMsgClearsession(common.TrezorTest):
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
with self.client:
|
||||
# pin and passphrase are cached
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
@ -16,16 +16,15 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
|
||||
class TestMsgEthereumGetaddress(common.TrezorTest):
|
||||
class TestMsgEthereumGetaddress(TrezorTest):
|
||||
|
||||
def test_ethereum_getaddress(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([])), b'1d1c328764a41bda0492b66baa30c4a339ff85ef')
|
||||
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([1])), b'437207ca3cf43bf2e47dea0756d736c5df4f597a')
|
||||
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, -1])), b'e5d96dfa07bcf1a3ae43677840c31394258861bf')
|
||||
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([-9, 0])), b'f68804ac9eca9483ab4241d3e4751590d2c05102')
|
||||
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, 9999999])), b'7a6366ecfcaf0d5dcc1539c171696c6cdd1eb8ed')
|
||||
assert hexlify(self.client.ethereum_get_address([])) == b'1d1c328764a41bda0492b66baa30c4a339ff85ef'
|
||||
assert hexlify(self.client.ethereum_get_address([1])) == b'437207ca3cf43bf2e47dea0756d736c5df4f597a'
|
||||
assert hexlify(self.client.ethereum_get_address([0, -1])) == b'e5d96dfa07bcf1a3ae43677840c31394258861bf'
|
||||
assert hexlify(self.client.ethereum_get_address([-9, 0])) == b'f68804ac9eca9483ab4241d3e4751590d2c05102'
|
||||
assert hexlify(self.client.ethereum_get_address([0, 9999999])) == b'7a6366ecfcaf0d5dcc1539c171696c6cdd1eb8ed'
|
||||
|
@ -15,20 +15,19 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
|
||||
class TestMsgEthereumSignmessage(common.TrezorTest):
|
||||
class TestMsgEthereumSignmessage(TrezorTest):
|
||||
|
||||
def test_sign(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.ethereum_sign_message([0], 'This is an example of a signed message.')
|
||||
self.assertEqual(binascii.hexlify(sig.address), b'cb3864960e8db1a751212c580af27ee8867d688f')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'95b64a7b3aa492f0cc1668a24097004562cc2b4f0e755e3c0d60dd791b9f9e285f95b618258ff97036b8419d0a0dd1af3751c625b4d248ee6deff84eba21b8ee1c')
|
||||
assert hexlify(sig.address) == b'cb3864960e8db1a751212c580af27ee8867d688f'
|
||||
assert hexlify(sig.signature) == b'95b64a7b3aa492f0cc1668a24097004562cc2b4f0e755e3c0d60dd791b9f9e285f95b618258ff97036b8419d0a0dd1af3751c625b4d248ee6deff84eba21b8ee1c'
|
||||
|
||||
def test_sign_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.ethereum_sign_message([0], 'VeryLongMessage!' * 64)
|
||||
self.assertEqual(binascii.hexlify(sig.address), b'cb3864960e8db1a751212c580af27ee8867d688f')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'70d03c8447b64489e80ae44ce4f1a543e8eb5dd9e9a19c4743ce95fbd9b8234b2d2a16db87cee857f5b474107ad2c0c0c86118f8a33d5df3d98b766be92d71331b')
|
||||
assert hexlify(sig.address) == b'cb3864960e8db1a751212c580af27ee8867d688f'
|
||||
assert hexlify(sig.signature) == b'70d03c8447b64489e80ae44ce4f1a543e8eb5dd9e9a19c4743ce95fbd9b8234b2d2a16db87cee857f5b474107ad2c0c0c86118f8a33d5df3d98b766be92d71331b'
|
||||
|
@ -16,11 +16,10 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
|
||||
class TestMsgEthereumSigntx(common.TrezorTest):
|
||||
class TestMsgEthereumSigntx(TrezorTest):
|
||||
|
||||
def test_ethereum_signtx_nodata(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -30,22 +29,22 @@ class TestMsgEthereumSigntx(common.TrezorTest):
|
||||
nonce=0,
|
||||
gas_price=20,
|
||||
gas_limit=20,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=10)
|
||||
self.assertEqual(sig_v, 27)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'9b61192a161d056c66cfbbd331edb2d783a0193bd4f65f49ee965f791d898f72')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'49c0bbe35131592c6ed5c871ac457feeb16a1493f64237387fab9b83c1a202f7')
|
||||
assert sig_v == 27
|
||||
assert hexlify(sig_r) == b'9b61192a161d056c66cfbbd331edb2d783a0193bd4f65f49ee965f791d898f72'
|
||||
assert hexlify(sig_s) == b'49c0bbe35131592c6ed5c871ac457feeb16a1493f64237387fab9b83c1a202f7'
|
||||
|
||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=20000,
|
||||
gas_limit=20000,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890)
|
||||
self.assertEqual(sig_v, 28)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'6de597b8ec1b46501e5b159676e132c1aa78a95bd5892ef23560a9867528975a')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'6e33c4230b1ecf96a8dbb514b4aec0a6d6ba53f8991c8143f77812aa6daa993f')
|
||||
assert sig_v == 28
|
||||
assert hexlify(sig_r) == b'6de597b8ec1b46501e5b159676e132c1aa78a95bd5892ef23560a9867528975a'
|
||||
assert hexlify(sig_s) == b'6e33c4230b1ecf96a8dbb514b4aec0a6d6ba53f8991c8143f77812aa6daa993f'
|
||||
|
||||
def test_ethereum_signtx_data(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -55,24 +54,24 @@ class TestMsgEthereumSigntx(common.TrezorTest):
|
||||
nonce=0,
|
||||
gas_price=20,
|
||||
gas_limit=20,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=10,
|
||||
data=b'abcdefghijklmnop' * 16)
|
||||
self.assertEqual(sig_v, 28)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'6da89ed8627a491bedc9e0382f37707ac4e5102e25e7a1234cb697cedb7cd2c0')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'691f73b145647623e2d115b208a7c3455a6a8a83e3b4db5b9c6d9bc75825038a')
|
||||
assert sig_v == 28
|
||||
assert hexlify(sig_r) == b'6da89ed8627a491bedc9e0382f37707ac4e5102e25e7a1234cb697cedb7cd2c0'
|
||||
assert hexlify(sig_s) == b'691f73b145647623e2d115b208a7c3455a6a8a83e3b4db5b9c6d9bc75825038a'
|
||||
|
||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=20000,
|
||||
gas_limit=20000,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890,
|
||||
data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!')
|
||||
self.assertEqual(sig_v, 28)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'4e90b13c45c6a9bf4aaad0e5427c3e62d76692b36eb727c78d332441b7400404')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'3ff236e7d05f0f9b1ee3d70599bb4200638f28388a8faf6bb36db9e04dc544be')
|
||||
assert sig_v == 28
|
||||
assert hexlify(sig_r) == b'4e90b13c45c6a9bf4aaad0e5427c3e62d76692b36eb727c78d332441b7400404'
|
||||
assert hexlify(sig_s) == b'3ff236e7d05f0f9b1ee3d70599bb4200638f28388a8faf6bb36db9e04dc544be'
|
||||
|
||||
def test_ethereum_signtx_message(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -82,27 +81,26 @@ class TestMsgEthereumSigntx(common.TrezorTest):
|
||||
nonce=0,
|
||||
gas_price=20000,
|
||||
gas_limit=20000,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=0,
|
||||
data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!')
|
||||
self.assertEqual(sig_v, 28)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'070e9dafda4d9e733fa7b6747a75f8a4916459560efb85e3e73cd39f31aa160d')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'7842db33ef15c27049ed52741db41fe3238a6fa3a6a0888fcfb74d6917600e41')
|
||||
assert sig_v == 28
|
||||
assert hexlify(sig_r) == b'070e9dafda4d9e733fa7b6747a75f8a4916459560efb85e3e73cd39f31aa160d'
|
||||
assert hexlify(sig_s) == b'7842db33ef15c27049ed52741db41fe3238a6fa3a6a0888fcfb74d6917600e41'
|
||||
|
||||
def test_ethereum_signtx_newcontract(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
# contract creation without data should fail.
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
self.client.ethereum_sign_tx,
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=20000,
|
||||
gas_limit=20000,
|
||||
to='',
|
||||
value=12345678901234567890
|
||||
)
|
||||
with pytest.raises(Exception):
|
||||
self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=20000,
|
||||
gas_limit=20000,
|
||||
to='',
|
||||
value=12345678901234567890
|
||||
)
|
||||
|
||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
@ -112,55 +110,51 @@ class TestMsgEthereumSigntx(common.TrezorTest):
|
||||
to='',
|
||||
value=12345678901234567890,
|
||||
data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!')
|
||||
self.assertEqual(sig_v, 28)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'b401884c10ae435a2e792303b5fc257a09f94403b2883ad8c0ac7a7282f5f1f9')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'4742fc9e6a5fa8db3db15c2d856914a7f3daab21603a6c1ce9e9927482f8352e')
|
||||
assert sig_v == 28
|
||||
assert hexlify(sig_r) == b'b401884c10ae435a2e792303b5fc257a09f94403b2883ad8c0ac7a7282f5f1f9'
|
||||
assert hexlify(sig_s) == b'4742fc9e6a5fa8db3db15c2d856914a7f3daab21603a6c1ce9e9927482f8352e'
|
||||
|
||||
def test_ethereum_sanity_checks(self):
|
||||
# gas overflow
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
self.client.ethereum_sign_tx,
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=0xffffffffffffffffffffffffffffffff,
|
||||
gas_limit=0xffffffffffffffffffffffffffffff,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
with pytest.raises(Exception):
|
||||
self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=0xffffffffffffffffffffffffffffffff,
|
||||
gas_limit=0xffffffffffffffffffffffffffffff,
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
|
||||
# no gas price
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
self.client.ethereum_sign_tx,
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_limit=10000,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
with pytest.raises(Exception):
|
||||
self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_limit=10000,
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
|
||||
# no gas limit
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
self.client.ethereum_sign_tx,
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=10000,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
with pytest.raises(Exception):
|
||||
self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
nonce=123456,
|
||||
gas_price=10000,
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
|
||||
# no nonce
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
self.client.ethereum_sign_tx,
|
||||
n=[0, 0],
|
||||
gas_price=10000,
|
||||
gas_limit=123456,
|
||||
to=binascii.unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
with pytest.raises(Exception):
|
||||
self.client.ethereum_sign_tx(
|
||||
n=[0, 0],
|
||||
gas_price=10000,
|
||||
gas_limit=123456,
|
||||
to=unhexlify('1d1c328764a41bda0492b66baa30c4a339ff85ef'),
|
||||
value=12345678901234567890
|
||||
)
|
||||
|
||||
def test_ethereum_signtx_nodata_eip155(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -170,24 +164,24 @@ class TestMsgEthereumSigntx(common.TrezorTest):
|
||||
nonce=0,
|
||||
gas_price=20000000000,
|
||||
gas_limit=21000,
|
||||
to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
to=unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
value=100000000000000000,
|
||||
chain_id=3)
|
||||
self.assertEqual(sig_v, 41)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'a90d0bc4f8d63be69453dd62f2bb5fff53c610000abf956672564d8a654d401a')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'544a2e57bc8b4da18660a1e6036967ea581cc635f5137e3ba97a750867c27cf2')
|
||||
assert sig_v == 41
|
||||
assert hexlify(sig_r) == b'a90d0bc4f8d63be69453dd62f2bb5fff53c610000abf956672564d8a654d401a'
|
||||
assert hexlify(sig_s) == b'544a2e57bc8b4da18660a1e6036967ea581cc635f5137e3ba97a750867c27cf2'
|
||||
|
||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
||||
nonce=1,
|
||||
gas_price=20000000000,
|
||||
gas_limit=21000,
|
||||
to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
to=unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
value=100000000000000000,
|
||||
chain_id=3)
|
||||
self.assertEqual(sig_v, 42)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'699428a6950e23c6843f1bf3754f847e64e047e829978df80d55187d19a401ce')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'087343d0a3a2f10842218ffccb146b59a8431b6245ab389fde22dc833f171e6e')
|
||||
assert sig_v == 42
|
||||
assert hexlify(sig_r) == b'699428a6950e23c6843f1bf3754f847e64e047e829978df80d55187d19a401ce'
|
||||
assert hexlify(sig_s) == b'087343d0a3a2f10842218ffccb146b59a8431b6245ab389fde22dc833f171e6e'
|
||||
|
||||
def test_ethereum_signtx_data_eip155(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -197,49 +191,49 @@ class TestMsgEthereumSigntx(common.TrezorTest):
|
||||
nonce=2,
|
||||
gas_price=20000000000,
|
||||
gas_limit=21004,
|
||||
to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
to=unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
value=100000000000000000,
|
||||
data=b'\0',
|
||||
chain_id=3)
|
||||
self.assertEqual(sig_v, 42)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'ba85b622a8bb82606ba96c132e81fa8058172192d15bc41d7e57c031bca17df4')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'6473b75997634b6f692f8d672193591d299d5bf1c2d6e51f1a14ed0530b91c7d')
|
||||
assert sig_v == 42
|
||||
assert hexlify(sig_r) == b'ba85b622a8bb82606ba96c132e81fa8058172192d15bc41d7e57c031bca17df4'
|
||||
assert hexlify(sig_s) == b'6473b75997634b6f692f8d672193591d299d5bf1c2d6e51f1a14ed0530b91c7d'
|
||||
|
||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
||||
nonce=3,
|
||||
gas_price=20000000000,
|
||||
gas_limit=299732,
|
||||
to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
to=unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
value=100000000000000000,
|
||||
data=b'ABCDEFGHIJKLMNOP' * 256 + b'!!!',
|
||||
chain_id=3)
|
||||
self.assertEqual(sig_v, 42)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'd021c98f92859c8db5e4de2f0e410a8deb0c977eb1a631e323ebf7484bd0d79a')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'2c0e9defc9b1e895dc9520ff25ba3c635b14ad70aa86a5ad6c0a3acb82b569b6')
|
||||
assert sig_v == 42
|
||||
assert hexlify(sig_r) == b'd021c98f92859c8db5e4de2f0e410a8deb0c977eb1a631e323ebf7484bd0d79a'
|
||||
assert hexlify(sig_s) == b'2c0e9defc9b1e895dc9520ff25ba3c635b14ad70aa86a5ad6c0a3acb82b569b6'
|
||||
|
||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
||||
nonce=4,
|
||||
gas_price=20000000000,
|
||||
gas_limit=21004,
|
||||
to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
to=unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
value=0,
|
||||
data=b'\0',
|
||||
chain_id=3)
|
||||
self.assertEqual(sig_v, 42)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'dd52f026972a83c56b7dea356836fcfc70a68e3b879cdc8ef2bb5fea23e0a7aa')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'079285fe579c9a2da25c811b1c5c0a74cd19b6301ee42cf20ef7b3b1353f7242')
|
||||
assert sig_v == 42
|
||||
assert hexlify(sig_r) == b'dd52f026972a83c56b7dea356836fcfc70a68e3b879cdc8ef2bb5fea23e0a7aa'
|
||||
assert hexlify(sig_s) == b'079285fe579c9a2da25c811b1c5c0a74cd19b6301ee42cf20ef7b3b1353f7242'
|
||||
|
||||
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
|
||||
n=[0x80000000 | 44, 0x80000000 | 1, 0x80000000, 0, 0],
|
||||
nonce=5,
|
||||
gas_price=0,
|
||||
gas_limit=21004,
|
||||
to=binascii.unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
to=unhexlify('8ea7a3fccc211ed48b763b4164884ddbcf3b0a98'),
|
||||
value=0,
|
||||
data=b'\0',
|
||||
chain_id=3)
|
||||
self.assertEqual(sig_v, 42)
|
||||
self.assertEqual(binascii.hexlify(sig_r), b'f7505f709d5999343aea3c384034c62d0514336ff6c6af65582006f708f81503')
|
||||
self.assertEqual(binascii.hexlify(sig_s), b'44e09e29a4b6247000b46ddc94fe391e94deb2b39ad6ac6398e6db5bec095ba9')
|
||||
assert sig_v == 42
|
||||
assert hexlify(sig_r) == b'f7505f709d5999343aea3c384034c62d0514336ff6c6af65582006f708f81503'
|
||||
assert hexlify(sig_s) == b'44e09e29a4b6247000b46ddc94fe391e94deb2b39ad6ac6398e6db5bec095ba9'
|
||||
|
@ -15,26 +15,25 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
|
||||
class TestMsgEthereumVerifymessage(common.TrezorTest):
|
||||
class TestMsgEthereumVerifymessage(TrezorTest):
|
||||
|
||||
def test_verify(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
res = self.client.ethereum_verify_message(
|
||||
binascii.unhexlify('cb3864960e8db1a751212c580af27ee8867d688f'),
|
||||
binascii.unhexlify('95b64a7b3aa492f0cc1668a24097004562cc2b4f0e755e3c0d60dd791b9f9e285f95b618258ff97036b8419d0a0dd1af3751c625b4d248ee6deff84eba21b8ee1c'),
|
||||
unhexlify('cb3864960e8db1a751212c580af27ee8867d688f'),
|
||||
unhexlify('95b64a7b3aa492f0cc1668a24097004562cc2b4f0e755e3c0d60dd791b9f9e285f95b618258ff97036b8419d0a0dd1af3751c625b4d248ee6deff84eba21b8ee1c'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(res)
|
||||
assert res is True
|
||||
|
||||
def test_verify_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.ethereum_verify_message(
|
||||
binascii.unhexlify('cb3864960e8db1a751212c580af27ee8867d688f'),
|
||||
binascii.unhexlify('70d03c8447b64489e80ae44ce4f1a543e8eb5dd9e9a19c4743ce95fbd9b8234b2d2a16db87cee857f5b474107ad2c0c0c86118f8a33d5df3d98b766be92d71331b'),
|
||||
unhexlify('cb3864960e8db1a751212c580af27ee8867d688f'),
|
||||
unhexlify('70d03c8447b64489e80ae44ce4f1a543e8eb5dd9e9a19c4743ce95fbd9b8234b2d2a16db87cee857f5b474107ad2c0c0c86118f8a33d5df3d98b766be92d71331b'),
|
||||
'VeryLongMessage!' * 64
|
||||
)
|
||||
self.assertTrue(ret)
|
||||
assert ret is True
|
||||
|
@ -16,39 +16,38 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
from . import common
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
import trezorlib.ckd_public as bip32
|
||||
|
||||
|
||||
class TestMsgGetaddress(common.TrezorTest):
|
||||
class TestMsgGetaddress(TrezorTest):
|
||||
|
||||
def test_btc(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(self.client.get_address('Bitcoin', []), '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [1]), '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [0, -1]), '1JVq66pzRBvqaBRFeU9SPVvg3er4ZDgoMs')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [-9, 0]), '1F4YdQdL9ZQwvcNTuy5mjyQxXkyCfMcP2P')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [0, 9999999]), '1GS8X3yc7ntzwGw9vXwj9wqmBWZkTFewBV')
|
||||
assert self.client.get_address('Bitcoin', []) == '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK'
|
||||
assert self.client.get_address('Bitcoin', [1]) == '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb'
|
||||
assert self.client.get_address('Bitcoin', [0, -1]) == '1JVq66pzRBvqaBRFeU9SPVvg3er4ZDgoMs'
|
||||
assert self.client.get_address('Bitcoin', [-9, 0]) == '1F4YdQdL9ZQwvcNTuy5mjyQxXkyCfMcP2P'
|
||||
assert self.client.get_address('Bitcoin', [0, 9999999]) == '1GS8X3yc7ntzwGw9vXwj9wqmBWZkTFewBV'
|
||||
|
||||
def test_ltc(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(self.client.get_address('Litecoin', []), 'LYtGrdDeqYUQnTkr5sHT2DKZLG7Hqg7HTK')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [1]), 'LKRGNecThFP3Q6c5fosLVA53Z2hUDb1qnE')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [0, -1]), 'LcinMK8pVrAtpz7Qpc8jfWzSFsDLgLYfG6')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [-9, 0]), 'LZHVtcwAEDf1BR4d67551zUijyLUpDF9EX')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [0, 9999999]), 'Laf5nGHSCT94C5dK6fw2RxuXPiw2ZuRR9S')
|
||||
assert self.client.get_address('Litecoin', []) == 'LYtGrdDeqYUQnTkr5sHT2DKZLG7Hqg7HTK'
|
||||
assert self.client.get_address('Litecoin', [1]) == 'LKRGNecThFP3Q6c5fosLVA53Z2hUDb1qnE'
|
||||
assert self.client.get_address('Litecoin', [0, -1]) == 'LcinMK8pVrAtpz7Qpc8jfWzSFsDLgLYfG6'
|
||||
assert self.client.get_address('Litecoin', [-9, 0]) == 'LZHVtcwAEDf1BR4d67551zUijyLUpDF9EX'
|
||||
assert self.client.get_address('Litecoin', [0, 9999999]) == 'Laf5nGHSCT94C5dK6fw2RxuXPiw2ZuRR9S'
|
||||
|
||||
def test_tbtc(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(self.client.get_address('Testnet', [111, 42]), 'moN6aN6NP1KWgnPSqzrrRPvx2x1UtZJssa')
|
||||
assert self.client.get_address('Testnet', [111, 42]) == 'moN6aN6NP1KWgnPSqzrrRPvx2x1UtZJssa'
|
||||
|
||||
def test_bch(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/0")), '1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q')
|
||||
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/1")), '1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3')
|
||||
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/1/0")), '1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE')
|
||||
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/0")) == '1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q'
|
||||
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/0/1")) == '1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3'
|
||||
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/0'/1/0")) == '1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE'
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
def test_bch_multisig(self):
|
||||
@ -64,8 +63,8 @@ class TestMsgGetaddress(common.TrezorTest):
|
||||
m=2,
|
||||
)
|
||||
for nr in range(1, 4):
|
||||
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/" + str(nr) + "'/0/0"), show_display=(nr == 1), multisig=getmultisig(0, 0)), '33Ju286QvonBz5N1V754ZekQv4GLJqcc5R')
|
||||
self.assertEqual(self.client.get_address('Bcash', self.client.expand_path("44'/145'/" + str(nr) + "'/1/0"), show_display=(nr == 1), multisig=getmultisig(1, 0)), '3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE')
|
||||
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/" + str(nr) + "'/0/0"), show_display=(nr == 1), multisig=getmultisig(0, 0)) == '33Ju286QvonBz5N1V754ZekQv4GLJqcc5R'
|
||||
assert self.client.get_address('Bcash', self.client.expand_path("44'/145'/" + str(nr) + "'/1/0"), show_display=(nr == 1), multisig=getmultisig(1, 0)) == '3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE'
|
||||
|
||||
def test_public_ckd(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -74,11 +73,11 @@ class TestMsgGetaddress(common.TrezorTest):
|
||||
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)
|
||||
self.assertEqual(node_sub1.public_key, node_sub2.public_key)
|
||||
assert node_sub1.chain_code == node_sub2.chain_code
|
||||
assert node_sub1.public_key == node_sub2.public_key
|
||||
|
||||
address1 = self.client.get_address('Bitcoin', [1])
|
||||
address2 = bip32.get_address(node_sub2, 0)
|
||||
|
||||
self.assertEqual(address2, '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb')
|
||||
self.assertEqual(address1, address2)
|
||||
assert address2 == '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb'
|
||||
assert address1 == address2
|
||||
|
@ -15,27 +15,19 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
import trezorlib.ckd_public as bip32
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
class TestMsgGetaddressSegwit(common.TrezorTest):
|
||||
class TestMsgGetaddressSegwit(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),
|
||||
'2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX')
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"),
|
||||
False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
|
||||
'2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp')
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||
False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS),
|
||||
'2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc')
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||
False, None, script_type=proto.InputScriptType.SPENDADDRESS),
|
||||
'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q')
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"), True, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX'
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp'
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc'
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDADDRESS) == 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q'
|
||||
|
||||
def test_show_multisig_3(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -51,6 +43,4 @@ class TestMsgGetaddressSegwit(common.TrezorTest):
|
||||
# m=2,
|
||||
# )
|
||||
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),
|
||||
'2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y')
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), False, multisig1, script_type=proto.InputScriptType.SPENDP2SHWITNESS) == '2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y'
|
||||
|
@ -15,27 +15,19 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
import trezorlib.ckd_public as bip32
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
class TestMsgGetaddressSegwitNative(common.TrezorTest):
|
||||
class TestMsgGetaddressSegwitNative(TrezorTest):
|
||||
|
||||
def test_show_segwit(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"),
|
||||
True, None, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||
'tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s')
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"),
|
||||
False, None, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||
'tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu')
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||
False, None, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||
'tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc')
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"),
|
||||
False, None, script_type=proto.InputScriptType.SPENDADDRESS),
|
||||
'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q')
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/0/0"), True, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s'
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("49'/1'/0'/1/0"), False, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu'
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc'
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("44'/1'/0'/0/0"), False, None, script_type=proto.InputScriptType.SPENDADDRESS) == 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q'
|
||||
|
||||
def test_show_multisig_3(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -51,9 +43,5 @@ class TestMsgGetaddressSegwitNative(common.TrezorTest):
|
||||
m=2,
|
||||
)
|
||||
for i in [1, 2, 3]:
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/1" % i),
|
||||
False, multisig2, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||
'tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy')
|
||||
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
|
||||
False, multisig1, script_type=proto.InputScriptType.SPENDWITNESS),
|
||||
'tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z')
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/1" % i), False, multisig2, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qch62pf820spe9mlq49ns5uexfnl6jzcezp7d328fw58lj0rhlhasge9hzy'
|
||||
assert self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), False, multisig1, script_type=proto.InputScriptType.SPENDWITNESS) == 'tb1qr6xa5v60zyt3ry9nmfew2fk5g9y3gerkjeu6xxdz7qga5kknz2ssld9z2z'
|
||||
|
@ -16,20 +16,19 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
import trezorlib.ckd_public as bip32
|
||||
import pytest
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgGetaddressShow(common.TrezorTest):
|
||||
class TestMsgGetaddressShow(TrezorTest):
|
||||
|
||||
def test_show(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [1], show_display=True), '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [2], show_display=True), '15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [3], show_display=True), '1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5')
|
||||
assert self.client.get_address('Bitcoin', [1], show_display=True) == '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb'
|
||||
assert self.client.get_address('Bitcoin', [2], show_display=True) == '15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG'
|
||||
assert self.client.get_address('Bitcoin', [3], show_display=True) == '1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5'
|
||||
|
||||
def test_show_multisig_3(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -46,7 +45,7 @@ class TestMsgGetaddressShow(common.TrezorTest):
|
||||
)
|
||||
|
||||
for i in [1, 2, 3]:
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig), '3E7GDtuHqnqPmDgwH59pVC7AvySiSkbibz')
|
||||
assert self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig) == '3E7GDtuHqnqPmDgwH59pVC7AvySiSkbibz'
|
||||
|
||||
def test_show_multisig_15(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -64,4 +63,4 @@ class TestMsgGetaddressShow(common.TrezorTest):
|
||||
)
|
||||
|
||||
for i in range(15):
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig), '3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU')
|
||||
assert self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig) == '3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU'
|
||||
|
@ -19,7 +19,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import math
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
import trezorlib.messages as proto
|
||||
|
||||
@ -38,12 +38,12 @@ def entropy(data):
|
||||
return e
|
||||
|
||||
|
||||
class TestMsgGetentropy(common.TrezorTest):
|
||||
class TestMsgGetentropy(TrezorTest):
|
||||
|
||||
def test_entropy(self):
|
||||
for l in [0, 1, 2, 3, 4, 5, 8, 9, 16, 17, 32, 33, 64, 65, 128, 129, 256, 257, 512, 513, 1024]:
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Entropy()])
|
||||
ent = self.client.get_entropy(l)
|
||||
self.assertTrue(len(ent) == l)
|
||||
assert len(ent) == l
|
||||
print('entropy = ', entropy(ent))
|
||||
|
@ -16,28 +16,28 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
import trezorlib.ckd_public as bip32
|
||||
|
||||
|
||||
class TestMsgGetpublickey(common.TrezorTest):
|
||||
class TestMsgGetpublickey(TrezorTest):
|
||||
|
||||
def test_btc(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
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')
|
||||
assert bip32.serialize(self.client.get_public_node([]).node, 0x0488B21E) == 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy'
|
||||
assert bip32.serialize(self.client.get_public_node([1]).node, 0x0488B21E) == 'xpub68zNxjsTrV8y9AadThLW7dTAqEpZ7xBLFSyJ3X9pjTv6Njg6kxgjXJkzxq8u3ttnjBw1jupQHMP3gpGZzZqd1eh5S4GjkaMhPR18vMyUi8N'
|
||||
assert bip32.serialize(self.client.get_public_node([0, -1]).node, 0x0488B21E) == 'xpub6A3FoZqYXj1AbW4thRwBh26YwZWbmoyjTaZwwxJjY1oKUpefLepL3RFS9DHKQrjAfxDrzDepYMDZPqXN6upQm3bHQ9xaXD5a3mqni3goF4v'
|
||||
assert bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x0488B21E) == 'xpub6A2h5mzLDfYginoD7q7wCWbq18wTbN9gducRr2w5NRTwdLeoT3cJSwefFqW7uXTpVFGtpUyDMBNYs3DNvvXx6NPjF9YEbUQrtxFSWnPtVrv'
|
||||
assert 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([]).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')
|
||||
assert bip32.serialize(self.client.get_public_node([]).node, 0x019dA462) == 'Ltub2SSUS19CirucVPGDKDBatBDBEM2s9UbH66pBURfaKrMocCPLhQ7Z7hecy5VYLHA5fRdXwB2e61j2VJCNzVsqKTCVEU1vECjqi5EyczFX9xp'
|
||||
assert bip32.serialize(self.client.get_public_node([1]).node, 0x019dA462) == 'Ltub2VRVRP5VjvSyPXra4BLVyVZPv397sjhUNjBGsbtw6xko77JuQyBULxFSKheviJJ3KQLbL3Cx8P2RnudguTw4raUVjCACRG7jsumUptYx55C'
|
||||
assert bip32.serialize(self.client.get_public_node([0, -1]).node, 0x019dA462) == 'Ltub2WUNGD3aRAKAqsLqHuwBYtCn2MqAXbVsarmvn33quWe2DCHTzfK4s4jsW5oM5G8RGAdSaM3NPNrwVvtV1ourbyNhhHr3BtqcYGc8caf5GoT'
|
||||
assert bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x019dA462) == 'Ltub2WToYRCN76rgyA59iK7w4Ni45wG2M9fpmBpQg7gBjvJeMiHc7473Gb96ci29Zvs55TgUQcMmCD1vy8aVqpdPwJB9YHRhGAAuPT1nRLLXmFu'
|
||||
assert 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]).node, 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz')
|
||||
assert bip32.serialize(self.client.get_public_node([111, 42]).node, 0x043587CF) == 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz'
|
||||
|
@ -16,40 +16,40 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
|
||||
class TestDeviceLoad(common.TrezorTest):
|
||||
class TestDeviceLoad(TrezorTest):
|
||||
def test_load_device_1(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
mnemonic = self.client.debug.read_mnemonic()
|
||||
self.assertEqual(mnemonic, self.mnemonic12)
|
||||
assert mnemonic == self.mnemonic12
|
||||
|
||||
pin = self.client.debug.read_pin()[0]
|
||||
self.assertEqual(pin, None)
|
||||
assert pin is None
|
||||
|
||||
passphrase_protection = self.client.debug.read_passphrase_protection()
|
||||
self.assertEqual(passphrase_protection, False)
|
||||
assert passphrase_protection is False
|
||||
|
||||
address = self.client.get_address('Bitcoin', [])
|
||||
self.assertEqual(address, '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK')
|
||||
assert address == '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK'
|
||||
|
||||
def test_load_device_2(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
self.client.set_passphrase('passphrase')
|
||||
|
||||
mnemonic = self.client.debug.read_mnemonic()
|
||||
self.assertEqual(mnemonic, self.mnemonic12)
|
||||
assert mnemonic == self.mnemonic12
|
||||
|
||||
pin = self.client.debug.read_pin()[0]
|
||||
self.assertEqual(pin, self.pin4)
|
||||
assert pin == self.pin4
|
||||
|
||||
passphrase_protection = self.client.debug.read_passphrase_protection()
|
||||
self.assertEqual(passphrase_protection, True)
|
||||
assert passphrase_protection is True
|
||||
|
||||
address = self.client.get_address('Bitcoin', [])
|
||||
self.assertEqual(address, '15fiTDFwZd2kauHYYseifGi9daH2wniDHH')
|
||||
assert address == '15fiTDFwZd2kauHYYseifGi9daH2wniDHH'
|
||||
|
||||
def test_load_device_utf(self):
|
||||
words_nfkd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a'
|
||||
@ -82,6 +82,6 @@ class TestDeviceLoad(common.TrezorTest):
|
||||
self.client.set_passphrase(passphrase_nfd)
|
||||
address_nfd = self.client.get_address('Bitcoin', [])
|
||||
|
||||
self.assertEqual(address_nfkd, address_nfc)
|
||||
self.assertEqual(address_nfkd, address_nfkc)
|
||||
self.assertEqual(address_nfkd, address_nfd)
|
||||
assert address_nfkd == address_nfc
|
||||
assert address_nfkd == address_nfkc
|
||||
assert address_nfkd == address_nfd
|
||||
|
@ -16,21 +16,20 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestDeviceLoadXprv(common.TrezorTest):
|
||||
class TestDeviceLoadXprv(TrezorTest):
|
||||
|
||||
def test_load_device_xprv_1(self):
|
||||
self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=False, label='test', language='english')
|
||||
|
||||
passphrase_protection = self.client.debug.read_passphrase_protection()
|
||||
self.assertEqual(passphrase_protection, False)
|
||||
assert passphrase_protection is False
|
||||
|
||||
address = self.client.get_address('Bitcoin', [])
|
||||
self.assertEqual(address, '128RdrAkJDmqasgvfRf6MC5VcX4HKqH4mR')
|
||||
assert address == '128RdrAkJDmqasgvfRf6MC5VcX4HKqH4mR'
|
||||
|
||||
def test_load_device_xprv_2(self):
|
||||
self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=True, label='test', language='english')
|
||||
@ -38,7 +37,7 @@ class TestDeviceLoadXprv(common.TrezorTest):
|
||||
self.client.set_passphrase('passphrase')
|
||||
|
||||
passphrase_protection = self.client.debug.read_passphrase_protection()
|
||||
self.assertEqual(passphrase_protection, True)
|
||||
assert passphrase_protection is True
|
||||
|
||||
address = self.client.get_address('Bitcoin', [])
|
||||
self.assertEqual(address, '1CHUbFa4wTTPYgkYaw2LHSd5D4qJjMU8ri')
|
||||
assert address == '1CHUbFa4wTTPYgkYaw2LHSd5D4qJjMU8ri'
|
||||
|
@ -15,15 +15,13 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgNEMGetaddress(common.TrezorTest):
|
||||
class TestMsgNEMGetaddress(TrezorTest):
|
||||
|
||||
def test_nem_getaddress(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(self.client.nem_get_address(self.client.expand_path("m/44'/1'/0'/0'/0'"), 0x68), "NB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQGHUBWQN")
|
||||
self.assertEqual(self.client.nem_get_address(self.client.expand_path("m/44'/1'/0'/0'/0'"), 0x98), "TB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQHSBNBMF")
|
||||
assert self.client.nem_get_address(self.client.expand_path("m/44'/1'/0'/0'/0'"), 0x68) == "NB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQGHUBWQN"
|
||||
assert self.client.nem_get_address(self.client.expand_path("m/44'/1'/0'/0'/0'"), 0x98) == "TB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQHSBNBMF"
|
||||
|
@ -15,25 +15,23 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
# tx hash: 209368053ac61969b6838ceb7e31badeb622ed6aa42d6c58365c42ad1a11e19d
|
||||
SIGNATURE_TESTNET_SIMPLE = binascii.unhexlify(
|
||||
SIGNATURE_TESTNET_SIMPLE = unhexlify(
|
||||
"9cda2045324d05c791a4fc312ecceb62954e7740482f8df8928560d63cf273dea595023640179f112de755c79717757ef76962175378d6d87360ddb3f3e5f70f"
|
||||
)
|
||||
|
||||
# tx hash: 9f8741194576a090bc71a3f43a03855950f94278fa121e99203e45967e19a7d0
|
||||
SIGNATURE_TESTNET_XEM_AS_MOSAIC = binascii.unhexlify(
|
||||
SIGNATURE_TESTNET_XEM_AS_MOSAIC = unhexlify(
|
||||
"1bca7b1b9ffb16d2c2adffa665be072bd2d7a0eafe4a9911dc473500c272905edf3d626274deb52aa490137a276d1fca67ee487079ebf9c09f9faa414f8e7c02"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgNEMSigntx(common.TrezorTest):
|
||||
class TestMsgNEMSigntx(TrezorTest):
|
||||
|
||||
def test_nem_signtx_simple(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -57,7 +55,7 @@ class TestMsgNEMSigntx(common.TrezorTest):
|
||||
"type": 257,
|
||||
"deadline": 74735615,
|
||||
"message": {
|
||||
"payload": binascii.hexlify(b"test_nem_transaction_transfer"),
|
||||
"payload": hexlify(b"test_nem_transaction_transfer"),
|
||||
"type": 1,
|
||||
},
|
||||
"version": (0x98 << 24),
|
||||
|
@ -16,14 +16,13 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgPing(common.TrezorTest):
|
||||
class TestMsgPing(TrezorTest):
|
||||
|
||||
def test_ping(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
@ -31,22 +30,22 @@ class TestMsgPing(common.TrezorTest):
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.Success()])
|
||||
res = self.client.ping('random data')
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||
res = self.client.ping('random data', button_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.PinMatrixRequest(), proto.Success()])
|
||||
res = self.client.ping('random data', pin_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.PassphraseRequest(), proto.Success()])
|
||||
res = self.client.ping('random data', passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
def test_ping_caching(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
@ -54,10 +53,10 @@ class TestMsgPing(common.TrezorTest):
|
||||
with self.client:
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success()])
|
||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
with self.client:
|
||||
# pin and passphrase are cached
|
||||
self.client.set_expected_responses([proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall), proto.Success()])
|
||||
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
@ -18,13 +18,12 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgRecoverydevice(common.TrezorTest):
|
||||
class TestMsgRecoverydevice(TrezorTest):
|
||||
|
||||
def test_pin_passphrase(self):
|
||||
mnemonic = self.mnemonic12.split(' ')
|
||||
@ -35,12 +34,12 @@ class TestMsgRecoverydevice(common.TrezorTest):
|
||||
language='english',
|
||||
enforce_wordlist=True))
|
||||
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
@ -48,7 +47,7 @@ class TestMsgRecoverydevice(common.TrezorTest):
|
||||
|
||||
fakes = 0
|
||||
for _ in range(int(12 * 2)):
|
||||
self.assertIsInstance(ret, proto.WordRequest)
|
||||
assert isinstance(ret, proto.WordRequest)
|
||||
(word, pos) = self.client.debug.read_recovery_word()
|
||||
|
||||
if pos != 0:
|
||||
@ -61,27 +60,27 @@ class TestMsgRecoverydevice(common.TrezorTest):
|
||||
print(mnemonic)
|
||||
|
||||
# Workflow succesfully ended
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# 12 expected fake words and all words of mnemonic are used
|
||||
self.assertEqual(fakes, 12)
|
||||
self.assertEqual(mnemonic, [None] * 12)
|
||||
assert fakes == 12
|
||||
assert mnemonic == [None] * 12
|
||||
|
||||
# Mnemonic is the same
|
||||
self.client.init_device()
|
||||
self.assertEqual(self.client.debug.read_mnemonic(), self.mnemonic12)
|
||||
assert self.client.debug.read_mnemonic() == self.mnemonic12
|
||||
|
||||
self.assertTrue(self.client.features.pin_protection)
|
||||
self.assertTrue(self.client.features.passphrase_protection)
|
||||
assert self.client.features.pin_protection is True
|
||||
assert self.client.features.passphrase_protection is True
|
||||
|
||||
# Do passphrase-protected action, PassphraseRequest should be raised
|
||||
resp = self.client.call_raw(proto.Ping(passphrase_protection=True))
|
||||
self.assertIsInstance(resp, proto.PassphraseRequest)
|
||||
assert isinstance(resp, proto.PassphraseRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
# Do PIN-protected action, PinRequest should be raised
|
||||
resp = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(resp, proto.PinMatrixRequest)
|
||||
assert isinstance(resp, proto.PinMatrixRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
def test_nopin_nopassphrase(self):
|
||||
@ -95,7 +94,7 @@ class TestMsgRecoverydevice(common.TrezorTest):
|
||||
|
||||
fakes = 0
|
||||
for _ in range(int(12 * 2)):
|
||||
self.assertIsInstance(ret, proto.WordRequest)
|
||||
assert isinstance(ret, proto.WordRequest)
|
||||
(word, pos) = self.client.debug.read_recovery_word()
|
||||
|
||||
if pos != 0:
|
||||
@ -108,26 +107,26 @@ class TestMsgRecoverydevice(common.TrezorTest):
|
||||
print(mnemonic)
|
||||
|
||||
# Workflow succesfully ended
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# 12 expected fake words and all words of mnemonic are used
|
||||
self.assertEqual(fakes, 12)
|
||||
self.assertEqual(mnemonic, [None] * 12)
|
||||
assert fakes == 12
|
||||
assert mnemonic == [None] * 12
|
||||
|
||||
# Mnemonic is the same
|
||||
self.client.init_device()
|
||||
self.assertEqual(self.client.debug.read_mnemonic(), self.mnemonic12)
|
||||
assert self.client.debug.read_mnemonic() == self.mnemonic12
|
||||
|
||||
self.assertFalse(self.client.features.pin_protection)
|
||||
self.assertFalse(self.client.features.passphrase_protection)
|
||||
assert self.client.features.pin_protection is False
|
||||
assert self.client.features.passphrase_protection is False
|
||||
|
||||
# Do passphrase-protected action, PassphraseRequest should NOT be raised
|
||||
resp = self.client.call_raw(proto.Ping(passphrase_protection=True))
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
||||
# Do PIN-protected action, PinRequest should NOT be raised
|
||||
resp = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
||||
def test_word_fail(self):
|
||||
ret = self.client.call_raw(proto.RecoveryDevice(word_count=12,
|
||||
@ -137,12 +136,12 @@ class TestMsgRecoverydevice(common.TrezorTest):
|
||||
language='english',
|
||||
enforce_wordlist=True))
|
||||
|
||||
self.assertIsInstance(ret, proto.WordRequest)
|
||||
assert isinstance(ret, proto.WordRequest)
|
||||
for _ in range(int(12 * 2)):
|
||||
(word, pos) = self.client.debug.read_recovery_word()
|
||||
if pos != 0:
|
||||
ret = self.client.call_raw(proto.WordAck(word='kwyjibo'))
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
break
|
||||
else:
|
||||
self.client.call_raw(proto.WordAck(word=word))
|
||||
@ -155,20 +154,21 @@ class TestMsgRecoverydevice(common.TrezorTest):
|
||||
language='english',
|
||||
enforce_wordlist=True))
|
||||
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin4)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time, but different one
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Failure should be raised
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
|
||||
def test_already_initialized(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertRaises(Exception, self.client.recovery_device, 12, False, False, 'label', 'english')
|
||||
with pytest.raises(Exception):
|
||||
self.client.recovery_device(12, False, False, 'label', 'english')
|
||||
|
@ -18,13 +18,12 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgRecoverydeviceDryrun(common.TrezorTest):
|
||||
class TestMsgRecoverydeviceDryrun(TrezorTest):
|
||||
|
||||
def recovery_loop(self, mnemonic, result):
|
||||
ret = self.client.call_raw(proto.RecoveryDevice(word_count=12,
|
||||
@ -37,7 +36,7 @@ class TestMsgRecoverydeviceDryrun(common.TrezorTest):
|
||||
|
||||
fakes = 0
|
||||
for _ in range(int(12 * 2)):
|
||||
self.assertIsInstance(ret, proto.WordRequest)
|
||||
assert isinstance(ret, proto.WordRequest)
|
||||
(word, pos) = self.client.debug.read_recovery_word()
|
||||
|
||||
if pos != 0:
|
||||
@ -49,11 +48,11 @@ class TestMsgRecoverydeviceDryrun(common.TrezorTest):
|
||||
|
||||
print(mnemonic)
|
||||
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
self.client.debug.press_yes()
|
||||
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
self.assertIsInstance(ret, result)
|
||||
assert isinstance(ret, result)
|
||||
|
||||
def test_correct_notsame(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
@ -16,13 +16,13 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from mnemonic import Mnemonic
|
||||
|
||||
|
||||
class TestMsgResetDevice(common.TrezorTest):
|
||||
class TestMsgResetDevice(TrezorTest):
|
||||
|
||||
def test_reset_device(self):
|
||||
|
||||
@ -40,17 +40,17 @@ class TestMsgResetDevice(common.TrezorTest):
|
||||
))
|
||||
|
||||
# Provide entropy
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
internal_entropy = self.client.debug.read_reset_entropy()
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
|
||||
# Generate mnemonic locally
|
||||
entropy = common.generate_entropy(strength, internal_entropy, external_entropy)
|
||||
entropy = generate_entropy(strength, internal_entropy, external_entropy)
|
||||
expected_mnemonic = Mnemonic('english').to_mnemonic(entropy)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
self.client.call_raw(proto.ButtonAck())
|
||||
@ -58,36 +58,36 @@ class TestMsgResetDevice(common.TrezorTest):
|
||||
mnemonic = ' '.join(mnemonic)
|
||||
|
||||
# Compare that device generated proper mnemonic for given entropies
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
resp = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
||||
mnemonic = ' '.join(mnemonic)
|
||||
|
||||
# Compare that second pass printed out the same mnemonic once again
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(resp.initialized)
|
||||
self.assertFalse(resp.needs_backup)
|
||||
self.assertFalse(resp.pin_protection)
|
||||
self.assertFalse(resp.passphrase_protection)
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is False
|
||||
assert resp.pin_protection is False
|
||||
assert resp.passphrase_protection is False
|
||||
|
||||
# Do passphrase-protected action, PassphraseRequest should NOT be raised
|
||||
resp = self.client.call_raw(proto.Ping(passphrase_protection=True))
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
||||
# Do PIN-protected action, PinRequest should NOT be raised
|
||||
resp = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
||||
def test_reset_device_pin(self):
|
||||
external_entropy = b'zlutoucky kun upel divoke ody' * 2
|
||||
@ -102,33 +102,33 @@ class TestMsgResetDevice(common.TrezorTest):
|
||||
label='test'
|
||||
))
|
||||
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = self.client.debug.encode_pin('654')
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time
|
||||
pin_encoded = self.client.debug.encode_pin('654')
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
# Provide entropy
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
internal_entropy = self.client.debug.read_reset_entropy()
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
|
||||
# Generate mnemonic locally
|
||||
entropy = common.generate_entropy(strength, internal_entropy, external_entropy)
|
||||
entropy = generate_entropy(strength, internal_entropy, external_entropy)
|
||||
expected_mnemonic = Mnemonic('english').to_mnemonic(entropy)
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
self.client.call_raw(proto.ButtonAck())
|
||||
@ -136,37 +136,37 @@ class TestMsgResetDevice(common.TrezorTest):
|
||||
mnemonic = ' '.join(mnemonic)
|
||||
|
||||
# Compare that device generated proper mnemonic for given entropies
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
resp = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
||||
mnemonic = ' '.join(mnemonic)
|
||||
|
||||
# Compare that second pass printed out the same mnemonic once again
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(resp.initialized)
|
||||
self.assertFalse(resp.needs_backup)
|
||||
self.assertTrue(resp.pin_protection)
|
||||
self.assertTrue(resp.passphrase_protection)
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is False
|
||||
assert resp.pin_protection is True
|
||||
assert resp.passphrase_protection is True
|
||||
|
||||
# Do passphrase-protected action, PassphraseRequest should be raised
|
||||
resp = self.client.call_raw(proto.Ping(passphrase_protection=True))
|
||||
self.assertIsInstance(resp, proto.PassphraseRequest)
|
||||
assert isinstance(resp, proto.PassphraseRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
# Do PIN-protected action, PinRequest should be raised
|
||||
resp = self.client.call_raw(proto.Ping(pin_protection=True))
|
||||
self.assertIsInstance(resp, proto.PinMatrixRequest)
|
||||
assert isinstance(resp, proto.PinMatrixRequest)
|
||||
self.client.call_raw(proto.Cancel())
|
||||
|
||||
def test_failed_pin(self):
|
||||
@ -182,23 +182,24 @@ class TestMsgResetDevice(common.TrezorTest):
|
||||
label='test'
|
||||
))
|
||||
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
self.client.debug.press_yes()
|
||||
ret = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for first time
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin4)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
self.assertIsInstance(ret, proto.PinMatrixRequest)
|
||||
assert isinstance(ret, proto.PinMatrixRequest)
|
||||
|
||||
# Enter PIN for second time
|
||||
pin_encoded = self.client.debug.encode_pin(self.pin6)
|
||||
ret = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
|
||||
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
|
||||
def test_already_initialized(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertRaises(Exception, self.client.reset_device, False, 128, True, True, 'label', 'english')
|
||||
with pytest.raises(Exception):
|
||||
self.client.reset_device(False, 128, True, True, 'label', 'english')
|
||||
|
@ -16,14 +16,13 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
from mnemonic import Mnemonic
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgResetDeviceSkipbackup(common.TrezorTest):
|
||||
class TestMsgResetDeviceSkipbackup(TrezorTest):
|
||||
|
||||
def test_reset_device_skip_backup(self):
|
||||
|
||||
@ -41,18 +40,18 @@ class TestMsgResetDeviceSkipbackup(common.TrezorTest):
|
||||
))
|
||||
|
||||
# Provide entropy
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
internal_entropy = self.client.debug.read_reset_entropy()
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(resp.initialized)
|
||||
self.assertTrue(resp.needs_backup)
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is True
|
||||
|
||||
# Generate mnemonic locally
|
||||
entropy = common.generate_entropy(strength, internal_entropy, external_entropy)
|
||||
entropy = generate_entropy(strength, internal_entropy, external_entropy)
|
||||
expected_mnemonic = Mnemonic('english').to_mnemonic(entropy)
|
||||
|
||||
# start Backup workflow
|
||||
@ -60,7 +59,7 @@ class TestMsgResetDeviceSkipbackup(common.TrezorTest):
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
self.client.call_raw(proto.ButtonAck())
|
||||
@ -68,25 +67,25 @@ class TestMsgResetDeviceSkipbackup(common.TrezorTest):
|
||||
mnemonic = ' '.join(mnemonic)
|
||||
|
||||
# Compare that device generated proper mnemonic for given entropies
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
mnemonic = []
|
||||
for _ in range(strength // 32 * 3):
|
||||
self.assertIsInstance(ret, proto.ButtonRequest)
|
||||
assert isinstance(ret, proto.ButtonRequest)
|
||||
mnemonic.append(self.client.debug.read_reset_word())
|
||||
self.client.debug.press_yes()
|
||||
resp = self.client.call_raw(proto.ButtonAck())
|
||||
|
||||
self.assertIsInstance(resp, proto.Success)
|
||||
assert isinstance(resp, proto.Success)
|
||||
|
||||
mnemonic = ' '.join(mnemonic)
|
||||
|
||||
# Compare that second pass printed out the same mnemonic once again
|
||||
self.assertEqual(mnemonic, expected_mnemonic)
|
||||
assert mnemonic == expected_mnemonic
|
||||
|
||||
# start backup again - should fail
|
||||
ret = self.client.call_raw(proto.BackupDevice())
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
|
||||
def test_reset_device_skip_backup_break(self):
|
||||
|
||||
@ -104,27 +103,27 @@ class TestMsgResetDeviceSkipbackup(common.TrezorTest):
|
||||
))
|
||||
|
||||
# Provide entropy
|
||||
self.assertIsInstance(ret, proto.EntropyRequest)
|
||||
assert isinstance(ret, proto.EntropyRequest)
|
||||
ret = self.client.call_raw(proto.EntropyAck(entropy=external_entropy))
|
||||
self.assertIsInstance(ret, proto.Success)
|
||||
assert isinstance(ret, proto.Success)
|
||||
|
||||
# Check if device is properly initialized
|
||||
resp = self.client.call_raw(proto.Initialize())
|
||||
self.assertTrue(resp.initialized)
|
||||
self.assertTrue(resp.needs_backup)
|
||||
assert resp.initialized is True
|
||||
assert resp.needs_backup is True
|
||||
|
||||
# start Backup workflow
|
||||
ret = self.client.call_raw(proto.BackupDevice())
|
||||
|
||||
# send Initialize -> break workflow
|
||||
ret = self.client.call_raw(proto.Initialize())
|
||||
self.assertIsInstance(resp, proto.Features)
|
||||
assert isinstance(resp, proto.Features)
|
||||
|
||||
# start backup again - should fail
|
||||
ret = self.client.call_raw(proto.BackupDevice())
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
|
||||
def test_initialized_device_backup_fail(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.call_raw(proto.BackupDevice())
|
||||
self.assertIsInstance(ret, proto.Failure)
|
||||
assert isinstance(ret, proto.Failure)
|
||||
|
@ -18,16 +18,15 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import binascii
|
||||
import hashlib
|
||||
import struct
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
def check_path(identity):
|
||||
m = hashlib.sha256()
|
||||
from hashlib import sha256
|
||||
m = sha256()
|
||||
m.update(struct.pack("<I", identity.index))
|
||||
uri = ''
|
||||
if identity.proto:
|
||||
@ -47,12 +46,12 @@ def check_path(identity):
|
||||
print('path:', 'm/' + '/'.join([str(x) for x in address_n]))
|
||||
|
||||
|
||||
class TestMsgSignidentity(common.TrezorTest):
|
||||
class TestMsgSignidentity(TrezorTest):
|
||||
|
||||
def test_sign(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
hidden = binascii.unhexlify('cd8552569d6e4509266ef137584d1e62c7579b5b8ed69bbafa4b864c6521e7c2')
|
||||
hidden = unhexlify('cd8552569d6e4509266ef137584d1e62c7579b5b8ed69bbafa4b864c6521e7c2')
|
||||
visual = '2015-03-23 17:39:22'
|
||||
|
||||
# URI : https://satoshi@bitcoin.org/login
|
||||
@ -60,33 +59,33 @@ class TestMsgSignidentity(common.TrezorTest):
|
||||
# path : m/2147483661/2637750992/2845082444/3761103859/4005495825
|
||||
identity = proto.IdentityType(proto='https', user='satoshi', host='bitcoin.org', port='', path='/login', index=0)
|
||||
sig = self.client.sign_identity(identity, hidden, visual)
|
||||
self.assertEqual(sig.address, '17F17smBTX9VTZA9Mj8LM5QGYNZnmziCjL')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'023a472219ad3327b07c18273717bb3a40b39b743756bf287fbd5fa9d263237f45')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'20f2d1a42d08c3a362be49275c3ffeeaa415fc040971985548b9f910812237bb41770bf2c8d488428799fbb7e52c11f1a3404011375e4080e077e0e42ab7a5ba02')
|
||||
assert sig.address == '17F17smBTX9VTZA9Mj8LM5QGYNZnmziCjL'
|
||||
assert hexlify(sig.public_key) == b'023a472219ad3327b07c18273717bb3a40b39b743756bf287fbd5fa9d263237f45'
|
||||
assert hexlify(sig.signature) == b'20f2d1a42d08c3a362be49275c3ffeeaa415fc040971985548b9f910812237bb41770bf2c8d488428799fbb7e52c11f1a3404011375e4080e077e0e42ab7a5ba02'
|
||||
|
||||
# URI : ftp://satoshi@bitcoin.org:2323/pub
|
||||
# hash : 79a6b53831c6ff224fb283587adc4ebae8fb0d734734a46c876838f52dff53f3
|
||||
# path : m/2147483661/3098912377/2734671409/3632509519/3125730426
|
||||
identity = proto.IdentityType(proto='ftp', user='satoshi', host='bitcoin.org', port='2323', path='/pub', index=3)
|
||||
sig = self.client.sign_identity(identity, hidden, visual)
|
||||
self.assertEqual(sig.address, '1KAr6r5qF2kADL8bAaRQBjGKYEGxn9WrbS')
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'0266cf12d2ba381c5fd797da0d64f59c07a6f1b034ad276cca6bf2729e92b20d9c')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'20bbd12dc657d534fc0f7e40186e22c447e0866a016f654f380adffa9a84e9faf412a1bb0ae908296537838cf91145e77da08681c63d07b7dca40728b9e6cb17cf')
|
||||
assert sig.address == '1KAr6r5qF2kADL8bAaRQBjGKYEGxn9WrbS'
|
||||
assert hexlify(sig.public_key) == b'0266cf12d2ba381c5fd797da0d64f59c07a6f1b034ad276cca6bf2729e92b20d9c'
|
||||
assert hexlify(sig.signature) == b'20bbd12dc657d534fc0f7e40186e22c447e0866a016f654f380adffa9a84e9faf412a1bb0ae908296537838cf91145e77da08681c63d07b7dca40728b9e6cb17cf'
|
||||
|
||||
# URI : ssh://satoshi@bitcoin.org
|
||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
||||
identity = proto.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
||||
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='nist256p1')
|
||||
self.assertEqual(sig.address, None)
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'0373f21a3da3d0e96fc2189f81dd826658c3d76b2d55bd1da349bc6c3573b13ae4')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'005122cebabb852cdd32103b602662afa88e54c0c0c1b38d7099c64dcd49efe908288114e66ed2d8c82f23a70b769a4db723173ec53840c08aafb840d3f09a18d3')
|
||||
assert sig.address is None
|
||||
assert hexlify(sig.public_key) == b'0373f21a3da3d0e96fc2189f81dd826658c3d76b2d55bd1da349bc6c3573b13ae4'
|
||||
assert hexlify(sig.signature) == b'005122cebabb852cdd32103b602662afa88e54c0c0c1b38d7099c64dcd49efe908288114e66ed2d8c82f23a70b769a4db723173ec53840c08aafb840d3f09a18d3'
|
||||
|
||||
# URI : ssh://satoshi@bitcoin.org
|
||||
# hash : 5fa612f558a1a3b1fb7f010b2ea0a25cb02520a0ffa202ce74a92fc6145da5f3
|
||||
# path : m/2147483661/4111640159/2980290904/2332131323/3701645358
|
||||
identity = proto.IdentityType(proto='ssh', user='satoshi', host='bitcoin.org', port='', path='', index=47)
|
||||
sig = self.client.sign_identity(identity, hidden, visual, ecdsa_curve_name='ed25519')
|
||||
self.assertEqual(sig.address, None)
|
||||
self.assertEqual(binascii.hexlify(sig.public_key), b'000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709')
|
||||
assert sig.address is None
|
||||
assert hexlify(sig.public_key) == b'000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18'
|
||||
assert hexlify(sig.signature) == b'00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709'
|
||||
|
@ -16,29 +16,28 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
|
||||
class TestMsgSignmessage(common.TrezorTest):
|
||||
class TestMsgSignmessage(TrezorTest):
|
||||
|
||||
def test_sign(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.")
|
||||
self.assertEqual(sig.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
assert sig.address == '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e'
|
||||
assert hexlify(sig.signature) == b'209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'
|
||||
|
||||
def test_sign_testnet(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.")
|
||||
self.assertEqual(sig.address, 'mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
assert sig.address == 'mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL'
|
||||
assert hexlify(sig.signature) == b'209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'
|
||||
|
||||
def test_sign_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64)
|
||||
self.assertEqual(sig.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
||||
assert sig.address == '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e'
|
||||
assert hexlify(sig.signature) == b'205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'
|
||||
|
||||
def test_sign_utf(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -47,9 +46,9 @@ class TestMsgSignmessage(common.TrezorTest):
|
||||
words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f'
|
||||
|
||||
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd)
|
||||
self.assertEqual(sig_nfkd.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
assert sig_nfkd.address == '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e'
|
||||
assert hexlify(sig_nfkd.signature) == b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'
|
||||
|
||||
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc)
|
||||
self.assertEqual(sig_nfc.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
|
||||
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
assert sig_nfc.address == '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e'
|
||||
assert hexlify(sig_nfc.signature) == b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'
|
||||
|
@ -16,32 +16,30 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgSignmessageSegwit(common.TrezorTest):
|
||||
class TestMsgSignmessageSegwit(TrezorTest):
|
||||
|
||||
def test_sign(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||
self.assertEqual(sig.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
assert sig.address == '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1'
|
||||
assert hexlify(sig.signature) == b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'
|
||||
|
||||
def test_sign_testnet(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||
self.assertEqual(sig.address, '2N4VkePSzKH2sv5YBikLHGvzUYvfPxV6zS9')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
assert sig.address == '2N4VkePSzKH2sv5YBikLHGvzUYvfPxV6zS9'
|
||||
assert hexlify(sig.signature) == b'249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'
|
||||
|
||||
def test_sign_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64, script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||
self.assertEqual(sig.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'245ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
||||
assert sig.address == '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1'
|
||||
assert hexlify(sig.signature) == b'245ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'
|
||||
|
||||
def test_sign_utf(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -50,9 +48,9 @@ class TestMsgSignmessageSegwit(common.TrezorTest):
|
||||
words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f'
|
||||
|
||||
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd, script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||
self.assertEqual(sig_nfkd.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
assert sig_nfkd.address == '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1'
|
||||
assert hexlify(sig_nfkd.signature) == b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'
|
||||
|
||||
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto.InputScriptType.SPENDP2SHWITNESS)
|
||||
self.assertEqual(sig_nfc.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
|
||||
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
assert sig_nfc.address == '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1'
|
||||
assert hexlify(sig_nfc.signature) == b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'
|
||||
|
@ -16,32 +16,30 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgSignmessageSegwitNative(common.TrezorTest):
|
||||
class TestMsgSignmessageSegwitNative(TrezorTest):
|
||||
|
||||
def test_sign(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDWITNESS)
|
||||
self.assertEqual(sig.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
assert sig.address == 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j'
|
||||
assert hexlify(sig.signature) == b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'
|
||||
|
||||
def test_sign_testnet(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Testnet', [0], "This is an example of a signed message.", script_type=proto.InputScriptType.SPENDWITNESS)
|
||||
self.assertEqual(sig.address, 'tb1qyjjkmdpu7metqt5r36jf872a34syws336p3n3p')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80')
|
||||
assert sig.address == 'tb1qyjjkmdpu7metqt5r36jf872a34syws336p3n3p'
|
||||
assert hexlify(sig.signature) == b'289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'
|
||||
|
||||
def test_sign_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
sig = self.client.sign_message('Bitcoin', [0], "VeryLongMessage!" * 64, script_type=proto.InputScriptType.SPENDWITNESS)
|
||||
self.assertEqual(sig.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||
self.assertEqual(binascii.hexlify(sig.signature), b'285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed')
|
||||
assert sig.address == 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j'
|
||||
assert hexlify(sig.signature) == b'285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'
|
||||
|
||||
def test_sign_utf(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -50,9 +48,9 @@ class TestMsgSignmessageSegwitNative(common.TrezorTest):
|
||||
words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f'
|
||||
|
||||
sig_nfkd = self.client.sign_message('Bitcoin', [0], words_nfkd, script_type=proto.InputScriptType.SPENDWITNESS)
|
||||
self.assertEqual(sig_nfkd.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||
self.assertEqual(binascii.hexlify(sig_nfkd.signature), b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
assert sig_nfkd.address == 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j'
|
||||
assert hexlify(sig_nfkd.signature) == b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'
|
||||
|
||||
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto.InputScriptType.SPENDWITNESS)
|
||||
self.assertEqual(sig_nfc.address, 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j')
|
||||
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
|
||||
assert sig_nfc.address == 'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j'
|
||||
assert hexlify(sig_nfc.signature) == b'28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'
|
||||
|
@ -16,30 +16,29 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.client import CallException
|
||||
from trezorlib.tx_api import TxApiTestnet
|
||||
|
||||
|
||||
TXHASH_157041 = binascii.unhexlify('1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6')
|
||||
TXHASH_39a29e = binascii.unhexlify('39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5')
|
||||
TXHASH_4a7b7e = binascii.unhexlify('4a7b7e0403ae5607e473949cfa03f09f2cd8b0f404bf99ce10b7303d86280bf7')
|
||||
TXHASH_54aa56 = binascii.unhexlify('54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3')
|
||||
TXHASH_58497a = binascii.unhexlify('58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e')
|
||||
TXHASH_6f90f3 = binascii.unhexlify('6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54')
|
||||
TXHASH_c63e24 = binascii.unhexlify('c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb')
|
||||
TXHASH_c6be22 = binascii.unhexlify('c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c')
|
||||
TXHASH_d5f65e = binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
TXHASH_d6da21 = binascii.unhexlify('d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236')
|
||||
TXHASH_d2dcda = binascii.unhexlify('d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24')
|
||||
TXHASH_e5040e = binascii.unhexlify('e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd')
|
||||
TXHASH_50f6f1 = binascii.unhexlify('50f6f1209ca92d7359564be803cb2c932cde7d370f7cee50fd1fad6790f6206d')
|
||||
TXHASH_157041 = unhexlify('1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6')
|
||||
TXHASH_39a29e = unhexlify('39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5')
|
||||
TXHASH_4a7b7e = unhexlify('4a7b7e0403ae5607e473949cfa03f09f2cd8b0f404bf99ce10b7303d86280bf7')
|
||||
TXHASH_54aa56 = unhexlify('54aa5680dea781f45ebb536e53dffc526d68c0eb5c00547e323b2c32382dfba3')
|
||||
TXHASH_58497a = unhexlify('58497a7757224d1ff1941488d23087071103e5bf855f4c1c44e5c8d9d82ca46e')
|
||||
TXHASH_6f90f3 = unhexlify('6f90f3c7cbec2258b0971056ef3fe34128dbde30daa9c0639a898f9977299d54')
|
||||
TXHASH_c63e24 = unhexlify('c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb')
|
||||
TXHASH_c6be22 = unhexlify('c6be22d34946593bcad1d2b013e12f74159e69574ffea21581dad115572e031c')
|
||||
TXHASH_d5f65e = unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
TXHASH_d6da21 = unhexlify('d6da21677d7cca5f42fbc7631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236')
|
||||
TXHASH_d2dcda = unhexlify('d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24')
|
||||
TXHASH_e5040e = unhexlify('e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd')
|
||||
TXHASH_50f6f1 = unhexlify('50f6f1209ca92d7359564be803cb2c932cde7d370f7cee50fd1fad6790f6206d')
|
||||
|
||||
|
||||
class TestMsgSigntx(common.TrezorTest):
|
||||
class TestMsgSigntx(TrezorTest):
|
||||
def test_one_one_fee(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
@ -78,7 +77,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
# Accepted by network: tx fd79435246dee76b2f159d2db08032d666c95adc544de64c8c49f474df4a7fee
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
||||
assert hexlify(serialized_tx) == b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000'
|
||||
|
||||
def test_testnet_one_two_fee(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -126,7 +125,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001cd3b93f5b24ae190ce5141235091cd93fbb2908e24e5b9ff6776aec11b0e04e5000000006b483045022100eba3bbcbb82ab1ebac88a394e8fb53b0263dadbb3e8072f0a21ee62818c911060220686a9b7f306d028b54a228b5c47cc6c27b1d01a3b0770440bcc64d55d8bace2c0121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff021023cb01000000001976a91485eb47fe98f349065d6f044e27a4ac541af79ee288aca0bb0d00000000001976a9143d3cca567e00a04819742b21a696a67da796498b88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000001cd3b93f5b24ae190ce5141235091cd93fbb2908e24e5b9ff6776aec11b0e04e5000000006b483045022100eba3bbcbb82ab1ebac88a394e8fb53b0263dadbb3e8072f0a21ee62818c911060220686a9b7f306d028b54a228b5c47cc6c27b1d01a3b0770440bcc64d55d8bace2c0121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff021023cb01000000001976a91485eb47fe98f349065d6f044e27a4ac541af79ee288aca0bb0d00000000001976a9143d3cca567e00a04819742b21a696a67da796498b88ac00000000'
|
||||
|
||||
def test_testnet_fee_too_high(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -176,7 +175,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006a47304402205ea68e9d52d4be14420ccecf7f2e11489d49b86bedb79ee99b5e9b7188884150022056219cb3384a5df8048cca286a9533403dbda1571afd84b51379cdaee6a6dea80121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff020084d717000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006a47304402205ea68e9d52d4be14420ccecf7f2e11489d49b86bedb79ee99b5e9b7188884150022056219cb3384a5df8048cca286a9533403dbda1571afd84b51379cdaee6a6dea80121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff020084d717000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000'
|
||||
|
||||
def test_one_two_fee(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -222,7 +221,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000016d20f69067ad1ffd50ee7c0f377dde2c932ccb03e84b5659732da99c20f1f650010000006a47304402203429bd3ce7b38c5c1e8a15340edd79ced41a2939aae62e259d2e3d18e0c5ee7602201b83b10ebc4d6dcee3f9eb42ba8f1ef8a059a05397e0c1b9223d1565a3e6ec01012102a7a079c1ef9916b289c2ff21a992c808d0de3dfcf8a9f163205c5c9e21f55d5cffffffff0230750000000000001976a914954820f1de627a703596ac0396f986d958e3de4c88ac10270000000000001976a91405427736705cfbfaff76b1cff48283707fb1037088ac00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000016d20f69067ad1ffd50ee7c0f377dde2c932ccb03e84b5659732da99c20f1f650010000006a47304402203429bd3ce7b38c5c1e8a15340edd79ced41a2939aae62e259d2e3d18e0c5ee7602201b83b10ebc4d6dcee3f9eb42ba8f1ef8a059a05397e0c1b9223d1565a3e6ec01012102a7a079c1ef9916b289c2ff21a992c808d0de3dfcf8a9f163205c5c9e21f55d5cffffffff0230750000000000001976a914954820f1de627a703596ac0396f986d958e3de4c88ac10270000000000001976a91405427736705cfbfaff76b1cff48283707fb1037088ac00000000'
|
||||
|
||||
def test_one_three_fee(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -280,7 +279,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2, out3])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100e695e2c530c7c0fc32e6b79b7cff56a7f70a8c9da787534f46b4204070f914fc02207b0879a81408a11e23b11d4c7965c62b5fc6d5c2d92340f5ee2da7b40e99314a0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0300650400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ace02e0000000000001976a9141fe1d337fb81afca42818051e12fd18245d1b17288ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100e695e2c530c7c0fc32e6b79b7cff56a7f70a8c9da787534f46b4204070f914fc02207b0879a81408a11e23b11d4c7965c62b5fc6d5c2d92340f5ee2da7b40e99314a0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0300650400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ace02e0000000000001976a9141fe1d337fb81afca42818051e12fd18245d1b17288ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000'
|
||||
|
||||
def test_two_two(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -349,7 +348,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2])
|
||||
|
||||
# Accepted by network: tx c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000'
|
||||
|
||||
"""
|
||||
def test_lots_of_inputs(self):
|
||||
@ -441,7 +440,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], outputs)
|
||||
|
||||
if cnt == 255:
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002fb792f470a58993e14964c9bd46cdf37cb4bbc3f61540cb651580c82ed243ec6010000006b483045022100969da46f94a81f34f3717b014e0c3e1826eda1b0022ec2f9ce39f3d750ab9235022026da269770993211a1503413566a339bbb4389a482fffcf8e1f76713fc3b94f5012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902ffffffffe56582d2119100cb1d3da8232291e053f71e25fb669c87b32a667749959ea239010000006a473044022052e1419bb237b9db400ab5e3df16db6355619d545fde9030924a360763ae9ad40220704beab04d72ecaeb42eca7d98faca7a0941e65f2e1341f183be2b83e6b09e1c012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902fffffffffdff00' + b'd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac' * cnt + b'00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002fb792f470a58993e14964c9bd46cdf37cb4bbc3f61540cb651580c82ed243ec6010000006b483045022100969da46f94a81f34f3717b014e0c3e1826eda1b0022ec2f9ce39f3d750ab9235022026da269770993211a1503413566a339bbb4389a482fffcf8e1f76713fc3b94f5012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902ffffffffe56582d2119100cb1d3da8232291e053f71e25fb669c87b32a667749959ea239010000006a473044022052e1419bb237b9db400ab5e3df16db6355619d545fde9030924a360763ae9ad40220704beab04d72ecaeb42eca7d98faca7a0941e65f2e1341f183be2b83e6b09e1c012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902fffffffffdff00' + b'd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac' * cnt + b'00000000'
|
||||
|
||||
def test_fee_too_high(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -480,7 +479,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001a6cab19c507e547ec87c1f3074d8fdd8379e90e6d5af7929f52c30b46e417015000000006b483045022100dc3531da7feb261575f03b5b9bbb35edc7f73bb081c92538827105de4102737002200161e34395f6a8ee93979200cb974fa75ccef6d7c14021511cf468eece90d6450121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01d018ee05000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000001a6cab19c507e547ec87c1f3074d8fdd8379e90e6d5af7929f52c30b46e417015000000006b483045022100dc3531da7feb261575f03b5b9bbb35edc7f73bb081c92538827105de4102737002200161e34395f6a8ee93979200cb974fa75ccef6d7c14021511cf468eece90d6450121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01d018ee05000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000'
|
||||
|
||||
def test_not_enough_funds(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -516,9 +515,9 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
try:
|
||||
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
except CallException as e:
|
||||
self.assertEqual(e.args[0], proto.FailureType.NotEnoughFunds)
|
||||
assert e.args[0] == proto.FailureType.NotEnoughFunds
|
||||
else:
|
||||
self.assert_(False, "types.FailureType.NotEnoughFunds expected")
|
||||
assert False # types.FailureType.NotEnoughFunds expected
|
||||
|
||||
def test_p2sh(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -554,7 +553,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
# Accepted by network: tx 8cc1f4adf7224ce855cf535a5104594a0004cb3b640d6714fdb00b9128832dd5
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001a3fb2d38322c3b327e54005cebc0686d52fcdf536e53bb5ef481a7de8056aa54010000006b4830450221009e020b0390ccad533b73b552f8a99a9d827212c558e4f755503674d07c92ad4502202d606f7316990e0461c51d4add25054f19c697aa3e3c2ced4d568f0b2c57e62f0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0170f305000000000017a9147f844bdb0b8fd54b64e3d16c85dc1170f1ff97c18700000000')
|
||||
assert hexlify(serialized_tx) == b'0100000001a3fb2d38322c3b327e54005cebc0686d52fcdf536e53bb5ef481a7de8056aa54010000006b4830450221009e020b0390ccad533b73b552f8a99a9d827212c558e4f755503674d07c92ad4502202d606f7316990e0461c51d4add25054f19c697aa3e3c2ced4d568f0b2c57e62f0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0170f305000000000017a9147f844bdb0b8fd54b64e3d16c85dc1170f1ff97c18700000000'
|
||||
|
||||
def test_attack_change_outputs(self):
|
||||
# This unit test attempts to modify data sent during ping-pong of streaming signing.
|
||||
@ -616,10 +615,11 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2])
|
||||
|
||||
# Accepted by network: tx c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000021c032e5715d1da8115a2fe4f57699e15742fe113b0d2d1ca3b594649d322bec6010000006b483045022100f773c403b2f85a5c1d6c9c4ad69c43de66930fff4b1bc818eb257af98305546a0220443bde4be439f276a6ce793664b463580e210ec6c9255d68354449ac0443c76501210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff6ea42cd8d9c8e5441c4c5f85bfe50311078730d2881494f11f4d2257777a4958010000006b48304502210090cff1c1911e771605358a8cddd5ae94c7b60cc96e50275908d9bf9d6367c79f02202bfa72e10260a146abd59d0526e1335bacfbb2b4401780e9e3a7441b0480c8da0121038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e3ffffffff02a0860100000000001976a9142f4490d5263906e4887ca2996b9e207af3e7824088aca0860100000000001976a914812c13d97f9159e54e326b481b8f88a73df8507a88ac00000000'
|
||||
|
||||
# Now run the attack, must trigger the exception
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, inp2], [out1, out2], debug_processor=attack_processor)
|
||||
with pytest.raises(CallException):
|
||||
self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2], debug_processor=attack_processor)
|
||||
|
||||
def test_attack_change_input_address(self):
|
||||
# This unit test attempts to modify input address after the Trezor checked
|
||||
@ -674,7 +674,7 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
# Test if the transaction can be signed normally
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001243e15b53cc553d93ec4e27e16984adc3d885ef107c613a7577fea47f5dadcd2010000006a47304402207d517dcb6b823bba4d252da096795a7f914d0c477aee26e554ba61653c45608a02202cba1e805c586c830472f399510be5d42c2fcfd67b8a6b0690cbe8a3e6e475e801210364430c9122948e525e2f1c6d88f00f47679274f0810fd8c63754954f310995c1ffffffff02a0860100000000001976a914b3cc67f3349974d0f1b50e9bb5dfdf226f888fa088ac18555907000000001976a91485a3f5b0d23cdd61f5f8e1eb8c9ca0890dd15a9788ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000001243e15b53cc553d93ec4e27e16984adc3d885ef107c613a7577fea47f5dadcd2010000006a47304402207d517dcb6b823bba4d252da096795a7f914d0c477aee26e554ba61653c45608a02202cba1e805c586c830472f399510be5d42c2fcfd67b8a6b0690cbe8a3e6e475e801210364430c9122948e525e2f1c6d88f00f47679274f0810fd8c63754954f310995c1ffffffff02a0860100000000001976a914b3cc67f3349974d0f1b50e9bb5dfdf226f888fa088ac18555907000000001976a91485a3f5b0d23cdd61f5f8e1eb8c9ca0890dd15a9788ac00000000'
|
||||
|
||||
# Now run the attack, must trigger the exception
|
||||
with self.client:
|
||||
@ -691,7 +691,8 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
])
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||
with pytest.raises(CallException):
|
||||
self.client.sign_tx('Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||
|
||||
def test_spend_coinbase(self):
|
||||
# 25 TEST generated to m/1 (mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV)
|
||||
@ -731,4 +732,4 @@ class TestMsgSigntx(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, ], [out1, ])
|
||||
|
||||
# Accepted by network: tx
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000'
|
||||
|
@ -15,9 +15,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.tx_api import TxApiInsight
|
||||
from trezorlib.ckd_public import deserialize
|
||||
@ -27,7 +25,7 @@ TxApiBitcoinCash = TxApiInsight(network='insight_bch', url='https://bch-bitcore2
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgSigntxBch(common.TrezorTest):
|
||||
class TestMsgSigntxBch(TrezorTest):
|
||||
|
||||
def test_send_bch_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -36,7 +34,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
address_n=self.client.expand_path("44'/145'/0'/0/0"),
|
||||
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
|
||||
amount=1995344,
|
||||
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
||||
prev_hash=unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
@ -64,7 +62,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001781a716b1e15b41b07157933e5d777392a75bf87132650cb2e7d46fb8dc237bc000000006a473044022061aee4f17abe044d5df8c52c9ffd3b84e5a29743517e488b20ecf1ae0b3e4d3a02206bb84c55e407f3b684ff8d9bea0a3409cfd865795a19d10b3d3c31f12795c34a412103a020b36130021a0f037c1d1a02042e325c0cb666d6478c1afdcd9d913b9ef080ffffffff0272ee1c00000000001976a914b1401fce7e8bf123c88a0467e0ed11e3b9fbef5488acec1e0100000000001976a914d51eca49695cdf47e7f4b55507893e3ad53fe9d888ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000001781a716b1e15b41b07157933e5d777392a75bf87132650cb2e7d46fb8dc237bc000000006a473044022061aee4f17abe044d5df8c52c9ffd3b84e5a29743517e488b20ecf1ae0b3e4d3a02206bb84c55e407f3b684ff8d9bea0a3409cfd865795a19d10b3d3c31f12795c34a412103a020b36130021a0f037c1d1a02042e325c0cb666d6478c1afdcd9d913b9ef080ffffffff0272ee1c00000000001976a914b1401fce7e8bf123c88a0467e0ed11e3b9fbef5488acec1e0100000000001976a914d51eca49695cdf47e7f4b55507893e3ad53fe9d888ac00000000'
|
||||
|
||||
def test_send_bch_nochange(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -73,7 +71,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
||||
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
|
||||
amount=1896050,
|
||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
@ -81,7 +79,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
address_n=self.client.expand_path("44'/145'/0'/0/1"),
|
||||
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
|
||||
amount=73452,
|
||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
@ -104,7 +102,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bcash', [inp1, inp2], [out1])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000022c06cf6f215c5cbfd7caa8e71b1b32630cabf1f816a4432815b037b277852e50000000006a47304402207a2a955f1cb3dc5f03f2c82934f55654882af4e852e5159639f6349e9386ec4002205fb8419dce4e648eae8f67bc4e369adfb130a87d2ea2d668f8144213b12bb457412103174c61e9c5362507e8061e28d2c0ce3d4df4e73f3535ae0b12f37809e0f92d2dffffffff2c06cf6f215c5cbfd7caa8e71b1b32630cabf1f816a4432815b037b277852e50010000006a473044022062151cf960b71823bbe68c7ed2c2a93ad1b9706a30255fddb02fcbe056d8c26102207bad1f0872bc5f0cfaf22e45c925c35d6c1466e303163b75cb7688038f1a5541412102595caf9aeb6ffdd0e82b150739a83297358b9a77564de382671056ad9e5b8c58ffffffff0170861d00000000001976a91434e9cec317896e818619ab7dc99d2305216ff4af88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000022c06cf6f215c5cbfd7caa8e71b1b32630cabf1f816a4432815b037b277852e50000000006a47304402207a2a955f1cb3dc5f03f2c82934f55654882af4e852e5159639f6349e9386ec4002205fb8419dce4e648eae8f67bc4e369adfb130a87d2ea2d668f8144213b12bb457412103174c61e9c5362507e8061e28d2c0ce3d4df4e73f3535ae0b12f37809e0f92d2dffffffff2c06cf6f215c5cbfd7caa8e71b1b32630cabf1f816a4432815b037b277852e50010000006a473044022062151cf960b71823bbe68c7ed2c2a93ad1b9706a30255fddb02fcbe056d8c26102207bad1f0872bc5f0cfaf22e45c925c35d6c1466e303163b75cb7688038f1a5541412102595caf9aeb6ffdd0e82b150739a83297358b9a77564de382671056ad9e5b8c58ffffffff0170861d00000000001976a91434e9cec317896e818619ab7dc99d2305216ff4af88ac00000000'
|
||||
|
||||
def test_attack_amount(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -113,7 +111,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
address_n=self.client.expand_path("44'/145'/0'/1/0"),
|
||||
# 1HADRPJpgqBzThepERpVXNi6qRgiLQRNoE
|
||||
amount=1896050 - 1,
|
||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
@ -121,7 +119,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
address_n=self.client.expand_path("44'/145'/0'/0/1"),
|
||||
# 1LRspCZNFJcbuNKQkXgHMDucctFRQya5a3
|
||||
amount=73452,
|
||||
prev_hash=binascii.unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_hash=unhexlify('502e8577b237b0152843a416f8f1ab0c63321b1be7a8cad7bf5c5c216fcf062c'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
@ -164,7 +162,8 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
])
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Bcash', [inp1, inp2], [out1], debug_processor=attack_processor)
|
||||
with pytest.raises(CallException):
|
||||
self.client.sign_tx('Bcash', [inp1, inp2], [out1], debug_processor=attack_processor)
|
||||
|
||||
def test_attack_change_input(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -173,7 +172,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
address_n=self.client.expand_path("44'/145'/1000'/0/0"),
|
||||
# 1MH9KKcvdCTY44xVDC2k3fjBbX5Cz29N1q
|
||||
amount=1995344,
|
||||
prev_hash=binascii.unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
||||
prev_hash=unhexlify('bc37c28dfb467d2ecb50261387bf752a3977d7e5337915071bb4151e6b711a78'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDADDRESS,
|
||||
)
|
||||
@ -218,7 +217,8 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
])
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Bcash', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||
with pytest.raises(CallException):
|
||||
self.client.sign_tx('Bcash', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||
|
||||
def test_send_bch_multisig_wrongchange(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -235,15 +235,15 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
)
|
||||
correcthorse = proto.HDNodeType(
|
||||
depth=1, fingerprint=0, child_num=0,
|
||||
chain_code=binascii.unhexlify('0000000000000000000000000000000000000000000000000000000000000000'),
|
||||
public_key=binascii.unhexlify('0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'))
|
||||
sig = binascii.unhexlify(b'304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae')
|
||||
chain_code=unhexlify('0000000000000000000000000000000000000000000000000000000000000000'),
|
||||
public_key=unhexlify('0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'))
|
||||
sig = unhexlify(b'304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae')
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=self.client.expand_path("44'/145'/1'/1/0"),
|
||||
multisig=getmultisig(1, 0, [b'', sig, b'']),
|
||||
# 3CPtPpL5mGAPdxUeUDfm2RNdWoSN9dKpXE
|
||||
amount=24000,
|
||||
prev_hash=binascii.unhexlify('f68caf10df12d5b07a34601d88fa6856c6edcbf4d05ebef3486510ae1c293d5f'),
|
||||
prev_hash=unhexlify('f68caf10df12d5b07a34601d88fa6856c6edcbf4d05ebef3486510ae1c293d5f'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
@ -270,8 +270,8 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
|
||||
])
|
||||
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1])
|
||||
self.assertEqual(binascii.hexlify(signatures1[0]), b'3044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000015f3d291cae106548f3be5ed0f4cbedc65668fa881d60347ab0d512df10af8cf601000000fc00473044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c4147304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae414c69522103d62b2af2272bbd67cbe30eeaf4226c7f2d57d2a0ed1aab5ab736fb40bb2f5ffe21036d5e0d7ca3589465711eec91436249d7234d3a994c219024fc75cec98fc02ae221024f58378a69b68e89301a6ff882116e0fa35446ec9bfd86532eeb05941ec1f8c853aeffffffff01d85900000000000017a9140bb11de6558871f49fc241341992ece9986f7c5c8700000000')
|
||||
assert hexlify(signatures1[0]) == b'3044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c'
|
||||
assert hexlify(serialized_tx) == b'01000000015f3d291cae106548f3be5ed0f4cbedc65668fa881d60347ab0d512df10af8cf601000000fc00473044022052ccf022b3684ecce9f961ce8828387b97267c86bedf0ce16a24bf014e62e42c022035d315ddbeeef7ab3456bd09aed8b625ea58852216b60e4b84ba9f85827d305c4147304402207274b5a4d15e75f3df7319a375557b0efba9b27bc63f9f183a17da95a6125c94022000efac57629f1522e2d3958430e2ef073b0706cfac06cce492651b79858f09ae414c69522103d62b2af2272bbd67cbe30eeaf4226c7f2d57d2a0ed1aab5ab736fb40bb2f5ffe21036d5e0d7ca3589465711eec91436249d7234d3a994c219024fc75cec98fc02ae221024f58378a69b68e89301a6ff882116e0fa35446ec9bfd86532eeb05941ec1f8c853aeffffffff01d85900000000000017a9140bb11de6558871f49fc241341992ece9986f7c5c8700000000'
|
||||
|
||||
def test_send_bch_multisig_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -291,7 +291,7 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
multisig=getmultisig(0, 0),
|
||||
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
|
||||
amount=48490,
|
||||
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
||||
prev_hash=unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
@ -320,14 +320,14 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
])
|
||||
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85')
|
||||
assert hexlify(signatures1[0]) == b'3045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85'
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=self.client.expand_path("44'/145'/1'/0/0"),
|
||||
multisig=getmultisig(0, 0, [b'', b'', signatures1[0]]),
|
||||
# 33Ju286QvonBz5N1V754ZekQv4GLJqcc5R
|
||||
amount=48490,
|
||||
prev_hash=binascii.unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
||||
prev_hash=unhexlify('8b6db9b8ba24235d86b053ea2ccb484fc32b96f89c3c39f98d86f90db16076a0'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
)
|
||||
@ -347,5 +347,5 @@ class TestMsgSigntxBch(common.TrezorTest):
|
||||
])
|
||||
(signatures1, serialized_tx) = self.client.sign_tx('Bcash', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa')
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000001a07660b10df9868df9393c9cf8962bc34f48cb2cea53b0865d2324bab8b96d8b00000000fdfe0000483045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa41483045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85414c69522102fcf63419c319ce1a42d69120a3599d6da8c5dd4caf2888220eccde5a1ff7c5d021036d7d5ef79370b7fabe2c058698a20219e97fc70868e65ecdd6b37cc18e8a88bd2103505dc649dab8cd1655a4c0daf0ec5f955881c9d7011478ea881fac11cab1e49953aeffffffff02c05d0000000000001976a91400741952f6a6eab5394f366db5cc5a54b0c2429f88acc05d00000000000017a914756c06d7e77de3950a6124f026d8e1a2464b3ecf8700000000')
|
||||
assert hexlify(signatures1[0]) == b'3045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa'
|
||||
assert hexlify(serialized_tx) == b'0100000001a07660b10df9868df9393c9cf8962bc34f48cb2cea53b0865d2324bab8b96d8b00000000fdfe0000483045022100f1153636371ba1f84389460e1265a8fa296569bc18e117c31f4e8f0fc0650c01022022932cc84766ff0c0f65ed9633ad311ae90d4c8fe71f5e1890b1e8f74dd516fa41483045022100bcb1a7134a13025a06052546ee1c6ac3640a0abd2d130190ed13ed7fcb43e9cd02207c381478e2ee123c850425bfbf6d3c691230eb37e333832cb32a1ed3f2cd9e85414c69522102fcf63419c319ce1a42d69120a3599d6da8c5dd4caf2888220eccde5a1ff7c5d021036d7d5ef79370b7fabe2c058698a20219e97fc70868e65ecdd6b37cc18e8a88bd2103505dc649dab8cd1655a4c0daf0ec5f955881c9d7011478ea881fac11cab1e49953aeffffffff02c05d0000000000001976a91400741952f6a6eab5394f366db5cc5a54b0c2429f88acc05d00000000000017a914756c06d7e77de3950a6124f026d8e1a2464b3ecf8700000000'
|
||||
|
@ -15,25 +15,23 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.tx_api import TxApiDecredTestnet
|
||||
|
||||
|
||||
TXHASH_e16248 = binascii.unhexlify("e16248f0b39a0a0c0e53d6f2f84c2a944f0d50e017a82701e8e02e46e979d5ed")
|
||||
TXHASH_5e6e35 = binascii.unhexlify("5e6e3500a333c53c02f523db5f1a9b17538a8850b4c2c24ecb9b7ba48059b970")
|
||||
TXHASH_ccf95b = binascii.unhexlify("ccf95b0fd220ef59ae2e5b17005a81e222758122682d522eff8ae1fcbc93bc74")
|
||||
TXHASH_f395ef = binascii.unhexlify("f395ef3e72a831a766db15e7a38bc28025d4ee02234d68bdea2d8353b47a3113")
|
||||
TXHASH_3f7c39 = binascii.unhexlify("3f7c395521d38387e7617565fe17628723ef6635a08537ad9c46cfb1619e4c3f")
|
||||
TXHASH_16da18 = binascii.unhexlify("16da185052740d85a630e79c140558215b64e26c500212b90e16b55d13ca06a8")
|
||||
TXHASH_e16248 = unhexlify("e16248f0b39a0a0c0e53d6f2f84c2a944f0d50e017a82701e8e02e46e979d5ed")
|
||||
TXHASH_5e6e35 = unhexlify("5e6e3500a333c53c02f523db5f1a9b17538a8850b4c2c24ecb9b7ba48059b970")
|
||||
TXHASH_ccf95b = unhexlify("ccf95b0fd220ef59ae2e5b17005a81e222758122682d522eff8ae1fcbc93bc74")
|
||||
TXHASH_f395ef = unhexlify("f395ef3e72a831a766db15e7a38bc28025d4ee02234d68bdea2d8353b47a3113")
|
||||
TXHASH_3f7c39 = unhexlify("3f7c395521d38387e7617565fe17628723ef6635a08537ad9c46cfb1619e4c3f")
|
||||
TXHASH_16da18 = unhexlify("16da185052740d85a630e79c140558215b64e26c500212b90e16b55d13ca06a8")
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgSigntxDecred(common.TrezorTest):
|
||||
class TestMsgSigntxDecred(TrezorTest):
|
||||
|
||||
def test_send_decred(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -72,7 +70,7 @@ class TestMsgSigntxDecred(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx("Decred Testnet", [inp1], [out1])
|
||||
|
||||
# Accepted by network: 5e6e3500a333c53c02f523db5f1a9b17538a8850b4c2c24ecb9b7ba48059b970
|
||||
self.assertEqual(serialized_tx, binascii.unhexlify("0100000001edd579e9462ee0e80127a817e0500d4f942a4cf8f2d6530e0c0a9ab3f04862e10100000000ffffffff01802b530b0000000000001976a914819d291a2f7fbf770e784bfd78b5ce92c58e95ea88ac000000000000000001000000000000000000000000ffffffff6b483045022100bad68486491e449a731513805c129201d7f65601d6f07c97fda0588453c97d22022013e9ef59657ae4f344ac4f0db2b7a23dbfcdb51ebeb85277146ac189e547d3f7012102f5a745afb96077c071e4d19911a5d3d024faa1314ee8688bc6eec39751d0818f"))
|
||||
assert serialized_tx == unhexlify("0100000001edd579e9462ee0e80127a817e0500d4f942a4cf8f2d6530e0c0a9ab3f04862e10100000000ffffffff01802b530b0000000000001976a914819d291a2f7fbf770e784bfd78b5ce92c58e95ea88ac000000000000000001000000000000000000000000ffffffff6b483045022100bad68486491e449a731513805c129201d7f65601d6f07c97fda0588453c97d22022013e9ef59657ae4f344ac4f0db2b7a23dbfcdb51ebeb85277146ac189e547d3f7012102f5a745afb96077c071e4d19911a5d3d024faa1314ee8688bc6eec39751d0818f")
|
||||
|
||||
def test_send_decred_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -148,7 +146,7 @@ class TestMsgSigntxDecred(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx("Decred Testnet", [inp1, inp2, inp3], [out1, out2])
|
||||
|
||||
# Accepted by network: c5ff767141a162b665acf775fcc35b60ff622fbe21a21e0a6609ed768c3737f4
|
||||
self.assertEqual(serialized_tx, binascii.unhexlify("010000000370b95980a47b9bcb4ec2c2b450888a53179b1a5fdb23f5023cc533a300356e5e0000000000ffffffff74bc93bcfce18aff2e522d6822817522e2815a00175b2eae59ef20d20f5bf9cc0100000000ffffffff13317ab453832deabd684d2302eed42580c28ba3e715db66a731a8723eef95f30000000000ffffffff02d86c341d0000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac00e1f5050000000000001976a9146748ebb8694c069742ee69eab2159c33c7f57d2b88ac000000000000000003000000000000000000000000ffffffff6b483045022100d91237a32b8968e1d3316b76f045cc18fed12736aebd570dd023a61826279cc102204222b133189762368d3398d11eb9a6843a67de11d70ac58426a28b605fa102b1012102f5a745afb96077c071e4d19911a5d3d024faa1314ee8688bc6eec39751d0818f000000000000000000000000ffffffff69463043021f7cf9b0b180f3fcde8d3d036d81e575e368d6ab5c8c6a2ffef47c06a0170023022036b964bf26ff276c58862dfacafa93216618832d6240f16b6100a9d10d5eb753012102f5a745afb96077c071e4d19911a5d3d024faa1314ee8688bc6eec39751d0818f000000000000000000000000ffffffff6b48304502210098f3a0cc17c3383f5998c542950b5cccb1175cc94b8d0343f420dc64abe9a50e0220507974c6ef0761925634fe3e13ec458b8cd3e42856828d584d4a5d39cc4d0f890121022c6099c7af8124d58e97beefc85c529dcfb3865794d46ec04095e70872e32a2e"))
|
||||
assert serialized_tx == unhexlify("010000000370b95980a47b9bcb4ec2c2b450888a53179b1a5fdb23f5023cc533a300356e5e0000000000ffffffff74bc93bcfce18aff2e522d6822817522e2815a00175b2eae59ef20d20f5bf9cc0100000000ffffffff13317ab453832deabd684d2302eed42580c28ba3e715db66a731a8723eef95f30000000000ffffffff02d86c341d0000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac00e1f5050000000000001976a9146748ebb8694c069742ee69eab2159c33c7f57d2b88ac000000000000000003000000000000000000000000ffffffff6b483045022100d91237a32b8968e1d3316b76f045cc18fed12736aebd570dd023a61826279cc102204222b133189762368d3398d11eb9a6843a67de11d70ac58426a28b605fa102b1012102f5a745afb96077c071e4d19911a5d3d024faa1314ee8688bc6eec39751d0818f000000000000000000000000ffffffff69463043021f7cf9b0b180f3fcde8d3d036d81e575e368d6ab5c8c6a2ffef47c06a0170023022036b964bf26ff276c58862dfacafa93216618832d6240f16b6100a9d10d5eb753012102f5a745afb96077c071e4d19911a5d3d024faa1314ee8688bc6eec39751d0818f000000000000000000000000ffffffff6b48304502210098f3a0cc17c3383f5998c542950b5cccb1175cc94b8d0343f420dc64abe9a50e0220507974c6ef0761925634fe3e13ec458b8cd3e42856828d584d4a5d39cc4d0f890121022c6099c7af8124d58e97beefc85c529dcfb3865794d46ec04095e70872e32a2e")
|
||||
|
||||
def test_decred_multisig_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -242,4 +240,4 @@ class TestMsgSigntxDecred(common.TrezorTest):
|
||||
serialized_tx = test_multisig(0)
|
||||
|
||||
# Accepted by network: eccfecc0dc3275f7fa5a966b58c8d503f8b3d23964f2ce2c3336e5883919f45f
|
||||
self.assertEqual(serialized_tx, binascii.unhexlify("01000000023f4c9e61b1cf469cad3785a03566ef23876217fe657561e78783d32155397c3f0100000000ffffffffa806ca135db5160eb91202506ce2645b215805149ce730a6850d74525018da160000000000ffffffff02605af40500000000000017a914d42253369723b43e114b31807ef68f84363e54418700a3e1110000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac000000000000000002000000000000000000000000fffffffffc483045022100be61bbcfd804f1e092c432511884bf8bdc00b6d302f00811149d20628bf3d33502200680721d1d03a71476f65e8815e2fba35bec6be982aa7686a57134eeae9a66f3014730440220016f9dd48ca0ceecf481d96f2c65389abb491af5f0eb63d76eb0f6a67a99718b02204fdeadace9167472411bb44bb63009ebd2373aa77cc08989a25fca37648dc685014c69522102a7ee50c2ceeacaed42aea05b29ac2ac3ec3c7e151dd95780929f53a0011f97a121038f9ebf01b25d80b4b8ad179542859ca96a9c5c8cbf0b5a50a92c0d9a7501efe62103b8d7f5663458e545af7de7a037e61a0e32c291ed2695f3cae120d6a0fe98052e53ae000000000000000000000000fffffffffdfd00483045022100ca8dd36eee86c4cefecfdd91cdf40a35a4274f71c4283e5b98af6bc242e2d5ad022009247ea5663367c2964f61b6111ea1a0790b381a40310f4e867a3725b249f12c01483045022100abc7b1440c31a564e1cd9d0a75abaa5abd8c1285b874c0e97e311e697782954302202fa43fb00149bb2d14b1a31a81b7660d6c9a17c4621a07eb4c2290b627aa540a014c69522103334dd6c58fae3d462f359125f0d6835e57ad885e5058b417f217decc21fdbba4210392af36b8a65ea0bb6f0acdec9069a0b5b75b00d9667b89e2a77f92d4efc92b9821025945b9f11a71546afe4af28cd291830fd77cb184006a90223de1b2c26502bfc353ae"))
|
||||
assert serialized_tx == unhexlify("01000000023f4c9e61b1cf469cad3785a03566ef23876217fe657561e78783d32155397c3f0100000000ffffffffa806ca135db5160eb91202506ce2645b215805149ce730a6850d74525018da160000000000ffffffff02605af40500000000000017a914d42253369723b43e114b31807ef68f84363e54418700a3e1110000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac000000000000000002000000000000000000000000fffffffffc483045022100be61bbcfd804f1e092c432511884bf8bdc00b6d302f00811149d20628bf3d33502200680721d1d03a71476f65e8815e2fba35bec6be982aa7686a57134eeae9a66f3014730440220016f9dd48ca0ceecf481d96f2c65389abb491af5f0eb63d76eb0f6a67a99718b02204fdeadace9167472411bb44bb63009ebd2373aa77cc08989a25fca37648dc685014c69522102a7ee50c2ceeacaed42aea05b29ac2ac3ec3c7e151dd95780929f53a0011f97a121038f9ebf01b25d80b4b8ad179542859ca96a9c5c8cbf0b5a50a92c0d9a7501efe62103b8d7f5663458e545af7de7a037e61a0e32c291ed2695f3cae120d6a0fe98052e53ae000000000000000000000000fffffffffdfd00483045022100ca8dd36eee86c4cefecfdd91cdf40a35a4274f71c4283e5b98af6bc242e2d5ad022009247ea5663367c2964f61b6111ea1a0790b381a40310f4e867a3725b249f12c01483045022100abc7b1440c31a564e1cd9d0a75abaa5abd8c1285b874c0e97e311e697782954302202fa43fb00149bb2d14b1a31a81b7660d6c9a17c4621a07eb4c2290b627aa540a014c69522103334dd6c58fae3d462f359125f0d6835e57ad885e5058b417f217decc21fdbba4210392af36b8a65ea0bb6f0acdec9069a0b5b75b00d9667b89e2a77f92d4efc92b9821025945b9f11a71546afe4af28cd291830fd77cb184006a90223de1b2c26502bfc353ae")
|
||||
|
@ -15,8 +15,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.tx_api import TxApiTestnet
|
||||
@ -24,7 +23,7 @@ from trezorlib.ckd_public import deserialize
|
||||
from trezorlib.client import CallException
|
||||
|
||||
|
||||
class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
class TestMsgSigntxSegwit(TrezorTest):
|
||||
|
||||
def test_send_p2sh(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -33,7 +32,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
@ -63,7 +62,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000')
|
||||
assert hexlify(serialized_tx) == b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'
|
||||
|
||||
def test_send_p2sh_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -72,7 +71,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
@ -101,7 +100,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000')
|
||||
assert hexlify(serialized_tx) == b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'
|
||||
|
||||
def test_send_multisig_1(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -115,7 +114,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
||||
prev_hash=binascii.unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
||||
prev_hash=unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
multisig=multisig,
|
||||
@ -154,7 +153,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
])
|
||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000000101be0210025c5be68a473f6a38bf53b53bc88d5c46567616026dc056e72b92319c01000000232200201e8dda334f11171190b3da72e526d441491464769679a319a2f011da5ad312a1ffffffff01887d1800000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac040047304402205b44c20cf2681690edaaf7cd2e30d4704124dd8b7eb1fb7f459d3906c3c374a602205ca359b6544ce2c101c979899c782f7d141c3b0454ea69202b1fb4c09d3b715701473044022052fafa64022554ae436dbf781e550bf0d326fef31eea1438350b3ff1940a180102202851bd19203b7fe8582a9ef52e82aa9f61cd52d4bcedfe6dcc0cf782468e6a8e01695221038e81669c085a5846e68e03875113ddb339ecbb7cb11376d4163bca5dc2e2a0c1210348c5c3be9f0e6cf1954ded1c0475beccc4d26aaa9d0cce2dd902538ff1018a112103931140ebe0fbbb7df0be04ed032a54e9589e30339ba7bbb8b0b71b15df1294da53ae00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000000101be0210025c5be68a473f6a38bf53b53bc88d5c46567616026dc056e72b92319c01000000232200201e8dda334f11171190b3da72e526d441491464769679a319a2f011da5ad312a1ffffffff01887d1800000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac040047304402205b44c20cf2681690edaaf7cd2e30d4704124dd8b7eb1fb7f459d3906c3c374a602205ca359b6544ce2c101c979899c782f7d141c3b0454ea69202b1fb4c09d3b715701473044022052fafa64022554ae436dbf781e550bf0d326fef31eea1438350b3ff1940a180102202851bd19203b7fe8582a9ef52e82aa9f61cd52d4bcedfe6dcc0cf782468e6a8e01695221038e81669c085a5846e68e03875113ddb339ecbb7cb11376d4163bca5dc2e2a0c1210348c5c3be9f0e6cf1954ded1c0475beccc4d26aaa9d0cce2dd902538ff1018a112103931140ebe0fbbb7df0be04ed032a54e9589e30339ba7bbb8b0b71b15df1294da53ae00000000'
|
||||
|
||||
def test_attack_change_input_address(self):
|
||||
# This unit test attempts to modify input address after the Trezor checked
|
||||
@ -166,7 +165,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
@ -221,7 +220,7 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a914dae9e09a7fc3bbe5a716fffec1bbb340b82a4fb9870248304502210099b5c4f8fd4402c9c0136fee5f711137d64fc9f14587e01bfa7798f5428f845d0220253e21c98f5b1b64efae69bc2ea9799c5620a43450baa6762a0c3cf4fdc886e5012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000')
|
||||
assert hexlify(serialized_tx) == b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a914dae9e09a7fc3bbe5a716fffec1bbb340b82a4fb9870248304502210099b5c4f8fd4402c9c0136fee5f711137d64fc9f14587e01bfa7798f5428f845d0220253e21c98f5b1b64efae69bc2ea9799c5620a43450baa6762a0c3cf4fdc886e5012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'
|
||||
|
||||
# Now run the attack, must trigger the exception
|
||||
with self.client:
|
||||
@ -234,4 +233,5 @@ class TestMsgSigntxSegwit(common.TrezorTest):
|
||||
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||
proto.Failure(code=proto.FailureType.ProcessError),
|
||||
])
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||
with pytest.raises(CallException):
|
||||
self.client.sign_tx('Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
|
||||
|
@ -15,15 +15,14 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.tx_api import TxApiTestnet
|
||||
from trezorlib.ckd_public import deserialize
|
||||
|
||||
|
||||
class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
class TestMsgSigntxSegwitNative(TrezorTest):
|
||||
|
||||
def test_send_p2sh(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -32,7 +31,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
@ -62,7 +61,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001600140099a7ecbd938ed1839f5f6bf6d50933c6db9d5c3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100bd3d8b8ad35c094e01f6282277300e575f1021678fc63ec3f9945d6e35670da3022052e26ef0dd5f3741c9d5939d1dec5464c15ab5f2c85245e70a622df250d4eb7c012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000')
|
||||
assert hexlify(serialized_tx) == b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001600140099a7ecbd938ed1839f5f6bf6d50933c6db9d5c3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100bd3d8b8ad35c094e01f6282277300e575f1021678fc63ec3f9945d6e35670da3022052e26ef0dd5f3741c9d5939d1dec5464c15ab5f2c85245e70a622df250d4eb7c012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'
|
||||
|
||||
def test_send_p2sh_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -71,7 +70,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=123456789,
|
||||
prev_hash=binascii.unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_hash=unhexlify('20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
@ -100,7 +99,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001600140099a7ecbd938ed1839f5f6bf6d50933c6db9d5c3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100bd3d8b8ad35c094e01f6282277300e575f1021678fc63ec3f9945d6e35670da3022052e26ef0dd5f3741c9d5939d1dec5464c15ab5f2c85245e70a622df250d4eb7c012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000')
|
||||
assert hexlify(serialized_tx) == b'0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001600140099a7ecbd938ed1839f5f6bf6d50933c6db9d5c3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca8702483045022100bd3d8b8ad35c094e01f6282277300e575f1021678fc63ec3f9945d6e35670da3022052e26ef0dd5f3741c9d5939d1dec5464c15ab5f2c85245e70a622df250d4eb7c012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'
|
||||
|
||||
def test_send_native(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -109,7 +108,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/0/0"),
|
||||
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
|
||||
amount=12300000,
|
||||
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||
prev_hash=unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
@ -139,7 +138,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000001018a44999c07bba32df1cacdc50987944e68e3205b4429438fdde35c76024614090000000000ffffffff02404b4c000000000017a9147a55d61848e77ca266e79a39bfc85c580a6426c987a8386f0000000000160014d16b8c0680c61fc6ed2e407455715055e41052f502483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000')
|
||||
assert hexlify(serialized_tx) == b'010000000001018a44999c07bba32df1cacdc50987944e68e3205b4429438fdde35c76024614090000000000ffffffff02404b4c000000000017a9147a55d61848e77ca266e79a39bfc85c580a6426c987a8386f0000000000160014d16b8c0680c61fc6ed2e407455715055e41052f502483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000'
|
||||
|
||||
def test_send_native_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -148,7 +147,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/0/0"),
|
||||
# tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s
|
||||
amount=12300000,
|
||||
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||
prev_hash=unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
@ -177,7 +176,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000001018a44999c07bba32df1cacdc50987944e68e3205b4429438fdde35c76024614090000000000ffffffff02404b4c000000000017a9147a55d61848e77ca266e79a39bfc85c580a6426c987a8386f0000000000160014d16b8c0680c61fc6ed2e407455715055e41052f502483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000')
|
||||
assert hexlify(serialized_tx) == b'010000000001018a44999c07bba32df1cacdc50987944e68e3205b4429438fdde35c76024614090000000000ffffffff02404b4c000000000017a9147a55d61848e77ca266e79a39bfc85c580a6426c987a8386f0000000000160014d16b8c0680c61fc6ed2e407455715055e41052f502483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000'
|
||||
|
||||
def test_send_both(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -186,7 +185,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||
# 2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX
|
||||
amount=111145789,
|
||||
prev_hash=binascii.unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||
prev_hash=unhexlify('09144602765ce3dd8f4329445b20e3684e948709c5cdcaf12da3bb079c99448a'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
)
|
||||
@ -194,7 +193,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
address_n=self.client.expand_path("49'/1'/0'/1/0"),
|
||||
# tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu
|
||||
amount=7289000,
|
||||
prev_hash=binascii.unhexlify('65b811d3eca0fe6915d9f2d77c86c5a7f19bf66b1b1253c2c51cb4ae5f0c017b'),
|
||||
prev_hash=unhexlify('65b811d3eca0fe6915d9f2d77c86c5a7f19bf66b1b1253c2c51cb4ae5f0c017b'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
@ -239,7 +238,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Testnet', [inp1, inp2], [out1, out2, out3])
|
||||
|
||||
# 0e480a97c7a545c85e101a2f13c9af0e115d43734e1448f0cac3e55fe8e7399d
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000001028a44999c07bba32df1cacdc50987944e68e3205b4429438fdde35c76024614090100000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff7b010c5faeb41cc5c253121b6bf69bf1a7c5867cd7f2d91569fea0ecd311b8650100000000ffffffff03e0aebb0000000000160014a579388225827d9f2fe9014add644487808c695d00cdb7020000000017a91491233e24a9bf8dbb19c1187ad876a9380c12e787870d859b03000000001976a914a579388225827d9f2fe9014add644487808c695d88ac02483045022100ead79ee134f25bb585b48aee6284a4bb14e07f03cc130253e83450d095515e5202201e161e9402c8b26b666f2b67e5b668a404ef7e57858ae9a6a68c3837e65fdc69012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7902483045022100b4099ec4c7b3123795b3c080a86f4b745f3784eb3f77de79bef1d8da319cbee5022039766865d448a4a3e435a95d0df3ff56ebc6532bf538988a7e8a679b40ec41b6012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000')
|
||||
assert hexlify(serialized_tx) == b'010000000001028a44999c07bba32df1cacdc50987944e68e3205b4429438fdde35c76024614090100000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff7b010c5faeb41cc5c253121b6bf69bf1a7c5867cd7f2d91569fea0ecd311b8650100000000ffffffff03e0aebb0000000000160014a579388225827d9f2fe9014add644487808c695d00cdb7020000000017a91491233e24a9bf8dbb19c1187ad876a9380c12e787870d859b03000000001976a914a579388225827d9f2fe9014add644487808c695d88ac02483045022100ead79ee134f25bb585b48aee6284a4bb14e07f03cc130253e83450d095515e5202201e161e9402c8b26b666f2b67e5b668a404ef7e57858ae9a6a68c3837e65fdc69012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7902483045022100b4099ec4c7b3123795b3c080a86f4b745f3784eb3f77de79bef1d8da319cbee5022039766865d448a4a3e435a95d0df3ff56ebc6532bf538988a7e8a679b40ec41b6012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'
|
||||
|
||||
def test_send_multisig_1(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -253,7 +252,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
||||
prev_hash=binascii.unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
||||
prev_hash=unhexlify('9c31922be756c06d02167656465c8dc83bb553bf386a3f478ae65b5c021002be'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
multisig=multisig,
|
||||
@ -295,7 +294,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||
|
||||
# f41cbedd8becee05a830f418d13aa665125464547db5c7a6cd28f21639fe1228
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000000101be0210025c5be68a473f6a38bf53b53bc88d5c46567616026dc056e72b92319c01000000232200201e8dda334f11171190b3da72e526d441491464769679a319a2f011da5ad312a1ffffffff01887d180000000000220020c5f4a0a4ea7c0392efe0a9670a73264cffa90b19107cd8a8e9750ff93c77fdfb0400483045022100a9b681f324ff4cf419ab06820d07248cc4e359c77334bf448ae7b5cdf3995ddf022039811f91f55b602368b4ba08a217b82bfd62d1a97dc635deb1457e7cfcc1550b0147304402201ad86a795c3d26881d696fa0a0619c24c4d505718132a82965cc2a609c9d8798022067cd490ce1366cde77e307ced5b13040bbc04991619ea6f49e06cece9a83268b01695221038e81669c085a5846e68e03875113ddb339ecbb7cb11376d4163bca5dc2e2a0c1210348c5c3be9f0e6cf1954ded1c0475beccc4d26aaa9d0cce2dd902538ff1018a112103931140ebe0fbbb7df0be04ed032a54e9589e30339ba7bbb8b0b71b15df1294da53ae00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000000101be0210025c5be68a473f6a38bf53b53bc88d5c46567616026dc056e72b92319c01000000232200201e8dda334f11171190b3da72e526d441491464769679a319a2f011da5ad312a1ffffffff01887d180000000000220020c5f4a0a4ea7c0392efe0a9670a73264cffa90b19107cd8a8e9750ff93c77fdfb0400483045022100a9b681f324ff4cf419ab06820d07248cc4e359c77334bf448ae7b5cdf3995ddf022039811f91f55b602368b4ba08a217b82bfd62d1a97dc635deb1457e7cfcc1550b0147304402201ad86a795c3d26881d696fa0a0619c24c4d505718132a82965cc2a609c9d8798022067cd490ce1366cde77e307ced5b13040bbc04991619ea6f49e06cece9a83268b01695221038e81669c085a5846e68e03875113ddb339ecbb7cb11376d4163bca5dc2e2a0c1210348c5c3be9f0e6cf1954ded1c0475beccc4d26aaa9d0cce2dd902538ff1018a112103931140ebe0fbbb7df0be04ed032a54e9589e30339ba7bbb8b0b71b15df1294da53ae00000000'
|
||||
|
||||
def test_send_multisig_2(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -309,7 +308,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=self.client.expand_path("999'/1'/2'/2/1"),
|
||||
prev_hash=binascii.unhexlify('f41cbedd8becee05a830f418d13aa665125464547db5c7a6cd28f21639fe1228'),
|
||||
prev_hash=unhexlify('f41cbedd8becee05a830f418d13aa665125464547db5c7a6cd28f21639fe1228'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
multisig=multisig,
|
||||
@ -351,7 +350,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||
|
||||
# c9348040bbc2024e12dcb4a0b4806b0398646b91acf314da028c3f03dd0179fc
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000001012812fe3916f228cda6c7b57d5464541265a63ad118f430a805eeec8bddbe1cf40000000000ffffffff01a0791800000000002200201e8dda334f11171190b3da72e526d441491464769679a319a2f011da5ad312a10400483045022100cc97f21a7cabc543a9b4ac52424e8f7e420622903f2417a1c08a6af68058ec4a02200baca0b222fc825078d94e8e1b55f174c4828bed16697e4281cda2a0c799eecf01473044022009b8058dc30fa7a13310dd8f1a99c4341c4cd95f771c5a41c4381f956e2344c102205e829c560c0184fd4b4db8971f99711e2a87409afa4df0840b4f12a87b2c8afc0169522102740ec30d0af8591a0dd4a3e3b274e57f3f73bdc0638a9603f9ee6ade0475ba57210311aada919974e882abf0c67b5c0fba00000b26997312ca00345027d22359443021029382591271a79d4b12365fa27c67fad3753150d8eaa987e5a12dc5ba1bb2fa1653ae00000000')
|
||||
assert hexlify(serialized_tx) == b'010000000001012812fe3916f228cda6c7b57d5464541265a63ad118f430a805eeec8bddbe1cf40000000000ffffffff01a0791800000000002200201e8dda334f11171190b3da72e526d441491464769679a319a2f011da5ad312a10400483045022100cc97f21a7cabc543a9b4ac52424e8f7e420622903f2417a1c08a6af68058ec4a02200baca0b222fc825078d94e8e1b55f174c4828bed16697e4281cda2a0c799eecf01473044022009b8058dc30fa7a13310dd8f1a99c4341c4cd95f771c5a41c4381f956e2344c102205e829c560c0184fd4b4db8971f99711e2a87409afa4df0840b4f12a87b2c8afc0169522102740ec30d0af8591a0dd4a3e3b274e57f3f73bdc0638a9603f9ee6ade0475ba57210311aada919974e882abf0c67b5c0fba00000b26997312ca00345027d22359443021029382591271a79d4b12365fa27c67fad3753150d8eaa987e5a12dc5ba1bb2fa1653ae00000000'
|
||||
|
||||
def test_send_multisig_3_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -370,7 +369,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=self.client.expand_path("999'/1'/1'/2/0"),
|
||||
prev_hash=binascii.unhexlify('c9348040bbc2024e12dcb4a0b4806b0398646b91acf314da028c3f03dd0179fc'),
|
||||
prev_hash=unhexlify('c9348040bbc2024e12dcb4a0b4806b0398646b91acf314da028c3f03dd0179fc'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDWITNESS,
|
||||
multisig=multisig,
|
||||
@ -412,7 +411,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||
|
||||
# 31bc1c88ce6ae337a6b3057a16d5bad0b561ad1dfc047d0a7fbb8814668f91e5
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000000101fc7901dd033f8c02da14f3ac916b6498036b80b4a0b4dc124e02c2bb408034c90000000000ffffffff01b87518000000000017a914a8655acf68f785125561158b0f4db9b5d0044047870400473044022057b571986c07f8ccb231811334ad06ee6f87b722495def2e9511c1da46f3433202207b6e95bdd99e7fc7d319486437cb930d40a4af3cd753c4cb960b330badbf7f35014730440220517ecc6d0a2544276921d8fc2077aec4285ab83b1b21f5eb73cdb6187a0583e4022043fb5ab942f8981c04a54c66a57c4d291fad8514d4a8afea09f01f2db7a8f32901695221038e81669c085a5846e68e03875113ddb339ecbb7cb11376d4163bca5dc2e2a0c1210348c5c3be9f0e6cf1954ded1c0475beccc4d26aaa9d0cce2dd902538ff1018a112103931140ebe0fbbb7df0be04ed032a54e9589e30339ba7bbb8b0b71b15df1294da53ae00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000000101fc7901dd033f8c02da14f3ac916b6498036b80b4a0b4dc124e02c2bb408034c90000000000ffffffff01b87518000000000017a914a8655acf68f785125561158b0f4db9b5d0044047870400473044022057b571986c07f8ccb231811334ad06ee6f87b722495def2e9511c1da46f3433202207b6e95bdd99e7fc7d319486437cb930d40a4af3cd753c4cb960b330badbf7f35014730440220517ecc6d0a2544276921d8fc2077aec4285ab83b1b21f5eb73cdb6187a0583e4022043fb5ab942f8981c04a54c66a57c4d291fad8514d4a8afea09f01f2db7a8f32901695221038e81669c085a5846e68e03875113ddb339ecbb7cb11376d4163bca5dc2e2a0c1210348c5c3be9f0e6cf1954ded1c0475beccc4d26aaa9d0cce2dd902538ff1018a112103931140ebe0fbbb7df0be04ed032a54e9589e30339ba7bbb8b0b71b15df1294da53ae00000000'
|
||||
|
||||
def test_send_multisig_4_change(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -431,7 +430,7 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=self.client.expand_path("999'/1'/1'/1/1"),
|
||||
prev_hash=binascii.unhexlify('31bc1c88ce6ae337a6b3057a16d5bad0b561ad1dfc047d0a7fbb8814668f91e5'),
|
||||
prev_hash=unhexlify('31bc1c88ce6ae337a6b3057a16d5bad0b561ad1dfc047d0a7fbb8814668f91e5'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDP2SHWITNESS,
|
||||
multisig=multisig,
|
||||
@ -473,4 +472,4 @@ class TestMsgSigntxSegwitNative(common.TrezorTest):
|
||||
(signatures2, serialized_tx) = self.client.sign_tx('Testnet', [inp1], [out1])
|
||||
|
||||
# c0bf56060a109624b4635222696d94a7d533cacea1b3f8245417a4348c045829
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000000101e5918f661488bb7f0a7d04fc1dad61b5d0bad5167a05b3a637e36ace881cbc3100000000232200205b9824093eaf5cdcf8247c00dc0b557a7720957828fcde8384ac11f80a91f403ffffffff01d071180000000000220020e77caf5fbef07b1e461475c02afd4aed877693263d69c81e14617304349b629a040047304402204832553b0da1009da496881e58e8e2e41010cfe5c0161623048093f1b1a817b7022020dad8bf887acf574af80bfe4b39cd24e95019fd5e6b8ae967471e21ddc67354014830450221009e5d60847e7275edcf4619ed8ee462c56a042eef75d17da2d44e6b13d78e50e50220665195492900ef87a5eb8a924fa0ac9afc4fc75ca704ff356dc3a213979970c80169522103f4040006e3561b3e76c6d4113225c84748ab9d55ffd23f9578ab4c18fb0c3b9721020975f2e6922897ff6b80da6412a8d6ebd67e33c9611d081656a53ef967964e5021026b0546f23a6ce6b756c2c30b4176ce6f1c3268744f7aca82668d5116c4f764e453ae00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000000101e5918f661488bb7f0a7d04fc1dad61b5d0bad5167a05b3a637e36ace881cbc3100000000232200205b9824093eaf5cdcf8247c00dc0b557a7720957828fcde8384ac11f80a91f403ffffffff01d071180000000000220020e77caf5fbef07b1e461475c02afd4aed877693263d69c81e14617304349b629a040047304402204832553b0da1009da496881e58e8e2e41010cfe5c0161623048093f1b1a817b7022020dad8bf887acf574af80bfe4b39cd24e95019fd5e6b8ae967471e21ddc67354014830450221009e5d60847e7275edcf4619ed8ee462c56a042eef75d17da2d44e6b13d78e50e50220665195492900ef87a5eb8a924fa0ac9afc4fc75ca704ff356dc3a213979970c80169522103f4040006e3561b3e76c6d4113225c84748ab9d55ffd23f9578ab4c18fb0c3b9721020975f2e6922897ff6b80da6412a8d6ebd67e33c9611d081656a53ef967964e5021026b0546f23a6ce6b756c2c30b4176ce6f1c3268744f7aca82668d5116c4f764e453ae00000000'
|
||||
|
@ -17,19 +17,17 @@
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.tx_api import TxApiZcash
|
||||
|
||||
|
||||
TXHASH_93373e = binascii.unhexlify('93373e63cc626c4a7d049ad775d6511bb5eba985f142db660c9b9f955c722f5c')
|
||||
TXHASH_93373e = unhexlify('93373e63cc626c4a7d049ad775d6511bb5eba985f142db660c9b9f955c722f5c')
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgSigntxZcash(common.TrezorTest):
|
||||
class TestMsgSigntxZcash(TrezorTest):
|
||||
|
||||
def test_one_one_fee(self):
|
||||
self.setup_mnemonic_allallall()
|
||||
@ -72,4 +70,4 @@ class TestMsgSigntxZcash(common.TrezorTest):
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Zcash', [inp1, ], [out1, ])
|
||||
|
||||
# Accepted by network: tx dcc2a10894e0e8a785c2afd4de2d958207329b9acc2b987fd768a09c5efc4547
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000015c2f725c959f9b0c66db42f185a9ebb51b51d675d79a047d4a6c62cc633e3793000000006a4730440220670b2b63d749a7038f9aea6ddf0302fe63bdcad93dafa4a89a1f0e7300ae2484022002c50af43fd867490cea0c527273c5828ff1b9a5115678f155a1830737cf29390121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff0128c55b07000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000015c2f725c959f9b0c66db42f185a9ebb51b51d675d79a047d4a6c62cc633e3793000000006a4730440220670b2b63d749a7038f9aea6ddf0302fe63bdcad93dafa4a89a1f0e7300ae2484022002c50af43fd867490cea0c527273c5828ff1b9a5115678f155a1830737cf29390121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff0128c55b07000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000'
|
||||
|
@ -16,32 +16,31 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
import base64
|
||||
|
||||
|
||||
class TestMsgVerifymessage(common.TrezorTest):
|
||||
class TestMsgVerifymessage(TrezorTest):
|
||||
|
||||
def test_message_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e',
|
||||
binascii.unhexlify('205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'),
|
||||
unhexlify('205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'),
|
||||
"VeryLongMessage!" * 64
|
||||
)
|
||||
self.assertTrue(ret)
|
||||
assert ret is True
|
||||
|
||||
def test_message_testnet(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.verify_message(
|
||||
'Testnet',
|
||||
'mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL',
|
||||
binascii.unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(ret)
|
||||
assert ret is True
|
||||
|
||||
def test_message_verify(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -50,80 +49,80 @@ class TestMsgVerifymessage(common.TrezorTest):
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T',
|
||||
binascii.unhexlify('1ba77e01a9e17ba158b962cfef5f13dfed676ffc2b4bada24e58f784458b52b97421470d001d53d5880cf5e10e76f02be3e80bf21e18398cbd41e8c3b4af74c8c2'),
|
||||
unhexlify('1ba77e01a9e17ba158b962cfef5f13dfed676ffc2b4bada24e58f784458b52b97421470d001d53d5880cf5e10e76f02be3e80bf21e18398cbd41e8c3b4af74c8c2'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(res)
|
||||
assert res is True
|
||||
|
||||
# uncompressed pubkey - FAIL - wrong sig
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T',
|
||||
binascii.unhexlify('1ba77e01a9e17ba158b962cfef5f13dfed676ffc2b4bada24e58f784458b52b97421470d001d53d5880cf5e10e76f02be3e80bf21e18398cbd41e8c3b4af74c800'),
|
||||
unhexlify('1ba77e01a9e17ba158b962cfef5f13dfed676ffc2b4bada24e58f784458b52b97421470d001d53d5880cf5e10e76f02be3e80bf21e18398cbd41e8c3b4af74c800'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
# uncompressed pubkey - FAIL - wrong msg
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T',
|
||||
binascii.unhexlify('1ba77e01a9e17ba158b962cfef5f13dfed676ffc2b4bada24e58f784458b52b97421470d001d53d5880cf5e10e76f02be3e80bf21e18398cbd41e8c3b4af74c8c2'),
|
||||
unhexlify('1ba77e01a9e17ba158b962cfef5f13dfed676ffc2b4bada24e58f784458b52b97421470d001d53d5880cf5e10e76f02be3e80bf21e18398cbd41e8c3b4af74c8c2'),
|
||||
'This is an example of a signed message!'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
# compressed pubkey - OK
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8',
|
||||
binascii.unhexlify('1f44e3e461f7ca9f57c472ce1a28214df1de1dadefb6551a32d1907b80c74d5a1fbfd6daaba12dd8cb06699ce3f6941fbe0f3957b5802d13076181046e741eaaaf'),
|
||||
unhexlify('1f44e3e461f7ca9f57c472ce1a28214df1de1dadefb6551a32d1907b80c74d5a1fbfd6daaba12dd8cb06699ce3f6941fbe0f3957b5802d13076181046e741eaaaf'),
|
||||
'This is an example of a signed message.')
|
||||
self.assertTrue(res)
|
||||
assert res is True
|
||||
|
||||
# compressed pubkey - FAIL - wrong sig
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8',
|
||||
binascii.unhexlify('1f44e3e461f7ca9f57c472ce1a28214df1de1dadefb6551a32d1907b80c74d5a1fbfd6daaba12dd8cb06699ce3f6941fbe0f3957b5802d13076181046e741eaa00'),
|
||||
unhexlify('1f44e3e461f7ca9f57c472ce1a28214df1de1dadefb6551a32d1907b80c74d5a1fbfd6daaba12dd8cb06699ce3f6941fbe0f3957b5802d13076181046e741eaa00'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
# compressed pubkey - FAIL - wrong msg
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8',
|
||||
binascii.unhexlify('1f44e3e461f7ca9f57c472ce1a28214df1de1dadefb6551a32d1907b80c74d5a1fbfd6daaba12dd8cb06699ce3f6941fbe0f3957b5802d13076181046e741eaaaf'),
|
||||
unhexlify('1f44e3e461f7ca9f57c472ce1a28214df1de1dadefb6551a32d1907b80c74d5a1fbfd6daaba12dd8cb06699ce3f6941fbe0f3957b5802d13076181046e741eaaaf'),
|
||||
'This is an example of a signed message!')
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
# trezor pubkey - OK
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e',
|
||||
binascii.unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(res)
|
||||
assert res is True
|
||||
|
||||
# trezor pubkey - FAIL - wrong sig
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e',
|
||||
binascii.unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be00'),
|
||||
unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be00'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
# trezor pubkey - FAIL - wrong msg
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e',
|
||||
binascii.unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message!'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
def test_verify_bitcoind(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -131,11 +130,11 @@ class TestMsgVerifymessage(common.TrezorTest):
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'1KzXE97kV7DrpxCViCN3HbGbiKhzzPM7TQ',
|
||||
binascii.unhexlify('1cc694f0f23901dfe3603789142f36a3fc582d0d5c0ec7215cf2ccd641e4e37228504f3d4dc3eea28bbdbf5da27c49d4635c097004d9f228750ccd836a8e1460c0'),
|
||||
unhexlify('1cc694f0f23901dfe3603789142f36a3fc582d0d5c0ec7215cf2ccd641e4e37228504f3d4dc3eea28bbdbf5da27c49d4635c097004d9f228750ccd836a8e1460c0'),
|
||||
u'\u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy'
|
||||
)
|
||||
|
||||
self.assertTrue(res)
|
||||
assert res is True
|
||||
|
||||
def test_verify_utf(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -146,16 +145,16 @@ class TestMsgVerifymessage(common.TrezorTest):
|
||||
res_nfkd = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e',
|
||||
binascii.unhexlify('20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
unhexlify('20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
words_nfkd
|
||||
)
|
||||
|
||||
res_nfc = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e',
|
||||
binascii.unhexlify('20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
unhexlify('20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
words_nfc
|
||||
)
|
||||
|
||||
self.assertTrue(res_nfkd)
|
||||
self.assertTrue(res_nfc)
|
||||
assert res_nfkd is True
|
||||
assert res_nfc is True
|
||||
|
@ -16,34 +16,32 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
import base64
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgVerifymessageSegwit(common.TrezorTest):
|
||||
class TestMsgVerifymessageSegwit(TrezorTest):
|
||||
|
||||
def test_message_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1',
|
||||
binascii.unhexlify('245ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'),
|
||||
unhexlify('245ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'),
|
||||
"VeryLongMessage!" * 64
|
||||
)
|
||||
self.assertTrue(ret)
|
||||
assert ret is True
|
||||
|
||||
def test_message_testnet(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.verify_message(
|
||||
'Testnet',
|
||||
'2N4VkePSzKH2sv5YBikLHGvzUYvfPxV6zS9',
|
||||
binascii.unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(ret)
|
||||
assert ret is True
|
||||
|
||||
def test_message_verify(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -52,28 +50,28 @@ class TestMsgVerifymessageSegwit(common.TrezorTest):
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1',
|
||||
binascii.unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(res)
|
||||
assert res is True
|
||||
|
||||
# trezor pubkey - FAIL - wrong sig
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1',
|
||||
binascii.unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be00'),
|
||||
unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be00'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
# trezor pubkey - FAIL - wrong msg
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1',
|
||||
binascii.unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message!'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
def test_verify_utf(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -84,16 +82,16 @@ class TestMsgVerifymessageSegwit(common.TrezorTest):
|
||||
res_nfkd = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1',
|
||||
binascii.unhexlify('24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
unhexlify('24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
words_nfkd
|
||||
)
|
||||
|
||||
res_nfc = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1',
|
||||
binascii.unhexlify('24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
unhexlify('24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
words_nfc
|
||||
)
|
||||
|
||||
self.assertTrue(res_nfkd)
|
||||
self.assertTrue(res_nfc)
|
||||
assert res_nfkd is True
|
||||
assert res_nfc is True
|
||||
|
@ -16,34 +16,32 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
from .common import *
|
||||
import base64
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgVerifymessageSegwitNative(common.TrezorTest):
|
||||
class TestMsgVerifymessageSegwitNative(TrezorTest):
|
||||
|
||||
def test_message_long(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j',
|
||||
binascii.unhexlify('285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'),
|
||||
unhexlify('285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed'),
|
||||
"VeryLongMessage!" * 64
|
||||
)
|
||||
self.assertTrue(ret)
|
||||
assert ret is True
|
||||
|
||||
def test_message_testnet(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
ret = self.client.verify_message(
|
||||
'Testnet',
|
||||
'tb1qyjjkmdpu7metqt5r36jf872a34syws336p3n3p',
|
||||
binascii.unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(ret)
|
||||
assert ret is True
|
||||
|
||||
def test_message_verify(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -52,28 +50,28 @@ class TestMsgVerifymessageSegwitNative(common.TrezorTest):
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j',
|
||||
binascii.unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertTrue(res)
|
||||
assert res is True
|
||||
|
||||
# trezor pubkey - FAIL - wrong sig
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j',
|
||||
binascii.unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be00'),
|
||||
unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be00'),
|
||||
'This is an example of a signed message.'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
# trezor pubkey - FAIL - wrong msg
|
||||
res = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j',
|
||||
binascii.unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message!'
|
||||
)
|
||||
self.assertFalse(res)
|
||||
assert res is False
|
||||
|
||||
def test_verify_utf(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -84,16 +82,16 @@ class TestMsgVerifymessageSegwitNative(common.TrezorTest):
|
||||
res_nfkd = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j',
|
||||
binascii.unhexlify('28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
unhexlify('28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
words_nfkd
|
||||
)
|
||||
|
||||
res_nfc = self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j',
|
||||
binascii.unhexlify('28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
unhexlify('28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6'),
|
||||
words_nfc
|
||||
)
|
||||
|
||||
self.assertTrue(res_nfkd)
|
||||
self.assertTrue(res_nfc)
|
||||
assert res_nfkd is True
|
||||
assert res_nfc is True
|
||||
|
@ -16,26 +16,26 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
class TestMsgWipedevice(common.TrezorTest):
|
||||
class TestMsgWipedevice(TrezorTest):
|
||||
|
||||
def test_wipe_device(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
|
||||
self.assertEqual(features.initialized, True)
|
||||
self.assertEqual(features.pin_protection, True)
|
||||
self.assertEqual(features.passphrase_protection, True)
|
||||
assert features.initialized is True
|
||||
assert features.pin_protection is True
|
||||
assert features.passphrase_protection is True
|
||||
device_id = features.device_id
|
||||
|
||||
self.client.wipe_device()
|
||||
features = self.client.call_raw(proto.Initialize())
|
||||
|
||||
self.assertEqual(features.initialized, False)
|
||||
self.assertEqual(features.pin_protection, False)
|
||||
self.assertEqual(features.passphrase_protection, False)
|
||||
self.assertNotEqual(features.device_id, device_id)
|
||||
assert features.initialized is False
|
||||
assert features.pin_protection is False
|
||||
assert features.passphrase_protection is False
|
||||
assert features.device_id != device_id
|
||||
|
@ -18,15 +18,13 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
import trezorlib.ckd_public as bip32
|
||||
from trezorlib.client import CallException
|
||||
|
||||
|
||||
TXHASH_c6091a = binascii.unhexlify('c6091adf4c0c23982a35899a6e58ae11e703eacd7954f588ed4b9cdefc4dba52')
|
||||
TXHASH_c6091a = unhexlify('c6091adf4c0c23982a35899a6e58ae11e703eacd7954f588ed4b9cdefc4dba52')
|
||||
|
||||
|
||||
# Multisig howto:
|
||||
@ -36,7 +34,7 @@ TXHASH_c6091a = binascii.unhexlify('c6091adf4c0c23982a35899a6e58ae11e703eacd7954
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMultisig(common.TrezorTest):
|
||||
class TestMultisig(TrezorTest):
|
||||
|
||||
def test_2_of_3(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -108,7 +106,7 @@ class TestMultisig(common.TrezorTest):
|
||||
# Now we have first signature
|
||||
(signatures1, _) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(signatures1[0]), b'3045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee058')
|
||||
assert hexlify(signatures1[0]) == b'3045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee058'
|
||||
|
||||
# ---------------------------------------
|
||||
# Let's do second signature using 3rd key
|
||||
@ -149,10 +147,10 @@ class TestMultisig(common.TrezorTest):
|
||||
])
|
||||
(signatures2, serialized_tx) = self.client.sign_tx('Bitcoin', [inp3, ], [out1, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(signatures2[0]), b'3045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d')
|
||||
assert hexlify(signatures2[0]) == b'3045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d'
|
||||
|
||||
# Accepted by network: tx 8382a2b2e3ec8788800c1d46d285dfa9dd4051edddd75982fad166b9273e5ac6
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000152ba4dfcde9c4bed88f55479cdea03e711ae586e9a89352a98230c4cdf1a09c601000000fdfe0000483045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee05801483045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d014c6952210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a790253aeffffffff01a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'010000000152ba4dfcde9c4bed88f55479cdea03e711ae586e9a89352a98230c4cdf1a09c601000000fdfe0000483045022100985cc1ba316d140eb4b2d4028d8cd1c451f87bff8ff679858732e516ad04cd3402207af6edda99972af0baa7702a3b7448517c8242e7bca669f6861771cdd16ee05801483045022100f5428fe0531b3095675b40d87cab607ee036fac823b22e8dcec35b65aff6e52b022032129b4577ff923d321a1c70db5a6cec5bcc142cb2c51901af8b989cced23e0d014c6952210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a790253aeffffffff01a0860100000000001976a91412e8391ad256dcdc023365978418d658dfecba1c88ac00000000'
|
||||
|
||||
def test_15_of_15(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -160,7 +158,7 @@ class TestMultisig(common.TrezorTest):
|
||||
"""
|
||||
pubs = []
|
||||
for x in range(15):
|
||||
pubs.append(binascii.hexlify(self.client.get_public_node([x]).node.public_key))
|
||||
pubs.append(hexlify(self.client.get_public_node([x]).node.public_key))
|
||||
"""
|
||||
|
||||
# xpub:
|
||||
@ -195,7 +193,7 @@ class TestMultisig(common.TrezorTest):
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=[x],
|
||||
prev_hash=binascii.unhexlify('6189e3febb5a21cee8b725aa1ef04ffce7e609448446d3a8d6f483c634ef5315'),
|
||||
prev_hash=unhexlify('6189e3febb5a21cee8b725aa1ef04ffce7e609448446d3a8d6f483c634ef5315'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig,
|
||||
@ -206,7 +204,7 @@ class TestMultisig(common.TrezorTest):
|
||||
signatures[x] = sig[0]
|
||||
|
||||
# Accepted as tx id dd320786d1f58c095be0509dc56b277b6de8f2fb5517f519c6e6708414e3300b
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000011553ef34c683f4d6a8d346844409e6e7fc4ff01eaa25b7e8ce215abbfee3896101000000fd43060048304502210098e23085ad7282de988bf98afa1e9add9c9830009132f8902a9fa4624d5dc98b0220733216e70ab67791aa64be5c83d2050cb4ed9ff7eda2a1acc35da024d2ab2a670147304402201f8c11fb6e90fd616e484986e9451929797eba039882a9abcc203210948060b9022044da031530de7d9747d3c5a8e7cec04b04b7af495c9120b854ce7362af7fa05a01483045022100ea67c70186acef019bdf1551881bf38e6f88186501b64d3a756a2ce18e4ba18002201c35110325653e21e448b60053a4b5dda46b61096faf701a1faca61fcde91f00014730440220315598992f156d2f9d7b4275395fa067aa61ea95829fa17730885c86df4de70d02203eda9ade1656e2198c668603b17e197acb0969ed183ab0841303ea261205618901473044022060fdd6621edde9b8cf6776bc4eef26ace9b57514d725b7214ba11d333520a30e022044c30744f94484aec0f896233c5613a3256878ec0379f566226906b6d1b6061401483045022100b1d907e3574f60f7834c7e9f2e367998ce0461dad7d742d84ef8917d713f41f902203b3ac54f7bb2f7fb8685f582d2a94f7213a37cb508acffe29090cc06ae01588b01483045022100e3bf90ff3ad6395e42f46002f253f94ca0e8ffaa0620f2ceb4fa21493abdca4d02201d4c28b10b740bb2dc4b3695b4205c18f8c0dad2bb69540eb8a36576463cd5280147304402202cfaf9fab7dc1c9f0c3c23bd46bd6d5cea0664d914139fc9add80766ce998808022012db2802c07853e4cbe147afdf0b47e60bdcbcd31f9df19e04c177ed9aa66c6d0147304402207cbc2d83f351eee5ee91df26bb0c7e1cb07fe328cbbcdb0bb9656d37922c497302201b3435d4c71ffd1b34d45892f2a487bd79c8c7f57cc04373287642bb9610cb840147304402202dc3eab30ccb06553703e794212f43ee9a659f5e787a8374e9ea0bf6de0def7402201a70e970c21a807783313ed102bf4f0a3406ac7c84f94bc8194c5e209464d7230147304402206b04530c190c46a879d7771a6ad53acd33547e0d7fd320d5ad0b5b1fdeb5d4c202207b812be81c3419daadc942cca0c55aa32c7759fa7566c6dc35f030ca87a1c5be01483045022100ce523dddd6eef73d5ae7c44c870466e1ac5a7a77d43475e8def024af68977a1e022028be0276435bfa2ea887d6cf89fa829f96c1c7a55edc57bb3fd667d523fd3bf601473044022019410b20ebcd8eb3ee7ec1eff6bf0f9cbfaea82116811c61f3cf24af7e4434b1022009e5823f3349f695be09ae40754185300d8442a22715ddb5ffa17c4213140e7201483045022100964ef26a9074c3cdafffcfbe4bd445933f8c842ba11fd887922adcf7fabe0c82022023055d94c75ab223c767fbaa825c917e9beecbc7d5758cccf20d886c63d4b72a0147304402207aa3a98197697d258a8baae681f0b4c0ee682982f4205534e6c95a37dabaddd60220517a7ed5c03da2f242e17ccfdae0d81d6f454d7f9ea931fc62df6c0eab922186014d01025f21023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43d210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a79022103fe91eca10602d7dad4c9dab2b2a0858f71e25a219a6940749ce7a48118480dae210234716c01c2dd03fa7ee302705e2b8fbd1311895d94b1dca15e62eedea9b0968f210341fb2ead334952cf60f4481ba435c4693d0be649be01d2cfe9b02018e483e7bd2102dad8b2bce360a705c16e74a50a36459b4f8f4b78f9cd67def29d54ef6f7c7cf9210222dbe3f5f197a34a1d50e2cbe2a1085cac2d605c9e176f9a240e0fd0c669330d2103fb41afab56c9cdb013fda63d777d4938ddc3cb2ad939712da688e3ed333f95982102435f177646bdc717cb3211bf46656ca7e8d642726144778c9ce816b8b8c36ccf2102158d8e20095364031d923c7e9f7f08a14b1be1ddee21fe1a5431168e31345e5521026259794892428ca0818c8fb61d2d459ddfe20e57f50803c7295e6f4e2f5586652102815f910a8689151db627e6e262e0a2075ad5ec2993a6bc1b876a9d420923d681210318f54647f645ff01bd49fedc0219343a6a22d3ea3180a3c3d3097e4b888a8db45faeffffffff0110270000000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000')
|
||||
assert hexlify(serialized_tx) == b'01000000011553ef34c683f4d6a8d346844409e6e7fc4ff01eaa25b7e8ce215abbfee3896101000000fd43060048304502210098e23085ad7282de988bf98afa1e9add9c9830009132f8902a9fa4624d5dc98b0220733216e70ab67791aa64be5c83d2050cb4ed9ff7eda2a1acc35da024d2ab2a670147304402201f8c11fb6e90fd616e484986e9451929797eba039882a9abcc203210948060b9022044da031530de7d9747d3c5a8e7cec04b04b7af495c9120b854ce7362af7fa05a01483045022100ea67c70186acef019bdf1551881bf38e6f88186501b64d3a756a2ce18e4ba18002201c35110325653e21e448b60053a4b5dda46b61096faf701a1faca61fcde91f00014730440220315598992f156d2f9d7b4275395fa067aa61ea95829fa17730885c86df4de70d02203eda9ade1656e2198c668603b17e197acb0969ed183ab0841303ea261205618901473044022060fdd6621edde9b8cf6776bc4eef26ace9b57514d725b7214ba11d333520a30e022044c30744f94484aec0f896233c5613a3256878ec0379f566226906b6d1b6061401483045022100b1d907e3574f60f7834c7e9f2e367998ce0461dad7d742d84ef8917d713f41f902203b3ac54f7bb2f7fb8685f582d2a94f7213a37cb508acffe29090cc06ae01588b01483045022100e3bf90ff3ad6395e42f46002f253f94ca0e8ffaa0620f2ceb4fa21493abdca4d02201d4c28b10b740bb2dc4b3695b4205c18f8c0dad2bb69540eb8a36576463cd5280147304402202cfaf9fab7dc1c9f0c3c23bd46bd6d5cea0664d914139fc9add80766ce998808022012db2802c07853e4cbe147afdf0b47e60bdcbcd31f9df19e04c177ed9aa66c6d0147304402207cbc2d83f351eee5ee91df26bb0c7e1cb07fe328cbbcdb0bb9656d37922c497302201b3435d4c71ffd1b34d45892f2a487bd79c8c7f57cc04373287642bb9610cb840147304402202dc3eab30ccb06553703e794212f43ee9a659f5e787a8374e9ea0bf6de0def7402201a70e970c21a807783313ed102bf4f0a3406ac7c84f94bc8194c5e209464d7230147304402206b04530c190c46a879d7771a6ad53acd33547e0d7fd320d5ad0b5b1fdeb5d4c202207b812be81c3419daadc942cca0c55aa32c7759fa7566c6dc35f030ca87a1c5be01483045022100ce523dddd6eef73d5ae7c44c870466e1ac5a7a77d43475e8def024af68977a1e022028be0276435bfa2ea887d6cf89fa829f96c1c7a55edc57bb3fd667d523fd3bf601473044022019410b20ebcd8eb3ee7ec1eff6bf0f9cbfaea82116811c61f3cf24af7e4434b1022009e5823f3349f695be09ae40754185300d8442a22715ddb5ffa17c4213140e7201483045022100964ef26a9074c3cdafffcfbe4bd445933f8c842ba11fd887922adcf7fabe0c82022023055d94c75ab223c767fbaa825c917e9beecbc7d5758cccf20d886c63d4b72a0147304402207aa3a98197697d258a8baae681f0b4c0ee682982f4205534e6c95a37dabaddd60220517a7ed5c03da2f242e17ccfdae0d81d6f454d7f9ea931fc62df6c0eab922186014d01025f21023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43d210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a621038caebd6f753bbbd2bb1f3346a43cd32140648583673a31d62f2dfb56ad0ab9e32103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a79022103fe91eca10602d7dad4c9dab2b2a0858f71e25a219a6940749ce7a48118480dae210234716c01c2dd03fa7ee302705e2b8fbd1311895d94b1dca15e62eedea9b0968f210341fb2ead334952cf60f4481ba435c4693d0be649be01d2cfe9b02018e483e7bd2102dad8b2bce360a705c16e74a50a36459b4f8f4b78f9cd67def29d54ef6f7c7cf9210222dbe3f5f197a34a1d50e2cbe2a1085cac2d605c9e176f9a240e0fd0c669330d2103fb41afab56c9cdb013fda63d777d4938ddc3cb2ad939712da688e3ed333f95982102435f177646bdc717cb3211bf46656ca7e8d642726144778c9ce816b8b8c36ccf2102158d8e20095364031d923c7e9f7f08a14b1be1ddee21fe1a5431168e31345e5521026259794892428ca0818c8fb61d2d459ddfe20e57f50803c7295e6f4e2f5586652102815f910a8689151db627e6e262e0a2075ad5ec2993a6bc1b876a9d420923d681210318f54647f645ff01bd49fedc0219343a6a22d3ea3180a3c3d3097e4b888a8db45faeffffffff0110270000000000001976a9144a087d89f8ad16ca029c675b037c02fd1c5f9aec88ac00000000'
|
||||
|
||||
def test_missing_pubkey(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -254,4 +252,5 @@ class TestMultisig(common.TrezorTest):
|
||||
|
||||
with self.client:
|
||||
# It should throw Failure 'Pubkey not found in multisig script'
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ])
|
||||
with pytest.raises(CallException):
|
||||
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
@ -16,19 +16,17 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
import trezorlib.ckd_public as bip32
|
||||
from trezorlib import tx_api
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMultisigChange(common.TrezorTest):
|
||||
class TestMultisigChange(TrezorTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMultisigChange, self).setUp()
|
||||
def setup_method(self, method):
|
||||
super(TestMultisigChange, self).setup_method(method)
|
||||
self.client.set_tx_api(tx_api.TxApiTestnet)
|
||||
|
||||
node_ext1 = bip32.deserialize('tpubDADHV9u9Y6gkggintTdMjJE3be58zKNLhpxBQyuEM6Pwx3sN9JVLmMCMN4DNVwL9AKec27z5TaWcWuHzMXiGAtcra5DjwWbvppGX4gaEGVN')
|
||||
@ -98,7 +96,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
# 2N9W4z9AhAPaHghtqVQPbaTAGHdbrhKeBQw
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=[45 | 0x80000000, 0, 0, 0],
|
||||
prev_hash=binascii.unhexlify('16c6c8471b8db7a628f2b2bb86bfeefae1766463ce8692438c7fd3fce3f43ce5'),
|
||||
prev_hash=unhexlify('16c6c8471b8db7a628f2b2bb86bfeefae1766463ce8692438c7fd3fce3f43ce5'),
|
||||
prev_index=1,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig_in1,
|
||||
@ -107,7 +105,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
# 2NDBG6QXQLtnQ3jRGkrqo53BiCeXfQXLdj4
|
||||
inp2 = proto.TxInputType(
|
||||
address_n=[45 | 0x80000000, 0, 0, 1],
|
||||
prev_hash=binascii.unhexlify('d80c34ee14143a8bf61125102b7ef594118a3796cad670fa8ee15080ae155318'),
|
||||
prev_hash=unhexlify('d80c34ee14143a8bf61125102b7ef594118a3796cad670fa8ee15080ae155318'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig_in2,
|
||||
@ -116,7 +114,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
# 2MvwPWfp2XPU3S1cMwgEMKBPUw38VP5SBE4
|
||||
inp3 = proto.TxInputType(
|
||||
address_n=[45 | 0x80000000, 0, 0, 1],
|
||||
prev_hash=binascii.unhexlify('b0946dc27ba308a749b11afecc2018980af18f79e89ad6b080b58220d856f739'),
|
||||
prev_hash=unhexlify('b0946dc27ba308a749b11afecc2018980af18f79e89ad6b080b58220d856f739'),
|
||||
prev_index=0,
|
||||
script_type=proto.InputScriptType.SPENDMULTISIG,
|
||||
multisig=multisig_in3,
|
||||
@ -183,7 +181,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022064f13801744a6c21b694f62cdb5d834e852f13ecf85ed4d0a56ba279571c24e3022010fab4cb05bdd7b24c8376dda4f62a418548eea6eb483e58675fa06e0d5c642c014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b4004730440220727b2522268f913acd213c507d7801b146e5b6cef666ad44b769c26d6c762e4d022021c0c2e9e8298dee2a490d956f7ab1b2d3160c1e37a50cc6d19a5e62eb484fc9014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a6202000000001976a9149b139230e4fe91c05a37ec334dc8378f3dbe377088ac00639f02000000001976a914b0d05a10926a7925508febdbab9a5bd4cda8c8f688ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022064f13801744a6c21b694f62cdb5d834e852f13ecf85ed4d0a56ba279571c24e3022010fab4cb05bdd7b24c8376dda4f62a418548eea6eb483e58675fa06e0d5c642c014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b4004730440220727b2522268f913acd213c507d7801b146e5b6cef666ad44b769c26d6c762e4d022021c0c2e9e8298dee2a490d956f7ab1b2d3160c1e37a50cc6d19a5e62eb484fc9014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a6202000000001976a9149b139230e4fe91c05a37ec334dc8378f3dbe377088ac00639f02000000001976a914b0d05a10926a7925508febdbab9a5bd4cda8c8f688ac00000000'
|
||||
|
||||
# first external, second internal
|
||||
def test_external_internal(self):
|
||||
@ -205,7 +203,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022064f13801744a6c21b694f62cdb5d834e852f13ecf85ed4d0a56ba279571c24e3022010fab4cb05bdd7b24c8376dda4f62a418548eea6eb483e58675fa06e0d5c642c014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b4004730440220727b2522268f913acd213c507d7801b146e5b6cef666ad44b769c26d6c762e4d022021c0c2e9e8298dee2a490d956f7ab1b2d3160c1e37a50cc6d19a5e62eb484fc9014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a6202000000001976a9149b139230e4fe91c05a37ec334dc8378f3dbe377088ac00639f02000000001976a914b0d05a10926a7925508febdbab9a5bd4cda8c8f688ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022064f13801744a6c21b694f62cdb5d834e852f13ecf85ed4d0a56ba279571c24e3022010fab4cb05bdd7b24c8376dda4f62a418548eea6eb483e58675fa06e0d5c642c014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b4004730440220727b2522268f913acd213c507d7801b146e5b6cef666ad44b769c26d6c762e4d022021c0c2e9e8298dee2a490d956f7ab1b2d3160c1e37a50cc6d19a5e62eb484fc9014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a6202000000001976a9149b139230e4fe91c05a37ec334dc8378f3dbe377088ac00639f02000000001976a914b0d05a10926a7925508febdbab9a5bd4cda8c8f688ac00000000'
|
||||
|
||||
# first internal, second external
|
||||
def test_internal_external(self):
|
||||
@ -227,7 +225,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=1))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022064f13801744a6c21b694f62cdb5d834e852f13ecf85ed4d0a56ba279571c24e3022010fab4cb05bdd7b24c8376dda4f62a418548eea6eb483e58675fa06e0d5c642c014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b4004730440220727b2522268f913acd213c507d7801b146e5b6cef666ad44b769c26d6c762e4d022021c0c2e9e8298dee2a490d956f7ab1b2d3160c1e37a50cc6d19a5e62eb484fc9014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a6202000000001976a9149b139230e4fe91c05a37ec334dc8378f3dbe377088ac00639f02000000001976a914b0d05a10926a7925508febdbab9a5bd4cda8c8f688ac00000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022064f13801744a6c21b694f62cdb5d834e852f13ecf85ed4d0a56ba279571c24e3022010fab4cb05bdd7b24c8376dda4f62a418548eea6eb483e58675fa06e0d5c642c014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b4004730440220727b2522268f913acd213c507d7801b146e5b6cef666ad44b769c26d6c762e4d022021c0c2e9e8298dee2a490d956f7ab1b2d3160c1e37a50cc6d19a5e62eb484fc9014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a6202000000001976a9149b139230e4fe91c05a37ec334dc8378f3dbe377088ac00639f02000000001976a914b0d05a10926a7925508febdbab9a5bd4cda8c8f688ac00000000'
|
||||
|
||||
# both outputs are external
|
||||
def test_multisig_external_external(self):
|
||||
@ -249,7 +247,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022059394e0dfcb2d2f4a6108703f801545ca5a820c0ac6a1859d0a3854813de55fa02207b6a57d70b82932ff58163336c461653a2dc82c78ed8157159e5178ac7325390014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b40047304402205a911685f5b974b2fc4a19d5ce056218773a4d20b5eaae2c2f9594929308182002201e03449f5a8813ec19f408bf1b6f4f334886d6fcf9920e300fd7678ef0724f81014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022059394e0dfcb2d2f4a6108703f801545ca5a820c0ac6a1859d0a3854813de55fa02207b6a57d70b82932ff58163336c461653a2dc82c78ed8157159e5178ac7325390014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b40047304402205a911685f5b974b2fc4a19d5ce056218773a4d20b5eaae2c2f9594929308182002201e03449f5a8813ec19f408bf1b6f4f334886d6fcf9920e300fd7678ef0724f81014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000'
|
||||
|
||||
# inputs match, change matches (first is change)
|
||||
def test_multisig_change_match_first(self):
|
||||
@ -282,7 +280,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=1))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022059394e0dfcb2d2f4a6108703f801545ca5a820c0ac6a1859d0a3854813de55fa02207b6a57d70b82932ff58163336c461653a2dc82c78ed8157159e5178ac7325390014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b40047304402205a911685f5b974b2fc4a19d5ce056218773a4d20b5eaae2c2f9594929308182002201e03449f5a8813ec19f408bf1b6f4f334886d6fcf9920e300fd7678ef0724f81014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022059394e0dfcb2d2f4a6108703f801545ca5a820c0ac6a1859d0a3854813de55fa02207b6a57d70b82932ff58163336c461653a2dc82c78ed8157159e5178ac7325390014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b40047304402205a911685f5b974b2fc4a19d5ce056218773a4d20b5eaae2c2f9594929308182002201e03449f5a8813ec19f408bf1b6f4f334886d6fcf9920e300fd7678ef0724f81014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000'
|
||||
|
||||
# inputs match, change matches (second is change)
|
||||
def test_multisig_change_match_second(self):
|
||||
@ -315,7 +313,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2, change=2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022059394e0dfcb2d2f4a6108703f801545ca5a820c0ac6a1859d0a3854813de55fa02207b6a57d70b82932ff58163336c461653a2dc82c78ed8157159e5178ac7325390014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b40047304402205a911685f5b974b2fc4a19d5ce056218773a4d20b5eaae2c2f9594929308182002201e03449f5a8813ec19f408bf1b6f4f334886d6fcf9920e300fd7678ef0724f81014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b400473044022059394e0dfcb2d2f4a6108703f801545ca5a820c0ac6a1859d0a3854813de55fa02207b6a57d70b82932ff58163336c461653a2dc82c78ed8157159e5178ac7325390014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b40047304402205a911685f5b974b2fc4a19d5ce056218773a4d20b5eaae2c2f9594929308182002201e03449f5a8813ec19f408bf1b6f4f334886d6fcf9920e300fd7678ef0724f81014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000'
|
||||
|
||||
# inputs match, change mismatches (second is change)
|
||||
def test_multisig_mismatch_change(self):
|
||||
@ -348,7 +346,7 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp2))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp2, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b40047304402207f9992cc0230527faf54ec6bd233307db82bc8fac039dcee418bc6feb4e96a3a02206bb4cb157ad27c123277328a877572563a45d70b844d9ab07cc42238112f8c2a014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b400473044022078a41bfa87d72d6ba810d84bf568b5a29acf8b851ba6c3a8dbff079b34a7feb0022037b770c776db0b6c883c38a684a121b90a59ed1958774cbf64de70e53e29639f014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914e6a3e2fbadb7f559f8d20c46aceae78c96fcf1d18700000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b40047304402207f9992cc0230527faf54ec6bd233307db82bc8fac039dcee418bc6feb4e96a3a02206bb4cb157ad27c123277328a877572563a45d70b844d9ab07cc42238112f8c2a014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff185315ae8050e18efa70d6ca96378a1194f57e2b102511f68b3a1414ee340cd800000000b400473044022078a41bfa87d72d6ba810d84bf568b5a29acf8b851ba6c3a8dbff079b34a7feb0022037b770c776db0b6c883c38a684a121b90a59ed1958774cbf64de70e53e29639f014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103ed1fd93989595d7ad4b488efd05a22c0239482c9a20923f2f214a38e54f6c41a2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948700639f020000000017a914e6a3e2fbadb7f559f8d20c46aceae78c96fcf1d18700000000'
|
||||
|
||||
# inputs mismatch, change matches with first input
|
||||
def test_multisig_mismatch_inputs(self):
|
||||
@ -381,4 +379,4 @@ class TestMultisigChange(common.TrezorTest):
|
||||
self.client.set_expected_responses(self._responses(self.inp1, self.inp3))
|
||||
(_, serialized_tx) = self.client.sign_tx('Testnet', [self.inp1, self.inp3, ], [out1, out2, ])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b500483045022100d907b9339951c96ef4515ef7aff8b3c28c4c8c5875d7421aa1de9f3a94e3508302205cdc311a6c91dfbb74f1a9a940a994a65dbfb0cf6dedcaaaeee839e0b8fd016d014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff39f756d82082b580b0d69ae8798ff10a981820ccfe1ab149a708a37bc26d94b000000000b500483045022100fdad4a47d15f47cc364fe0cbed11b1ced1f9ef210bc1bd413ec4384f630c63720220752e4f09ea4e5e6623f5ebe89b3983ec6e5702f63f9bce696f10b2d594d23532014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103b6321a1194e5cc47b6b7edc3f67a096e6f71ccb72440f84f390b6e98df0ea8ec2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948740d2df030000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000')
|
||||
assert hexlify(serialized_tx) == b'0100000002e53cf4e3fcd37f8c439286ce636476e1faeebf86bbb2f228a6b78d1b47c8c61601000000b500483045022100d907b9339951c96ef4515ef7aff8b3c28c4c8c5875d7421aa1de9f3a94e3508302205cdc311a6c91dfbb74f1a9a940a994a65dbfb0cf6dedcaaaeee839e0b8fd016d014c69522103dc07026aacb5918dac4e09f9da8290d0ae22161699636c22cace78082116a7792103e70db185fad69c2971f0107a42930e5d82a9ed3a11b922a96fdfc4124b63e54c2103f3fe007a1e34ac76c1a2528e9149f90f9f93739929797afab6a8e18d682fa71053aeffffffff39f756d82082b580b0d69ae8798ff10a981820ccfe1ab149a708a37bc26d94b000000000b500483045022100fdad4a47d15f47cc364fe0cbed11b1ced1f9ef210bc1bd413ec4384f630c63720220752e4f09ea4e5e6623f5ebe89b3983ec6e5702f63f9bce696f10b2d594d23532014c6952210297ad8a5df42f9e362ef37d9a4ddced89d8f7a143690649aa0d0ff049c7daca842103b6321a1194e5cc47b6b7edc3f67a096e6f71ccb72440f84f390b6e98df0ea8ec2103f91460d79e4e463d7d90cb75254bcd62b515a99a950574c721efdc5f711dff3553aeffffffff02005a62020000000017a91466528dd543f94d162c8111d2ec248d25ba9b90948740d2df030000000017a914f1fc92c0aed1712911c70a2e09ac15ff0922652f8700000000'
|
||||
|
@ -16,17 +16,16 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import binascii
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.client import CallException
|
||||
|
||||
|
||||
TXHASH_d5f65e = binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
TXHASH_d5f65e = unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
|
||||
|
||||
class TestOpReturn(common.TrezorTest):
|
||||
class TestOpReturn(TrezorTest):
|
||||
|
||||
def test_opreturn(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -74,7 +73,7 @@ class TestOpReturn(common.TrezorTest):
|
||||
])
|
||||
(signatures, serialized_tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, out2])
|
||||
|
||||
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a4730440220187b7b9c340a32fc8445418ad11fb3827d2e8bac7d730e1c9ad800353e7ba62f02206c0c5820ba8882c82923a39aee8d36d6d32e13daed73f7a3d6199de5f8e7ddfd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0260cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000000000001c6a1a74657374206f6620746865206f705f72657475726e206461746100000000')
|
||||
assert hexlify(serialized_tx) == b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a4730440220187b7b9c340a32fc8445418ad11fb3827d2e8bac7d730e1c9ad800353e7ba62f02206c0c5820ba8882c82923a39aee8d36d6d32e13daed73f7a3d6199de5f8e7ddfd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0260cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000000000001c6a1a74657374206f6620746865206f705f72657475726e206461746100000000'
|
||||
|
||||
def test_nonzero_opreturn(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -111,4 +110,5 @@ class TestOpReturn(common.TrezorTest):
|
||||
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
|
||||
proto.Failure()
|
||||
])
|
||||
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ])
|
||||
with pytest.raises(CallException):
|
||||
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
|
@ -19,8 +19,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import time
|
||||
from . import common
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.client import PinException, CallException
|
||||
|
||||
@ -28,7 +27,7 @@ from trezorlib.client import PinException, CallException
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestProtectCall(common.TrezorTest):
|
||||
class TestProtectCall(TrezorTest):
|
||||
|
||||
def _some_protected_call(self, button, pin, passphrase):
|
||||
# This method perform any call which have protection in the device
|
||||
@ -38,7 +37,7 @@ class TestProtectCall(common.TrezorTest):
|
||||
pin_protection=pin,
|
||||
passphrase_protection=passphrase
|
||||
)
|
||||
self.assertEqual(res, 'random data')
|
||||
assert res == 'random data'
|
||||
|
||||
"""
|
||||
def test_expected_responses(self):
|
||||
@ -50,12 +49,14 @@ class TestProtectCall(common.TrezorTest):
|
||||
with self.client:
|
||||
# Scenario 1 - Received unexpected message
|
||||
self.client.set_expected_responses([])
|
||||
self.assertRaises(CallException, self._some_protected_call, True, True, True)
|
||||
with pytest.raises(CallException):
|
||||
self._some_protected_call(True, True, True)
|
||||
|
||||
with self.client:
|
||||
# Scenario 2 - Received other than expected message
|
||||
self.client.set_expected_responses([proto.Success()])
|
||||
self.assertRaises(CallException, self._some_protected_call, True, True, True)
|
||||
with pytest.raises(CallException):
|
||||
self._some_protected_call(True, True, True)
|
||||
|
||||
def scenario3():
|
||||
with self.client:
|
||||
@ -64,7 +65,8 @@ class TestProtectCall(common.TrezorTest):
|
||||
proto.Success(),
|
||||
proto.Success()]) # This is expected, but not received
|
||||
self._some_protected_call(True, False, False)
|
||||
self.assertRaises(Exception, scenario3)
|
||||
with pytest.raises(Exception):
|
||||
scenario3()
|
||||
|
||||
with self.client:
|
||||
# Scenario 4 - Received what expected
|
||||
@ -80,14 +82,15 @@ class TestProtectCall(common.TrezorTest):
|
||||
self.client.set_expected_responses([proto.ButtonRequest(),
|
||||
proto.Success(message='wrong data')])
|
||||
self._some_protected_call(True, True, True)
|
||||
self.assertRaises(CallException, scenario5)
|
||||
with pytest.raises(CallException):
|
||||
scenario5()
|
||||
"""
|
||||
|
||||
def test_no_protection(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
with self.client:
|
||||
self.assertEqual(self.client.debug.read_pin()[0], None)
|
||||
assert self.client.debug.read_pin()[0] is None
|
||||
self.client.set_expected_responses([proto.Success()])
|
||||
self._some_protected_call(False, True, True)
|
||||
|
||||
@ -95,7 +98,7 @@ class TestProtectCall(common.TrezorTest):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
|
||||
with self.client:
|
||||
self.assertEqual(self.client.debug.read_pin()[0], self.pin4)
|
||||
assert self.client.debug.read_pin()[0] == self.pin4
|
||||
self.client.setup_debuglink(button=True, pin_correct=True)
|
||||
self.client.set_expected_responses([proto.ButtonRequest(),
|
||||
proto.PinMatrixRequest(),
|
||||
@ -105,12 +108,14 @@ class TestProtectCall(common.TrezorTest):
|
||||
def test_incorrect_pin(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
self.client.setup_debuglink(button=True, pin_correct=False)
|
||||
self.assertRaises(PinException, self._some_protected_call, False, True, False)
|
||||
with pytest.raises(PinException):
|
||||
self._some_protected_call(False, True, False)
|
||||
|
||||
def test_cancelled_pin(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
self.client.setup_debuglink(button=True, pin_correct=False) # PIN cancel
|
||||
self.assertRaises(PinException, self._some_protected_call, False, True, False)
|
||||
with pytest.raises(PinException):
|
||||
self._some_protected_call(False, True, False)
|
||||
|
||||
def test_exponential_backoff_with_reboot(self):
|
||||
self.setup_mnemonic_pin_passphrase()
|
||||
@ -126,9 +131,10 @@ class TestProtectCall(common.TrezorTest):
|
||||
|
||||
msg = "Pin delay expected to be at least %s seconds, got %s" % (expected, got)
|
||||
print(msg)
|
||||
self.assertLessEqual(expected, got, msg)
|
||||
assert got >= expected
|
||||
|
||||
for attempt in range(1, 6):
|
||||
start = time.time()
|
||||
self.assertRaises(PinException, self._some_protected_call, False, True, False)
|
||||
with pytest.raises(PinException):
|
||||
self._some_protected_call(False, True, False)
|
||||
test_backoff(attempt, start)
|
||||
|
@ -16,17 +16,15 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import common
|
||||
import binascii
|
||||
import pytest
|
||||
from .common import *
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
TXHASH_d5f65e = binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
TXHASH_d5f65e = unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestProtectionLevels(common.TrezorTest):
|
||||
class TestProtectionLevels(TrezorTest):
|
||||
|
||||
def test_initialize(self):
|
||||
with self.client:
|
||||
@ -116,8 +114,8 @@ class TestProtectionLevels(common.TrezorTest):
|
||||
self.client.load_device_by_mnemonic('this is mnemonic', '1234', True, 'label', 'english', skip_checksum=True)
|
||||
|
||||
# This must fail, because device is already initialized
|
||||
self.assertRaises(Exception, self.client.load_device_by_mnemonic,
|
||||
'this is mnemonic', '1234', True, 'label', 'english', skip_checksum=True)
|
||||
with pytest.raises(Exception):
|
||||
self.client.load_device_by_mnemonic('this is mnemonic', '1234', True, 'label', 'english', skip_checksum=True)
|
||||
|
||||
def test_reset_device(self):
|
||||
with self.client:
|
||||
@ -125,7 +123,8 @@ class TestProtectionLevels(common.TrezorTest):
|
||||
self.client.reset_device(False, 128, True, False, 'label', 'english')
|
||||
|
||||
# This must fail, because device is already initialized
|
||||
self.assertRaises(Exception, self.client.reset_device, False, 128, True, False, 'label', 'english')
|
||||
with pytest.raises(Exception):
|
||||
self.client.reset_device(False, 128, True, False, 'label', 'english')
|
||||
|
||||
def test_recovery_device(self):
|
||||
with self.client:
|
||||
@ -134,7 +133,8 @@ class TestProtectionLevels(common.TrezorTest):
|
||||
self.client.recovery_device(12, False, False, 'label', 'english')
|
||||
|
||||
# This must fail, because device is already initialized
|
||||
self.assertRaises(Exception, self.client.recovery_device, 12, False, False, 'label', 'english')
|
||||
with pytest.raises(Exception):
|
||||
self.client.recovery_device(12, False, False, 'label', 'english')
|
||||
|
||||
def test_sign_message(self):
|
||||
with self.client:
|
||||
@ -154,7 +154,7 @@ class TestProtectionLevels(common.TrezorTest):
|
||||
self.client.verify_message(
|
||||
'Bitcoin',
|
||||
'14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e',
|
||||
binascii.unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
unhexlify('209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80'),
|
||||
'This is an example of a signed message.')
|
||||
|
||||
def test_signtx(self):
|
||||
|
@ -18,19 +18,18 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import binascii
|
||||
import sys
|
||||
from . import common
|
||||
from .common import *
|
||||
|
||||
from trezorlib import messages as proto
|
||||
|
||||
|
||||
TXHASH_d5f65e = binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
TXHASH_d5f65e = unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882')
|
||||
|
||||
|
||||
# address_n = [177] < 68
|
||||
# address_n = [16518] < 66
|
||||
class TestZerosig(common.TrezorTest):
|
||||
class TestZerosig(TrezorTest):
|
||||
|
||||
'''
|
||||
def test_mine_zero_signature(self):
|
||||
@ -59,7 +58,7 @@ class TestZerosig(common.TrezorTest):
|
||||
print(siglen)
|
||||
if siglen < 67:
|
||||
print("!!!!", n)
|
||||
print(binascii.hexlify(tx.serialized_tx))
|
||||
print(hexlify(tx.serialized_tx))
|
||||
return
|
||||
'''
|
||||
|
||||
@ -84,7 +83,7 @@ class TestZerosig(common.TrezorTest):
|
||||
siglen = serialized_tx[44]
|
||||
|
||||
# TREZOR must strip leading zero from signature
|
||||
self.assertEqual(siglen, 67)
|
||||
assert siglen == 67
|
||||
|
||||
def test_two_zero_signature(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
@ -107,4 +106,4 @@ class TestZerosig(common.TrezorTest):
|
||||
siglen = serialized_tx[44]
|
||||
|
||||
# TREZOR must strip leading zero from signature
|
||||
self.assertEqual(siglen, 66)
|
||||
assert siglen == 66
|
||||
|
Loading…
Reference in New Issue
Block a user