-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error code APPLICATION_NOT_INSTALLED when the CAL requests an app…
…lication that is not installed
- Loading branch information
1 parent
6deb77c
commit 25975f3
Showing
8 changed files
with
119 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
from ragger.utils import RAPDU, prefix_with_len, create_currency_config | ||
from ragger.error import ExceptionRAPDU | ||
|
||
from .apps.exchange import ExchangeClient, Rate, SubCommand, Errors, Command, P2_EXTEND, P2_MORE, EXCHANGE_CLASS | ||
from .apps.exchange_transaction_builder import get_partner_curve, LEGACY_SUBCOMMANDS, ALL_SUBCOMMANDS, NEW_SUBCOMMANDS, get_credentials, craft_and_sign_tx | ||
from .apps.signing_authority import SigningAuthority, LEDGER_SIGNER | ||
from .apps import cal as cal | ||
from .apps.ethereum import ETC_PACKED_DERIVATION_PATH | ||
|
||
# This does not exist | ||
CURRENCY_TO = cal.CurrencyConfiguration(ticker="PSM", | ||
conf=create_currency_config("PSM", "PSM"), | ||
packed_derivation_path=ETC_PACKED_DERIVATION_PATH) | ||
CURRENCY_FROM = cal.ETH_CURRENCY_CONFIGURATION | ||
|
||
# Some valid infos for TX. Content is irrelevant for the test | ||
|
||
SWAP_TX_INFOS = { | ||
"payin_address": b"0xd692Cb1346262F584D17B4B470954501f6715a82", | ||
"payin_extra_id": b"", | ||
"refund_address": b"0xDad77910DbDFdE764fC21FCD4E74D71bBACA6D8D", | ||
"refund_extra_id": b"", | ||
"payout_address": b"bc1qqtl9jlrwcr3fsfcjj2du7pu6fcgaxl5dsw2vyg", | ||
"payout_extra_id": b"", | ||
"currency_from": CURRENCY_FROM.ticker, | ||
"currency_to": CURRENCY_TO.ticker, | ||
"amount_to_provider": bytes.fromhex("013fc3a717fb5000"), | ||
"amount_to_wallet": b"\x0b\xeb\xc2\x00", | ||
} | ||
FEES = 100 | ||
|
||
@pytest.mark.use_on_backend("ledgerwallet") | ||
def test_missing_application(backend): | ||
ex = ExchangeClient(backend, Rate.FIXED, SubCommand.SWAP_NG) | ||
partner = SigningAuthority(curve=get_partner_curve(SubCommand.SWAP_NG), name="Name") | ||
transaction_id = ex.init_transaction().data | ||
credentials = get_credentials(SubCommand.SWAP_NG, partner) | ||
ex.set_partner_key(credentials) | ||
ex.check_partner_key(LEDGER_SIGNER.sign(credentials)) | ||
tx, tx_signature = craft_and_sign_tx(SubCommand.SWAP_NG, SWAP_TX_INFOS, transaction_id, FEES, partner) | ||
ex.process_transaction(tx) | ||
ex.check_transaction_signature(tx_signature) | ||
to_configuration = CURRENCY_TO.get_conf_for_ticker() | ||
with pytest.raises(ExceptionRAPDU) as e: | ||
ex.check_payout_address(to_configuration) | ||
assert e.value.status == Errors.APPLICATION_NOT_INSTALLED |