mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
Merge pull request #606 from trezor/andrewkozlik/fido2-device-test
debug: Add left and right swipe direction to DebugLinkDecision message and unify terminology around swipe direction.
This commit is contained in:
commit
7b0860a3cc
@ -14,8 +14,17 @@ import "messages-common.proto";
|
||||
*/
|
||||
message DebugLinkDecision {
|
||||
optional bool yes_no = 1; // true for "Confirm", false for "Cancel"
|
||||
optional bool up_down = 2; // true for scroll up, false for scroll down
|
||||
optional DebugSwipeDirection swipe = 2; // swipe direction
|
||||
optional string input = 3; // keyboard input
|
||||
/**
|
||||
* Structure representing swipe direction
|
||||
*/
|
||||
enum DebugSwipeDirection {
|
||||
UP = 0;
|
||||
DOWN = 1;
|
||||
LEFT = 2;
|
||||
RIGHT = 3;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ if not __debug__:
|
||||
|
||||
if __debug__:
|
||||
from trezor import config, log, loop, utils
|
||||
from trezor.messages import MessageType
|
||||
from trezor.messages import MessageType, DebugSwipeDirection
|
||||
from trezor.wire import register
|
||||
|
||||
if False:
|
||||
@ -33,15 +33,19 @@ if __debug__:
|
||||
|
||||
while True:
|
||||
msg = await debuglink_decision_chan.take()
|
||||
|
||||
if msg.yes_no is not None:
|
||||
await confirm_chan.put(
|
||||
confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED
|
||||
)
|
||||
if msg.up_down is not None:
|
||||
await swipe_chan.put(
|
||||
swipe.SWIPE_DOWN if msg.up_down else swipe.SWIPE_UP
|
||||
)
|
||||
if msg.swipe is not None:
|
||||
if msg.swipe == DebugSwipeDirection.UP:
|
||||
await swipe_chan.put(swipe.SWIPE_UP)
|
||||
elif msg.swipe == DebugSwipeDirection.DOWN:
|
||||
await swipe_chan.put(swipe.SWIPE_DOWN)
|
||||
elif msg.swipe == DebugSwipeDirection.LEFT:
|
||||
await swipe_chan.put(swipe.SWIPE_LEFT)
|
||||
elif msg.swipe == DebugSwipeDirection.RIGHT:
|
||||
await swipe_chan.put(swipe.SWIPE_RIGHT)
|
||||
if msg.input is not None:
|
||||
await input_chan.put(msg.input)
|
||||
|
||||
|
@ -6,8 +6,10 @@ if __debug__:
|
||||
try:
|
||||
from typing import Dict, List, Optional
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
EnumTypeDebugSwipeDirection = Literal[0, 1, 2, 3]
|
||||
except ImportError:
|
||||
Dict, List, Optional = None, None, None # type: ignore
|
||||
EnumTypeDebugSwipeDirection = None # type: ignore
|
||||
|
||||
|
||||
class DebugLinkDecision(p.MessageType):
|
||||
@ -16,17 +18,17 @@ class DebugLinkDecision(p.MessageType):
|
||||
def __init__(
|
||||
self,
|
||||
yes_no: bool = None,
|
||||
up_down: bool = None,
|
||||
swipe: EnumTypeDebugSwipeDirection = None,
|
||||
input: str = None,
|
||||
) -> None:
|
||||
self.yes_no = yes_no
|
||||
self.up_down = up_down
|
||||
self.swipe = swipe
|
||||
self.input = input
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('yes_no', p.BoolType, 0),
|
||||
2: ('up_down', p.BoolType, 0),
|
||||
2: ('swipe', p.EnumType("DebugSwipeDirection", (0, 1, 2, 3)), 0),
|
||||
3: ('input', p.UnicodeType, 0),
|
||||
}
|
||||
|
6
core/src/trezor/messages/DebugSwipeDirection.py
Normal file
6
core/src/trezor/messages/DebugSwipeDirection.py
Normal file
@ -0,0 +1,6 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
UP = 0
|
||||
DOWN = 1
|
||||
LEFT = 2
|
||||
RIGHT = 3
|
@ -91,7 +91,7 @@ class DebugLink:
|
||||
if args != 1:
|
||||
raise ValueError("Invalid input - must use one of word, button, swipe")
|
||||
|
||||
decision = proto.DebugLinkDecision(yes_no=button, up_down=swipe, input=word)
|
||||
decision = proto.DebugLinkDecision(yes_no=button, swipe=swipe, input=word)
|
||||
self._call(decision, nowait=True)
|
||||
|
||||
def press_yes(self):
|
||||
@ -101,10 +101,16 @@ class DebugLink:
|
||||
self.input(button=False)
|
||||
|
||||
def swipe_up(self):
|
||||
self.input(swipe=True)
|
||||
self.input(swipe=proto.DebugSwipeDirection.UP)
|
||||
|
||||
def swipe_down(self):
|
||||
self.input(swipe=False)
|
||||
self.input(swipe=proto.DebugSwipeDirection.DOWN)
|
||||
|
||||
def swipe_right(self):
|
||||
self.input(swipe=proto.DebugSwipeDirection.RIGHT)
|
||||
|
||||
def swipe_left(self):
|
||||
self.input(swipe=proto.DebugSwipeDirection.LEFT)
|
||||
|
||||
def stop(self):
|
||||
self._call(proto.DebugLinkStop(), nowait=True)
|
||||
|
@ -6,8 +6,10 @@ if __debug__:
|
||||
try:
|
||||
from typing import Dict, List, Optional
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
EnumTypeDebugSwipeDirection = Literal[0, 1, 2, 3]
|
||||
except ImportError:
|
||||
Dict, List, Optional = None, None, None # type: ignore
|
||||
EnumTypeDebugSwipeDirection = None # type: ignore
|
||||
|
||||
|
||||
class DebugLinkDecision(p.MessageType):
|
||||
@ -16,17 +18,17 @@ class DebugLinkDecision(p.MessageType):
|
||||
def __init__(
|
||||
self,
|
||||
yes_no: bool = None,
|
||||
up_down: bool = None,
|
||||
swipe: EnumTypeDebugSwipeDirection = None,
|
||||
input: str = None,
|
||||
) -> None:
|
||||
self.yes_no = yes_no
|
||||
self.up_down = up_down
|
||||
self.swipe = swipe
|
||||
self.input = input
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('yes_no', p.BoolType, 0),
|
||||
2: ('up_down', p.BoolType, 0),
|
||||
2: ('swipe', p.EnumType("DebugSwipeDirection", (0, 1, 2, 3)), 0),
|
||||
3: ('input', p.UnicodeType, 0),
|
||||
}
|
||||
|
6
python/src/trezorlib/messages/DebugSwipeDirection.py
Normal file
6
python/src/trezorlib/messages/DebugSwipeDirection.py
Normal file
@ -0,0 +1,6 @@
|
||||
# Automatically generated by pb2py
|
||||
# fmt: off
|
||||
UP = 0
|
||||
DOWN = 1
|
||||
LEFT = 2
|
||||
RIGHT = 3
|
@ -262,6 +262,7 @@ from . import BinanceOrderType
|
||||
from . import BinanceTimeInForce
|
||||
from . import ButtonRequestType
|
||||
from . import Capability
|
||||
from . import DebugSwipeDirection
|
||||
from . import FailureType
|
||||
from . import InputScriptType
|
||||
from . import LiskTransactionType
|
||||
|
@ -149,7 +149,7 @@ def read_and_confirm_mnemonic(debug, words):
|
||||
while True:
|
||||
mnemonic.extend(debug.read_reset_word().split())
|
||||
if len(mnemonic) < words:
|
||||
debug.swipe_down()
|
||||
debug.swipe_up()
|
||||
else:
|
||||
# last page is confirmation
|
||||
debug.press_yes()
|
||||
|
@ -191,10 +191,10 @@ def test_cardano_sign_tx(
|
||||
|
||||
def input_flow():
|
||||
yield
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
client.debug.press_yes()
|
||||
yield
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
client.debug.press_yes()
|
||||
|
||||
with client:
|
||||
|
@ -134,10 +134,10 @@ def test_cardano_sign_tx(
|
||||
|
||||
def input_flow():
|
||||
yield
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
client.debug.press_yes()
|
||||
yield
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
client.debug.press_yes()
|
||||
|
||||
client.set_passphrase("TREZOR")
|
||||
|
@ -40,7 +40,7 @@ class TestMsgEosSignTx:
|
||||
# swipe through pages
|
||||
yield
|
||||
for _ in range(pages - 1):
|
||||
debug.swipe_down()
|
||||
debug.swipe_up()
|
||||
|
||||
# confirm last page
|
||||
debug.press_yes()
|
||||
@ -654,14 +654,14 @@ class TestMsgEosSignTx:
|
||||
# swipe through new account
|
||||
yield
|
||||
for _ in range(5):
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
|
||||
# confirm new account
|
||||
client.debug.press_yes()
|
||||
|
||||
# swipe through buyrambytes
|
||||
yield
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
|
||||
# confirm buyrambytes
|
||||
client.debug.press_yes()
|
||||
@ -669,7 +669,7 @@ class TestMsgEosSignTx:
|
||||
# swipe through delegatebw
|
||||
yield
|
||||
for _ in range(2):
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
|
||||
# confirm delegatebw
|
||||
client.debug.press_yes()
|
||||
@ -721,14 +721,14 @@ class TestMsgEosSignTx:
|
||||
|
||||
# swipe through setcode
|
||||
yield
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
|
||||
# confirm setcode
|
||||
client.debug.press_yes()
|
||||
|
||||
# swipe through setabi
|
||||
yield
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
|
||||
# confirm setabi
|
||||
client.debug.press_yes()
|
||||
|
@ -174,7 +174,7 @@ class TestMsgNEMSignTxMosaics:
|
||||
# Swipe and confirm
|
||||
yield
|
||||
for _ in range(num_of_swipes):
|
||||
client.debug.swipe_down()
|
||||
client.debug.swipe_up()
|
||||
client.debug.press_yes()
|
||||
|
||||
# Confirm Action
|
||||
|
@ -190,7 +190,7 @@ class TestMsgTezosSignTx:
|
||||
def input_flow(self, debug, num_pages):
|
||||
yield
|
||||
for _ in range(num_pages - 1):
|
||||
debug.swipe_down()
|
||||
debug.swipe_up()
|
||||
debug.press_yes()
|
||||
|
||||
def test_tezos_sign_tx_proposal(self, client):
|
||||
|
Loading…
Reference in New Issue
Block a user