1
0
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:
matejcik 2020-01-31 16:37:37 +01:00 committed by Pavol Rusnak
parent fd0dc8ed66
commit a8cfa8fbed
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -16,65 +16,41 @@
import pytest
from trezorlib import messages as proto
from trezorlib import messages
from trezorlib.btc import get_public_node
from trezorlib.tools import parse_path
ADDRESS_N = parse_path("44'/0'/0'")
XPUB = "xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy"
@pytest.mark.skip_ui
@pytest.mark.setup_client(pin=True, passphrase=True)
def test_clear_session(client):
if client.features.model == "1":
init_responses = [
proto.PinMatrixRequest(),
proto.PassphraseRequest(),
]
init_responses = [messages.PinMatrixRequest(), messages.PassphraseRequest()]
else:
init_responses = [
proto.PassphraseRequest(),
]
cached_responses = [
proto.ButtonRequest(code=proto.ButtonRequestType.PublicKey),
proto.PublicKey(),
]
init_responses = [messages.PassphraseRequest()]
cached_responses = [messages.PublicKey()]
with client:
client.set_expected_responses(init_responses + cached_responses)
assert (
get_public_node(
client, parse_path("44'/0'/0'"), show_display=True
).node.public_key.hex()
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
)
assert get_public_node(client, ADDRESS_N).xpub == XPUB
with client:
# pin and passphrase are cached
client.set_expected_responses(cached_responses)
assert (
get_public_node(
client, parse_path("44'/0'/0'"), show_display=True
).node.public_key.hex()
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
)
assert get_public_node(client, ADDRESS_N).xpub == XPUB
client.clear_session()
# session cache is cleared
with client:
client.set_expected_responses(init_responses + cached_responses)
assert (
get_public_node(
client, parse_path("44'/0'/0'"), show_display=True
).node.public_key.hex()
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
)
assert get_public_node(client, ADDRESS_N).xpub == XPUB
with client:
# pin and passphrase are cached
client.set_expected_responses(cached_responses)
assert (
get_public_node(
client, parse_path("44'/0'/0'"), show_display=True
).node.public_key.hex()
== "03c8166eb40ac84088b618ec07c7cebadacee31c5f5b04a1e8c2a2f3e748eb2cdd"
)
assert get_public_node(client, ADDRESS_N).xpub == XPUB