Skip to content

Commit

Permalink
first workable version
Browse files Browse the repository at this point in the history
  • Loading branch information
Pana committed Nov 5, 2024
1 parent d2cf096 commit e828ae5
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 19 deletions.
4 changes: 0 additions & 4 deletions main.py

This file was deleted.

Empty file removed tests/__init__.py
Empty file.
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ safe-pysha3>=1.0.0,<2.0.0
tomli>=2.0.1
web3>=7.0.0,<8.0.0
cfx-account>=1.2.1
cfx-address>=1.2.3
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_short_tx/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_sign_tx_short_tx/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 35 additions & 15 deletions tests/test_sign_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ragger.navigator import NavIns, NavInsID
from utils import ROOT_SCREENSHOT_PATH, check_signature_validity
from web3 import Web3
from cfx_address import Base32Address

# In these tests we check the behavior of the device when asked to sign a transaction

Expand All @@ -25,11 +26,18 @@ def test_sign_tx_short_tx(backend, scenario_navigator, firmware, navigator):

# Create the transaction that will be sent to the device for signing
transaction = Transaction(
to=Base32Address("0x1123456789012345678901234567890123456789", network_id=1029),
value=1,
nonce=1,
value=777,
to="de0b295669a9fd93d5f28d9ec85e40f4cb697bae",
data=Web3.to_hex("For u EthDev")
gas=1,
gasPrice=1,
storageLimit=1,
epochHeight=1,
chainId=1,
data="".encode("utf-8")
).serialize()

print(transaction)

# Enable display of transaction data (NBGL devices only)
if not firmware.device.startswith("nano"):
Expand Down Expand Up @@ -70,10 +78,15 @@ def test_sign_tx_short_tx_no_memo(backend, scenario_navigator, firmware):

# Create the transaction that will be sent to the device for signing
transaction = Transaction(
to=Base32Address("0x1123456789012345678901234567890123456789", network_id=1029),
value=1,
nonce=1,
value=777,
to="de0b295669a9fd93d5f28d9ec85e40f4cb697bae",
data=Web3.to_hex("For u EthDev")
gas=1,
gasPrice=1,
storageLimit=1,
epochHeight=1,
chainId=1,
data="".encode("utf-8")
).serialize()

# Send the sign device instruction.
Expand Down Expand Up @@ -103,13 +116,15 @@ def test_sign_tx_long_tx(backend, scenario_navigator, firmware, navigator):
_, public_key, _, _ = unpack_get_public_key_response(rapdu.data)

transaction = Transaction(
to=Base32Address("0x1123456789012345678901234567890123456789", network_id=1029),
value=1,
nonce=1,
value=666,
to="de0b295669a9fd93d5f28d9ec85e40f4cb697bae",
data=Web3.to_hex("This is a very long data. "
"It will force the app client to send the serialized transaction to be sent in chunk. "
"As the maximum chunk size is 255 bytes we will make this data greater than 255 characters. "
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam.")
gas=1,
gasPrice=1,
storageLimit=1,
epochHeight=1,
chainId=1,
data="".encode("utf-8") # todo this should be a long string
).serialize()

# Enable display of transaction data (NBGL devices only)
Expand Down Expand Up @@ -143,10 +158,15 @@ def test_sign_tx_refused(backend, scenario_navigator):
_, pub_key, _, _ = unpack_get_public_key_response(rapdu.data)

transaction = Transaction(
to=Base32Address("0x1123456789012345678901234567890123456789", network_id=1029),
value=1,
nonce=1,
value=666,
to="de0b295669a9fd93d5f28d9ec85e40f4cb697bae",
data=Web3.to_hex("This transaction will be refused by the user")
gas=1,
gasPrice=1,
storageLimit=1,
epochHeight=1,
chainId=1,
data="This transaction will be refused by the user".encode("utf-8") # todo this should be a long string
).serialize()

with pytest.raises(ExceptionRAPDU) as e:
Expand Down

0 comments on commit e828ae5

Please sign in to comment.