mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-07 14:00:57 +00:00
fix bitcoin tests
This commit is contained in:
parent
9e6a9c35b7
commit
e22a141788
@ -129,6 +129,18 @@ class TrezorClient:
|
|||||||
return SessionV2.new(self, passphrase, derive_cardano)
|
return SessionV2.new(self, passphrase, derive_cardano)
|
||||||
raise NotImplementedError # TODO
|
raise NotImplementedError # TODO
|
||||||
|
|
||||||
|
def resume_session(self, session: Session):
|
||||||
|
from trezorlib.transport.session import SessionV1, SessionV2
|
||||||
|
|
||||||
|
if isinstance(session, SessionV2):
|
||||||
|
return session
|
||||||
|
elif isinstance(session, SessionV1):
|
||||||
|
session.init_session()
|
||||||
|
return session
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_management_session(self, new_session: bool = False) -> Session:
|
def get_management_session(self, new_session: bool = False) -> Session:
|
||||||
from .transport.session import SessionV1, SessionV2
|
from .transport.session import SessionV1, SessionV2
|
||||||
|
|
||||||
@ -178,9 +190,6 @@ class TrezorClient:
|
|||||||
# TODO implement
|
# TODO implement
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def resume_session(self, session_id: bytes) -> Session:
|
|
||||||
raise NotImplementedError # TODO
|
|
||||||
|
|
||||||
def _get_protocol(self) -> ProtocolAndChannel:
|
def _get_protocol(self) -> ProtocolAndChannel:
|
||||||
self.transport.open()
|
self.transport.open()
|
||||||
|
|
||||||
|
@ -1344,7 +1344,9 @@ class TrezorClientDebugLink(TrezorClient):
|
|||||||
# self.debug.close()
|
# self.debug.close()
|
||||||
|
|
||||||
def get_session(
|
def get_session(
|
||||||
self, passphrase: str | None = None, derive_cardano: bool = False
|
self,
|
||||||
|
passphrase: str | None = None,
|
||||||
|
derive_cardano: bool = False,
|
||||||
) -> Session:
|
) -> Session:
|
||||||
if passphrase is not None:
|
if passphrase is not None:
|
||||||
passphrase = Mnemonic.normalize_string(passphrase)
|
passphrase = Mnemonic.normalize_string(passphrase)
|
||||||
|
@ -111,7 +111,7 @@ class SessionV1(Session):
|
|||||||
session.passphrase_callback = _callback_passphrase
|
session.passphrase_callback = _callback_passphrase
|
||||||
session.passphrase = passphrase
|
session.passphrase = passphrase
|
||||||
session.derive_cardano = derive_cardano
|
session.derive_cardano = derive_cardano
|
||||||
session._init_session()
|
session.init_session()
|
||||||
return session
|
return session
|
||||||
|
|
||||||
def _write(self, msg: t.Any) -> None:
|
def _write(self, msg: t.Any) -> None:
|
||||||
@ -124,7 +124,7 @@ class SessionV1(Session):
|
|||||||
assert isinstance(self.client.protocol, ProtocolV1)
|
assert isinstance(self.client.protocol, ProtocolV1)
|
||||||
return self.client.protocol.read()
|
return self.client.protocol.read()
|
||||||
|
|
||||||
def _init_session(self):
|
def init_session(self):
|
||||||
if self.id == b"":
|
if self.id == b"":
|
||||||
session_id = None
|
session_id = None
|
||||||
else:
|
else:
|
||||||
|
@ -855,7 +855,7 @@ def test_multisession_authorization(client: Client):
|
|||||||
# Switch back to the first session.
|
# Switch back to the first session.
|
||||||
# session_id2 = session.session_id
|
# session_id2 = session.session_id
|
||||||
# TODO client.init_device(session_id=session_id1)
|
# TODO client.init_device(session_id=session_id1)
|
||||||
|
client.resume_session(session1)
|
||||||
# Requesting a preauthorized ownership proof for www.example1.com should succeed in session 1.
|
# Requesting a preauthorized ownership proof for www.example1.com should succeed in session 1.
|
||||||
ownership_proof, _ = btc.get_ownership_proof(
|
ownership_proof, _ = btc.get_ownership_proof(
|
||||||
session1,
|
session1,
|
||||||
@ -901,7 +901,7 @@ def test_multisession_authorization(client: Client):
|
|||||||
|
|
||||||
# Switch to the second session.
|
# Switch to the second session.
|
||||||
# TODO client.init_device(session_id=session_id2)
|
# TODO client.init_device(session_id=session_id2)
|
||||||
|
client.resume_session(session2)
|
||||||
# Requesting a preauthorized ownership proof for www.example2.com should still succeed in session 2.
|
# Requesting a preauthorized ownership proof for www.example2.com should still succeed in session 2.
|
||||||
ownership_proof, _ = btc.get_ownership_proof(
|
ownership_proof, _ = btc.get_ownership_proof(
|
||||||
session2,
|
session2,
|
||||||
|
Loading…
Reference in New Issue
Block a user