diff --git a/main.py b/main.py deleted file mode 100644 index 09726f30..00000000 --- a/main.py +++ /dev/null @@ -1,4 +0,0 @@ -from tests.application_client.transaction import Transaction - -tx = Transaction(nonce=1, value=777, to="de0b295669a9fd93d5f28d9ec85e40f4cb697bae", maxPriorityFeePerGas=1000000000, maxFeePerGas=1000000000, gas=1000000, storageLimit=1000000, epochHeight=1000000, chainId=1, data="For u EthDev".encode("utf-8")) -print(tx.serialize()) diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/requirements.txt b/tests/requirements.txt index efe0fd7f..9d39d4d7 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -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 diff --git a/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png b/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png index e90e5385..c4c02106 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png and b/tests/snapshots/nanosp/test_sign_tx_long_tx/00001.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_long_tx/00002.png b/tests/snapshots/nanosp/test_sign_tx_long_tx/00002.png index 4aaa4bc3..6724a60b 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_long_tx/00002.png and b/tests/snapshots/nanosp/test_sign_tx_long_tx/00002.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_long_tx/00003.png b/tests/snapshots/nanosp/test_sign_tx_long_tx/00003.png index 609903f2..645b45de 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_long_tx/00003.png and b/tests/snapshots/nanosp/test_sign_tx_long_tx/00003.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_long_tx/00004.png b/tests/snapshots/nanosp/test_sign_tx_long_tx/00004.png index 16fcf14e..53ae6519 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_long_tx/00004.png and b/tests/snapshots/nanosp/test_sign_tx_long_tx/00004.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_long_tx/00005.png b/tests/snapshots/nanosp/test_sign_tx_long_tx/00005.png index b170a76f..69a5d2c8 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_long_tx/00005.png and b/tests/snapshots/nanosp/test_sign_tx_long_tx/00005.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00001.png b/tests/snapshots/nanosp/test_sign_tx_refused/00001.png index e90e5385..c4c02106 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_refused/00001.png and b/tests/snapshots/nanosp/test_sign_tx_refused/00001.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00002.png b/tests/snapshots/nanosp/test_sign_tx_refused/00002.png index 4aaa4bc3..6724a60b 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_refused/00002.png and b/tests/snapshots/nanosp/test_sign_tx_refused/00002.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00003.png b/tests/snapshots/nanosp/test_sign_tx_refused/00003.png index 468b7ae4..f18377d6 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_refused/00003.png and b/tests/snapshots/nanosp/test_sign_tx_refused/00003.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00004.png b/tests/snapshots/nanosp/test_sign_tx_refused/00004.png index 53ae6519..d39b1a00 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_refused/00004.png and b/tests/snapshots/nanosp/test_sign_tx_refused/00004.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00005.png b/tests/snapshots/nanosp/test_sign_tx_refused/00005.png index c9222461..53ae6519 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_refused/00005.png and b/tests/snapshots/nanosp/test_sign_tx_refused/00005.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00006.png b/tests/snapshots/nanosp/test_sign_tx_refused/00006.png index 69a5d2c8..c9222461 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_refused/00006.png and b/tests/snapshots/nanosp/test_sign_tx_refused/00006.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_refused/00007.png b/tests/snapshots/nanosp/test_sign_tx_refused/00007.png new file mode 100644 index 00000000..69a5d2c8 Binary files /dev/null and b/tests/snapshots/nanosp/test_sign_tx_refused/00007.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png b/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png index 568b789b..c4c02106 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png and b/tests/snapshots/nanosp/test_sign_tx_short_tx/00001.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_short_tx/00002.png b/tests/snapshots/nanosp/test_sign_tx_short_tx/00002.png index 4aaa4bc3..6724a60b 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_short_tx/00002.png and b/tests/snapshots/nanosp/test_sign_tx_short_tx/00002.png differ diff --git a/tests/snapshots/nanosp/test_sign_tx_short_tx/00003.png b/tests/snapshots/nanosp/test_sign_tx_short_tx/00003.png index 3521e3ab..645b45de 100644 Binary files a/tests/snapshots/nanosp/test_sign_tx_short_tx/00003.png and b/tests/snapshots/nanosp/test_sign_tx_short_tx/00003.png differ diff --git a/tests/test_sign_cmd.py b/tests/test_sign_cmd.py index 4b98038e..753e41d0 100644 --- a/tests/test_sign_cmd.py +++ b/tests/test_sign_cmd.py @@ -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 @@ -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"): @@ -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. @@ -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) @@ -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: