1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-26 09:52:34 +00:00

device_tests: add input flow function to Ontology tests (#348)

This commit is contained in:
strmci 2019-01-07 12:58:42 +01:00 committed by matejcik
parent 0428f5091c
commit 402e72e36e
2 changed files with 50 additions and 38 deletions

View File

@ -18,7 +18,8 @@ import time
import pytest import pytest
from trezorlib import messages from trezorlib import messages, ontology
from trezorlib.messages import ButtonRequestType as B
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest from .common import TrezorTest
@ -70,23 +71,28 @@ class TestMsgOntologySignOntIdAddAttributes(TrezorTest):
def _ontology_sign( def _ontology_sign(
self, num_of_swipes, address_n, transaction, ont_id_add_attributes self, num_of_swipes, address_n, transaction, ont_id_add_attributes
): ):
# Sending Ontology message def input_flow():
msg = messages.OntologySignOntIdAddAttributes( # Sign Tx
address_n=address_n, btn_code = yield
transaction=transaction, assert btn_code == B.SignTx
ont_id_add_attributes=ont_id_add_attributes,
)
self.client.transport.write(msg) # Swipe and confirm
ret = self.client.transport.read()
# Confirm action
assert isinstance(ret, messages.ButtonRequest)
self.client.debug.press_yes()
self.client.transport.write(messages.ButtonAck())
time.sleep(1)
for _ in range(num_of_swipes):
self.client.debug.swipe_down()
time.sleep(1) time.sleep(1)
self.client.debug.press_yes() for _ in range(num_of_swipes):
return self.client.transport.read() self.client.debug.swipe_down()
time.sleep(1)
# Confirm Action
self.client.debug.press_yes()
with self.client:
self.client.set_input_flow(input_flow)
self.client.set_expected_responses(
[
messages.ButtonRequest(code=B.SignTx),
messages.OntologySignedOntIdAddAttributes(),
]
)
return ontology.sign_add_attr(
self.client, address_n, transaction, ont_id_add_attributes
)

View File

@ -18,7 +18,8 @@ import time
import pytest import pytest
from trezorlib import messages from trezorlib import messages, ontology
from trezorlib.messages import ButtonRequestType as B
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest from .common import TrezorTest
@ -62,23 +63,28 @@ class TestMsgOntologySignOntIdRegister(TrezorTest):
) )
def _ontology_sign(self, num_of_swipes, address_n, transaction, ont_id_register): def _ontology_sign(self, num_of_swipes, address_n, transaction, ont_id_register):
# Sending Ontology message def input_flow():
msg = messages.OntologySignOntIdRegister( # Sign Tx
address_n=address_n, btn_code = yield
transaction=transaction, assert btn_code == B.SignTx
ont_id_register=ont_id_register,
)
self.client.transport.write(msg) # Swipe and confirm
ret = self.client.transport.read()
# Confirm action
assert isinstance(ret, messages.ButtonRequest)
self.client.debug.press_yes()
self.client.transport.write(messages.ButtonAck())
time.sleep(1)
for _ in range(num_of_swipes):
self.client.debug.swipe_down()
time.sleep(1) time.sleep(1)
self.client.debug.press_yes() for _ in range(num_of_swipes):
return self.client.transport.read() self.client.debug.swipe_down()
time.sleep(1)
# Confirm Action
self.client.debug.press_yes()
with self.client:
self.client.set_expected_responses(
[
messages.ButtonRequest(code=B.SignTx),
messages.OntologySignedOntIdRegister(),
]
)
self.client.set_input_flow(input_flow)
return ontology.sign_register(
self.client, address_n, transaction, ont_id_register
)