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