mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
tests: take advantage of debuglink feedback
This commit is contained in:
parent
0890f68c0c
commit
b9c978c1e2
@ -59,10 +59,6 @@ class DebugLink:
|
||||
_, matrix = self.read_pin()
|
||||
return "".join([str(matrix.index(p) + 1) for p in pin])
|
||||
|
||||
def read_layout(self):
|
||||
obj = self._call(proto.DebugLinkGetState())
|
||||
return obj.layout
|
||||
|
||||
def read_mnemonic_secret(self):
|
||||
obj = self._call(proto.DebugLinkGetState())
|
||||
return obj.mnemonic_secret
|
||||
@ -72,11 +68,11 @@ class DebugLink:
|
||||
return (obj.recovery_fake_word, obj.recovery_word_pos)
|
||||
|
||||
def read_reset_word(self):
|
||||
obj = self._call(proto.DebugLinkGetState())
|
||||
obj = self._call(proto.DebugLinkGetState(wait_word_list=True))
|
||||
return obj.reset_word
|
||||
|
||||
def read_reset_word_pos(self):
|
||||
obj = self._call(proto.DebugLinkGetState())
|
||||
obj = self._call(proto.DebugLinkGetState(wait_word_pos=True))
|
||||
return obj.reset_word_pos
|
||||
|
||||
def read_reset_entropy(self):
|
||||
@ -90,19 +86,13 @@ class DebugLink:
|
||||
def input(self, word=None, button=None, swipe=None):
|
||||
if not self.allow_interactions:
|
||||
return
|
||||
decision = proto.DebugLinkDecision()
|
||||
if button is not None:
|
||||
decision.yes_no = button
|
||||
elif word is not None:
|
||||
decision.input = word
|
||||
elif swipe is not None:
|
||||
decision.up_down = swipe
|
||||
else:
|
||||
raise ValueError("You need to provide input data.")
|
||||
self._call(decision, nowait=True)
|
||||
|
||||
def press_button(self, yes_no):
|
||||
self._call(proto.DebugLinkDecision(yes_no=yes_no), nowait=True)
|
||||
args = sum(a is not None for a in (word, button, swipe))
|
||||
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)
|
||||
self._call(decision, nowait=True)
|
||||
|
||||
def press_yes(self):
|
||||
self.input(button=True)
|
||||
|
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
@ -40,7 +39,6 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
yield
|
||||
for _ in range(pages - 1):
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# confirm last page
|
||||
self.client.debug.press_yes()
|
||||
@ -285,7 +283,7 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
}
|
||||
|
||||
with self.client:
|
||||
self.client.set_input_flow(self.input_flow(pages=2))
|
||||
self.client.set_input_flow(self.input_flow(pages=0))
|
||||
resp = eos.sign_tx(self.client, ADDRESS_N, transaction, CHAIN_ID)
|
||||
assert isinstance(resp, EosSignedTx)
|
||||
assert (
|
||||
@ -449,7 +447,7 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
}
|
||||
|
||||
with self.client:
|
||||
self.client.set_input_flow(self.input_flow(pages=2))
|
||||
self.client.set_input_flow(self.input_flow(pages=0))
|
||||
resp = eos.sign_tx(self.client, ADDRESS_N, transaction, CHAIN_ID)
|
||||
assert isinstance(resp, EosSignedTx)
|
||||
assert (
|
||||
@ -547,7 +545,7 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
}
|
||||
|
||||
with self.client:
|
||||
self.client.set_input_flow(self.input_flow(pages=2))
|
||||
self.client.set_input_flow(self.input_flow(pages=0))
|
||||
resp = eos.sign_tx(self.client, ADDRESS_N, transaction, CHAIN_ID)
|
||||
assert isinstance(resp, EosSignedTx)
|
||||
assert (
|
||||
@ -670,7 +668,6 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
yield
|
||||
for _ in range(5):
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# confirm new account
|
||||
self.client.debug.press_yes()
|
||||
@ -678,7 +675,6 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
# swipe through buyrambytes
|
||||
yield
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# confirm buyrambytes
|
||||
self.client.debug.press_yes()
|
||||
@ -687,7 +683,6 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
yield
|
||||
for _ in range(2):
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# confirm delegatebw
|
||||
self.client.debug.press_yes()
|
||||
@ -741,7 +736,6 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
# swipe through setcode
|
||||
yield
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# confirm setcode
|
||||
self.client.debug.press_yes()
|
||||
@ -749,7 +743,6 @@ class TestMsgEosSignTx(TrezorTest):
|
||||
# swipe through setabi
|
||||
yield
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
|
||||
# confirm setabi
|
||||
self.client.debug.press_yes()
|
||||
|
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
@ -62,7 +61,6 @@ def enter_all_shares(debug, shares):
|
||||
assert code == messages.ButtonRequestType.MnemonicInput
|
||||
# Enter mnemonic words
|
||||
for word in share.split(" "):
|
||||
time.sleep(1)
|
||||
debug.input(word)
|
||||
|
||||
# Homescreen - continue
|
||||
@ -173,14 +171,12 @@ def test_wrong_nth_word(client, nth_word):
|
||||
debug.press_yes()
|
||||
yield # Enter first share
|
||||
for word in share:
|
||||
time.sleep(1)
|
||||
debug.input(word)
|
||||
|
||||
yield # Continue to next share
|
||||
debug.press_yes()
|
||||
yield # Enter next share
|
||||
for i, word in enumerate(share):
|
||||
time.sleep(1)
|
||||
if i < nth_word:
|
||||
debug.input(word)
|
||||
else:
|
||||
@ -215,14 +211,12 @@ def test_same_share(client):
|
||||
debug.press_yes()
|
||||
yield # Enter first share
|
||||
for word in first_share:
|
||||
time.sleep(1)
|
||||
debug.input(word)
|
||||
|
||||
yield # Continue to next share
|
||||
debug.press_yes()
|
||||
yield # Enter next share
|
||||
for word in second_share:
|
||||
time.sleep(1)
|
||||
debug.input(word)
|
||||
|
||||
code = yield
|
||||
|
@ -1,5 +1,3 @@
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import device, messages
|
||||
@ -94,7 +92,6 @@ def enter_all_shares(debug, shares):
|
||||
assert code == messages.ButtonRequestType.MnemonicInput
|
||||
# Enter mnemonic words
|
||||
for word in share.split(" "):
|
||||
time.sleep(1)
|
||||
debug.input(word)
|
||||
|
||||
# Homescreen - continue
|
||||
|
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
@ -72,7 +71,6 @@ class TestMsgRecoverydeviceT2(TrezorTest):
|
||||
assert ret == proto.ButtonRequest(code=proto.ButtonRequestType.MnemonicInput)
|
||||
self.client.transport.write(proto.ButtonAck())
|
||||
for word in mnemonic:
|
||||
time.sleep(1)
|
||||
self.client.debug.input(word)
|
||||
ret = self.client.transport.read()
|
||||
|
||||
@ -128,7 +126,6 @@ class TestMsgRecoverydeviceT2(TrezorTest):
|
||||
assert ret == proto.ButtonRequest(code=proto.ButtonRequestType.MnemonicInput)
|
||||
self.client.transport.write(proto.ButtonAck())
|
||||
for word in mnemonic:
|
||||
time.sleep(1)
|
||||
self.client.debug.input(word)
|
||||
ret = self.client.transport.read()
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import time
|
||||
from itertools import combinations
|
||||
from unittest import mock
|
||||
|
||||
@ -72,8 +71,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
# mnemonic phrases
|
||||
# 20 word over 6 pages for strength 128, 33 words over 9 pages for strength 256
|
||||
for i in range(6):
|
||||
time.sleep(1)
|
||||
words.extend(self.client.debug.state().reset_word.split())
|
||||
words.extend(self.client.debug.read_reset_word().split())
|
||||
if i < 5:
|
||||
self.client.debug.swipe_down()
|
||||
else:
|
||||
@ -82,8 +80,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
|
||||
# check share
|
||||
for _ in range(3):
|
||||
time.sleep(1)
|
||||
index = self.client.debug.state().reset_word_pos
|
||||
index = self.client.debug.read_reset_word_pos()
|
||||
self.client.debug.input(words[index])
|
||||
|
||||
all_mnemonics.extend([" ".join(words)])
|
||||
|
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@ -55,8 +54,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
assert btn_code == B.ResetDevice
|
||||
# 12 words, 3 pages
|
||||
for i in range(3):
|
||||
time.sleep(1)
|
||||
words.extend(self.client.debug.state().reset_word.split())
|
||||
words.extend(self.client.debug.read_reset_word().split())
|
||||
if i < 2:
|
||||
self.client.debug.swipe_down()
|
||||
else:
|
||||
@ -65,8 +63,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
|
||||
# check backup words
|
||||
for _ in range(3):
|
||||
time.sleep(1)
|
||||
index = self.client.debug.state().reset_word_pos
|
||||
index = self.client.debug.read_reset_word_pos()
|
||||
self.client.debug.input(words[index])
|
||||
|
||||
# confirm recovery seed check
|
||||
@ -160,8 +157,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
assert btn_code == B.ResetDevice
|
||||
# 12 words, 3 pages
|
||||
for i in range(3):
|
||||
time.sleep(1)
|
||||
words.extend(self.client.debug.state().reset_word.split())
|
||||
words.extend(self.client.debug.read_reset_word().split())
|
||||
if i < 2:
|
||||
self.client.debug.swipe_down()
|
||||
else:
|
||||
@ -170,8 +166,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
|
||||
# check backup words
|
||||
for _ in range(3):
|
||||
time.sleep(1)
|
||||
index = self.client.debug.state().reset_word_pos
|
||||
index = self.client.debug.read_reset_word_pos()
|
||||
self.client.debug.input(words[index])
|
||||
|
||||
# confirm recovery seed check
|
||||
|
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
@ -200,10 +199,8 @@ class TestMsgTezosSignTx(TrezorTest):
|
||||
|
||||
def input_flow(self, num_pages):
|
||||
yield
|
||||
time.sleep(1)
|
||||
for _ in range(num_pages - 1):
|
||||
self.client.debug.swipe_down()
|
||||
time.sleep(1)
|
||||
self.client.debug.press_yes()
|
||||
|
||||
def test_tezos_sign_tx_proposal(self):
|
||||
|
Loading…
Reference in New Issue
Block a user