mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-25 17:09:44 +00:00
debug: Add left and right swipe direction to DebugLinkDecision message and unify terminology around swipe direction.
This commit is contained in:
parent
47a21ceebc
commit
564b24191e
@ -14,8 +14,17 @@ import "messages-common.proto";
|
|||||||
*/
|
*/
|
||||||
message DebugLinkDecision {
|
message DebugLinkDecision {
|
||||||
optional bool yes_no = 1; // true for "Confirm", false for "Cancel"
|
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
|
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__:
|
if __debug__:
|
||||||
from trezor import config, log, loop, utils
|
from trezor import config, log, loop, utils
|
||||||
from trezor.messages import MessageType
|
from trezor.messages import MessageType, DebugSwipeDirection
|
||||||
from trezor.wire import register
|
from trezor.wire import register
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
@ -33,15 +33,19 @@ if __debug__:
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
msg = await debuglink_decision_chan.take()
|
msg = await debuglink_decision_chan.take()
|
||||||
|
|
||||||
if msg.yes_no is not None:
|
if msg.yes_no is not None:
|
||||||
await confirm_chan.put(
|
await confirm_chan.put(
|
||||||
confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED
|
confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED
|
||||||
)
|
)
|
||||||
if msg.up_down is not None:
|
if msg.swipe is not None:
|
||||||
await swipe_chan.put(
|
if msg.swipe == DebugSwipeDirection.UP:
|
||||||
swipe.SWIPE_DOWN if msg.up_down else swipe.SWIPE_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:
|
if msg.input is not None:
|
||||||
await input_chan.put(msg.input)
|
await input_chan.put(msg.input)
|
||||||
|
|
||||||
|
@ -6,8 +6,10 @@ if __debug__:
|
|||||||
try:
|
try:
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
from typing_extensions import Literal # noqa: F401
|
from typing_extensions import Literal # noqa: F401
|
||||||
|
EnumTypeDebugSwipeDirection = Literal[0, 1, 2, 3]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
Dict, List, Optional = None, None, None # type: ignore
|
Dict, List, Optional = None, None, None # type: ignore
|
||||||
|
EnumTypeDebugSwipeDirection = None # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkDecision(p.MessageType):
|
class DebugLinkDecision(p.MessageType):
|
||||||
@ -16,17 +18,17 @@ class DebugLinkDecision(p.MessageType):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
yes_no: bool = None,
|
yes_no: bool = None,
|
||||||
up_down: bool = None,
|
swipe: EnumTypeDebugSwipeDirection = None,
|
||||||
input: str = None,
|
input: str = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.yes_no = yes_no
|
self.yes_no = yes_no
|
||||||
self.up_down = up_down
|
self.swipe = swipe
|
||||||
self.input = input
|
self.input = input
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_fields(cls) -> Dict:
|
def get_fields(cls) -> Dict:
|
||||||
return {
|
return {
|
||||||
1: ('yes_no', p.BoolType, 0),
|
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),
|
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:
|
if args != 1:
|
||||||
raise ValueError("Invalid input - must use one of word, button, swipe")
|
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)
|
self._call(decision, nowait=True)
|
||||||
|
|
||||||
def press_yes(self):
|
def press_yes(self):
|
||||||
@ -101,10 +101,16 @@ class DebugLink:
|
|||||||
self.input(button=False)
|
self.input(button=False)
|
||||||
|
|
||||||
def swipe_up(self):
|
def swipe_up(self):
|
||||||
self.input(swipe=True)
|
self.input(swipe=proto.DebugSwipeDirection.UP)
|
||||||
|
|
||||||
def swipe_down(self):
|
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):
|
def stop(self):
|
||||||
self._call(proto.DebugLinkStop(), nowait=True)
|
self._call(proto.DebugLinkStop(), nowait=True)
|
||||||
|
@ -6,8 +6,10 @@ if __debug__:
|
|||||||
try:
|
try:
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
from typing_extensions import Literal # noqa: F401
|
from typing_extensions import Literal # noqa: F401
|
||||||
|
EnumTypeDebugSwipeDirection = Literal[0, 1, 2, 3]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
Dict, List, Optional = None, None, None # type: ignore
|
Dict, List, Optional = None, None, None # type: ignore
|
||||||
|
EnumTypeDebugSwipeDirection = None # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkDecision(p.MessageType):
|
class DebugLinkDecision(p.MessageType):
|
||||||
@ -16,17 +18,17 @@ class DebugLinkDecision(p.MessageType):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
yes_no: bool = None,
|
yes_no: bool = None,
|
||||||
up_down: bool = None,
|
swipe: EnumTypeDebugSwipeDirection = None,
|
||||||
input: str = None,
|
input: str = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.yes_no = yes_no
|
self.yes_no = yes_no
|
||||||
self.up_down = up_down
|
self.swipe = swipe
|
||||||
self.input = input
|
self.input = input
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_fields(cls) -> Dict:
|
def get_fields(cls) -> Dict:
|
||||||
return {
|
return {
|
||||||
1: ('yes_no', p.BoolType, 0),
|
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),
|
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 BinanceTimeInForce
|
||||||
from . import ButtonRequestType
|
from . import ButtonRequestType
|
||||||
from . import Capability
|
from . import Capability
|
||||||
|
from . import DebugSwipeDirection
|
||||||
from . import FailureType
|
from . import FailureType
|
||||||
from . import InputScriptType
|
from . import InputScriptType
|
||||||
from . import LiskTransactionType
|
from . import LiskTransactionType
|
||||||
|
@ -149,7 +149,7 @@ def read_and_confirm_mnemonic(debug, words):
|
|||||||
while True:
|
while True:
|
||||||
mnemonic.extend(debug.read_reset_word().split())
|
mnemonic.extend(debug.read_reset_word().split())
|
||||||
if len(mnemonic) < words:
|
if len(mnemonic) < words:
|
||||||
debug.swipe_down()
|
debug.swipe_up()
|
||||||
else:
|
else:
|
||||||
# last page is confirmation
|
# last page is confirmation
|
||||||
debug.press_yes()
|
debug.press_yes()
|
||||||
|
@ -191,10 +191,10 @@ def test_cardano_sign_tx(
|
|||||||
|
|
||||||
def input_flow():
|
def input_flow():
|
||||||
yield
|
yield
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
yield
|
yield
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
|
@ -134,10 +134,10 @@ def test_cardano_sign_tx(
|
|||||||
|
|
||||||
def input_flow():
|
def input_flow():
|
||||||
yield
|
yield
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
yield
|
yield
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
client.set_passphrase("TREZOR")
|
client.set_passphrase("TREZOR")
|
||||||
|
@ -40,7 +40,7 @@ class TestMsgEosSignTx:
|
|||||||
# swipe through pages
|
# swipe through pages
|
||||||
yield
|
yield
|
||||||
for _ in range(pages - 1):
|
for _ in range(pages - 1):
|
||||||
debug.swipe_down()
|
debug.swipe_up()
|
||||||
|
|
||||||
# confirm last page
|
# confirm last page
|
||||||
debug.press_yes()
|
debug.press_yes()
|
||||||
@ -654,14 +654,14 @@ class TestMsgEosSignTx:
|
|||||||
# swipe through new account
|
# swipe through new account
|
||||||
yield
|
yield
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
|
|
||||||
# confirm new account
|
# confirm new account
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
# swipe through buyrambytes
|
# swipe through buyrambytes
|
||||||
yield
|
yield
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
|
|
||||||
# confirm buyrambytes
|
# confirm buyrambytes
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
@ -669,7 +669,7 @@ class TestMsgEosSignTx:
|
|||||||
# swipe through delegatebw
|
# swipe through delegatebw
|
||||||
yield
|
yield
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
|
|
||||||
# confirm delegatebw
|
# confirm delegatebw
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
@ -721,14 +721,14 @@ class TestMsgEosSignTx:
|
|||||||
|
|
||||||
# swipe through setcode
|
# swipe through setcode
|
||||||
yield
|
yield
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
|
|
||||||
# confirm setcode
|
# confirm setcode
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
# swipe through setabi
|
# swipe through setabi
|
||||||
yield
|
yield
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
|
|
||||||
# confirm setabi
|
# confirm setabi
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
@ -174,7 +174,7 @@ class TestMsgNEMSignTxMosaics:
|
|||||||
# Swipe and confirm
|
# Swipe and confirm
|
||||||
yield
|
yield
|
||||||
for _ in range(num_of_swipes):
|
for _ in range(num_of_swipes):
|
||||||
client.debug.swipe_down()
|
client.debug.swipe_up()
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
# Confirm Action
|
# Confirm Action
|
||||||
|
@ -190,7 +190,7 @@ class TestMsgTezosSignTx:
|
|||||||
def input_flow(self, debug, num_pages):
|
def input_flow(self, debug, num_pages):
|
||||||
yield
|
yield
|
||||||
for _ in range(num_pages - 1):
|
for _ in range(num_pages - 1):
|
||||||
debug.swipe_down()
|
debug.swipe_up()
|
||||||
debug.press_yes()
|
debug.press_yes()
|
||||||
|
|
||||||
def test_tezos_sign_tx_proposal(self, client):
|
def test_tezos_sign_tx_proposal(self, client):
|
||||||
|
Loading…
Reference in New Issue
Block a user