mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
device_tests: add input flow function to Ontology tests (#348)
This commit is contained in:
parent
0428f5091c
commit
402e72e36e
@ -18,7 +18,8 @@ import time
|
||||
|
||||
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 .common import TrezorTest
|
||||
@ -70,23 +71,28 @@ class TestMsgOntologySignOntIdAddAttributes(TrezorTest):
|
||||
def _ontology_sign(
|
||||
self, num_of_swipes, address_n, transaction, ont_id_add_attributes
|
||||
):
|
||||
# Sending Ontology message
|
||||
msg = messages.OntologySignOntIdAddAttributes(
|
||||
address_n=address_n,
|
||||
transaction=transaction,
|
||||
ont_id_add_attributes=ont_id_add_attributes,
|
||||
)
|
||||
def input_flow():
|
||||
# Sign Tx
|
||||
btn_code = yield
|
||||
assert btn_code == B.SignTx
|
||||
|
||||
self.client.transport.write(msg)
|
||||
ret = self.client.transport.read()
|
||||
|
||||
# Confirm action
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
self.client.debug.press_yes()
|
||||
self.client.transport.write(messages.ButtonAck())
|
||||
# Swipe and confirm
|
||||
time.sleep(1)
|
||||
for _ in range(num_of_swipes):
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# Confirm Action
|
||||
self.client.debug.press_yes()
|
||||
return self.client.transport.read()
|
||||
|
||||
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
|
||||
)
|
||||
|
@ -18,7 +18,8 @@ import time
|
||||
|
||||
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 .common import TrezorTest
|
||||
@ -62,23 +63,28 @@ class TestMsgOntologySignOntIdRegister(TrezorTest):
|
||||
)
|
||||
|
||||
def _ontology_sign(self, num_of_swipes, address_n, transaction, ont_id_register):
|
||||
# Sending Ontology message
|
||||
msg = messages.OntologySignOntIdRegister(
|
||||
address_n=address_n,
|
||||
transaction=transaction,
|
||||
ont_id_register=ont_id_register,
|
||||
)
|
||||
def input_flow():
|
||||
# Sign Tx
|
||||
btn_code = yield
|
||||
assert btn_code == B.SignTx
|
||||
|
||||
self.client.transport.write(msg)
|
||||
ret = self.client.transport.read()
|
||||
|
||||
# Confirm action
|
||||
assert isinstance(ret, messages.ButtonRequest)
|
||||
self.client.debug.press_yes()
|
||||
self.client.transport.write(messages.ButtonAck())
|
||||
# Swipe and confirm
|
||||
time.sleep(1)
|
||||
for _ in range(num_of_swipes):
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# Confirm Action
|
||||
self.client.debug.press_yes()
|
||||
return self.client.transport.read()
|
||||
|
||||
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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user