chore(core/test): Add input flow test for ERC20 approve

[no changelog]
issue_2923
Christopher Bergqvist 11 months ago
parent d6d4343a5e
commit 49fb99bbf6
No known key found for this signature in database
GPG Key ID: A0DEB4CB2A91DE0D

@ -23,6 +23,7 @@ from trezorlib.tools import parse_path, unharden
from ...common import parametrize_using_common_fixtures
from ...input_flows import (
InputFlowErc20Approve,
InputFlowEthereumSignTxGoBack,
InputFlowEthereumSignTxScrollDown,
InputFlowEthereumSignTxSkip,
@ -392,3 +393,25 @@ def test_signtx_data_pagination(client: Client, flow):
client.watch_layout()
client.set_input_flow(flow(client, cancel=True))
_sign_tx_call()
@pytest.mark.skip_t1
def test_ethereum_sign_erc20_approve(client: Client):
with client:
client.watch_layout()
IF = InputFlowErc20Approve(client)
client.set_input_flow(IF.get())
ethereum.sign_tx(
client,
n=parse_path("m/44h/60h/0h/0/0"),
nonce=0x0,
gas_price=0x14,
gas_limit=0x14,
to="0xfc6b5d6af8a13258f7cbd0d39e11b35e01a32f93",
chain_id=1,
value=0x0,
tx_type=None,
data=bytes.fromhex(
"095ea7b300000000000000000000000012345678901234567890123456789012345678900000000000000000000000000000000000000000000000056bc75e2d63100000"
),
)

@ -1318,6 +1318,38 @@ class InputFlowBip39RecoveryDryRun(InputFlowBase):
self.debug.press_yes()
class InputFlowErc20Approve(InputFlowBase):
def __init__(self, client: Client):
super().__init__(client)
def input_flow_tt(self) -> GeneratorType:
br = yield
assert br.code == messages.ButtonRequestType.Other
assert "CONFIRM APPROVE" == self.layout().title()
assert (
"Allow 0x123456789012345- 67890123456789012- 34567890 to withdraw up to 100,000,000,000,0"
in self.layout().text_content()
)
self.debug.swipe_up()
assert br.code == messages.ButtonRequestType.Other
assert "CONFIRM APPROVE" == self.layout().title()
assert "00,000,000 Wei UNKN" in self.layout().text_content()
self.debug.press_yes()
yield
assert br.code == messages.ButtonRequestType.Other
assert "CONFIRM FEE" == self.layout().title()
assert "Gas price: 20 Wei ETH" in self.layout().text_content()
self.debug.press_yes()
yield
assert br.code == messages.ButtonRequestType.Other
assert "TOTAL" == self.layout().title()
assert "Maximum fee: 400 Wei ETH" in self.layout().text_content()
self.debug.press_yes()
class InputFlowBip39RecoveryDryRunInvalid(InputFlowBase):
def __init__(self, client: Client):
super().__init__(client)

Loading…
Cancel
Save