mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-15 19:08:07 +00:00
tests: simplify ClearSession test
This commit is contained in:
parent
fd0dc8ed66
commit
a8cfa8fbed
@ -16,65 +16,41 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import messages as proto
|
from trezorlib import messages
|
||||||
from trezorlib.btc import get_public_node
|
from trezorlib.btc import get_public_node
|
||||||
from trezorlib.tools import parse_path
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
|
ADDRESS_N = parse_path("44'/0'/0'")
|
||||||
|
XPUB = "xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip_ui
|
@pytest.mark.skip_ui
|
||||||
@pytest.mark.setup_client(pin=True, passphrase=True)
|
@pytest.mark.setup_client(pin=True, passphrase=True)
|
||||||
def test_clear_session(client):
|
def test_clear_session(client):
|
||||||
if client.features.model == "1":
|
if client.features.model == "1":
|
||||||
init_responses = [
|
init_responses = [messages.PinMatrixRequest(), messages.PassphraseRequest()]
|
||||||
proto.PinMatrixRequest(),
|
|
||||||
proto.PassphraseRequest(),
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
init_responses = [
|
init_responses = [messages.PassphraseRequest()]
|
||||||
proto.PassphraseRequest(),
|
|
||||||
]
|
cached_responses = [messages.PublicKey()]
|
||||||
cached_responses = [
|
|
||||||
proto.ButtonRequest(code=proto.ButtonRequestType.PublicKey),
|
|
||||||
proto.PublicKey(),
|
|
||||||
]
|
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(init_responses + cached_responses)
|
client.set_expected_responses(init_responses + cached_responses)
|
||||||
assert (
|
assert get_public_node(client, ADDRESS_N).xpub == XPUB
|
||||||
get_public_node(
|
|
||||||
client, parse_path("44'/0'/0'"), show_display=True
|
|
||||||
).node.public_key.hex()
|
|
||||||
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
|
|
||||||
)
|
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
# pin and passphrase are cached
|
# pin and passphrase are cached
|
||||||
client.set_expected_responses(cached_responses)
|
client.set_expected_responses(cached_responses)
|
||||||
assert (
|
assert get_public_node(client, ADDRESS_N).xpub == XPUB
|
||||||
get_public_node(
|
|
||||||
client, parse_path("44'/0'/0'"), show_display=True
|
|
||||||
).node.public_key.hex()
|
|
||||||
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
|
|
||||||
)
|
|
||||||
|
|
||||||
client.clear_session()
|
client.clear_session()
|
||||||
|
|
||||||
# session cache is cleared
|
# session cache is cleared
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(init_responses + cached_responses)
|
client.set_expected_responses(init_responses + cached_responses)
|
||||||
assert (
|
assert get_public_node(client, ADDRESS_N).xpub == XPUB
|
||||||
get_public_node(
|
|
||||||
client, parse_path("44'/0'/0'"), show_display=True
|
|
||||||
).node.public_key.hex()
|
|
||||||
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
|
|
||||||
)
|
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
# pin and passphrase are cached
|
# pin and passphrase are cached
|
||||||
client.set_expected_responses(cached_responses)
|
client.set_expected_responses(cached_responses)
|
||||||
assert (
|
assert get_public_node(client, ADDRESS_N).xpub == XPUB
|
||||||
get_public_node(
|
|
||||||
client, parse_path("44'/0'/0'"), show_display=True
|
|
||||||
).node.public_key.hex()
|
|
||||||
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user