Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
test: add test_sign_wrong_pubkey_transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yf0μl committed Feb 19, 2024
1 parent f90e0cf commit a99ee72
Show file tree
Hide file tree
Showing 53 changed files with 54 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/application_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def condition_folder_name(event_index: int, additional_index: bool, condition_in
return str(event_index) + "_" + str(condition_index)
return str(event_index)


def generic_test_sign(
client: Nearbackend,
chunks: List[Union[bytes, AsyncAPDU]],
Expand All @@ -90,8 +91,8 @@ def generic_test_sign(
if isinstance(chunk_event, NavigableConditions):
for cond_index, condition in enumerate(chunk_event.value):
str_index = condition_folder_name(index, len(chunk_event.value) > 1, cond_index)
condition_folder = (
Path(test_name) / (str_index + "_" + condition.lower().replace(" ", "_"))
condition_folder = Path(test_name) / (
str_index + "_" + condition.lower().replace(" ", "_").replace("!", "_bang")
)
navigator.navigate_until_text_and_compare(
NavInsID.RIGHT_CLICK,
Expand Down
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
51 changes: 51 additions & 0 deletions tests/test_public_key_validation/test_sign_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from application_client.client import (
AsyncAPDU,
SW_OK,
NavigableConditions,
Nearbackend,
FINISH_STUB_APDU,
generic_test_sign,
)
from ragger.backend.interface import RAPDU
from ragger.backend import RaisePolicy
from ragger.navigator import Navigator


def test_sign_wrong_pubkey_transfer(firmware, backend, navigator: Navigator, test_name):
"""
Transaction {
signer_id: AccountId(
"1b11b3b31673033936ad07bddc01f9da27d974811e480fb197c799e23480a489",
),
public_key: ed25519:2pffV8fXgXUyuKdTS8Nqnvbkua16wEtTv8tdWZCpVtat,
nonce: 103595482000005,
receiver_id: AccountId(
"dc7e34eecec3096a4a661e10932834f801149c49dba9b93322f6d9de18047f9c",
),
block_hash: Cb3vKNiF3MUuVoqfjuEFCgSNPT79pbuVfXXd2RxDXc5E,
actions: [
Transfer(
TransferAction {
deposit: 150000000000000000000000,
},
),
],
}
"""
backend.raise_policy = RaisePolicy.RAISE_NOTHING
client = Nearbackend(backend)
chunks = [
AsyncAPDU(
data=bytes.fromhex(
"80028057fa8000002c8000018d8000000080000000800000014000000031623131623362333136373330333339333661643037626464633031663964613237643937343831316534383066623139376337393965323334383061343839001b11b3b31673033936ad07bddc01f9da27d974811e480fb197c799e23480a48985aae733385e00004000000064633765333465656365633330393661346136363165313039333238333466383031313439633439646261396239333332326636643964653138303437663963ac299ac1376e375cd39338d8b29225613ef947424b74a3207c1226863a72583101000000030000c071f0d12b84c31f000000000000"
),
navigable_conditions=NavigableConditions(
value=["Continue to actions", "Error!"],
),
expected_response=RAPDU(
0xB00D,
bytes(),
),
)
]
generic_test_sign(client, chunks, navigator, test_name)

0 comments on commit a99ee72

Please sign in to comment.