1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

tests: ripple fix

This commit is contained in:
Tomas Susanka 2018-09-05 10:42:32 +02:00
parent 80766ca6b3
commit 6c15a41514
2 changed files with 20 additions and 9 deletions

View File

@ -19,7 +19,8 @@ from . import messages
from .protobuf import dict_to_proto
from .tools import dict_from_camelcase, expect
REQUIRED_FIELDS = ("Fee", "Sequence", "TransactionType", "Amount", "Destination")
REQUIRED_FIELDS = ("Fee", "Sequence", "TransactionType", "Payment")
REQUIRED_PAYMENT_FIELDS = ("Amount", "Destination")
@expect(messages.RippleAddress, field="address")
@ -38,6 +39,8 @@ def sign_tx(client, address_n, msg: messages.RippleSignTx):
def create_sign_tx_msg(transaction) -> messages.RippleSignTx:
if not all(transaction.get(k) for k in REQUIRED_FIELDS):
raise ValueError("Some of the required fields missing")
if not all(transaction["Payment"].get(k) for k in REQUIRED_PAYMENT_FIELDS):
raise ValueError("Some of the required payment fields missing")
if transaction["TransactionType"] != "Payment":
raise ValueError("Only Payment transaction type is supported")

View File

@ -35,8 +35,10 @@ class TestMsgRippleSignTx(TrezorTest):
msg = ripple.create_sign_tx_msg(
{
"TransactionType": "Payment",
"Destination": "rBKz5MC2iXdoS3XgnNSYmF69K1Yo4NS3Ws",
"Amount": 100000000,
"Payment": {
"Amount": 100000000,
"Destination": "rBKz5MC2iXdoS3XgnNSYmF69K1Yo4NS3Ws",
},
"Flags": 0x80000000,
"Fee": 100000,
"Sequence": 25,
@ -53,8 +55,10 @@ class TestMsgRippleSignTx(TrezorTest):
msg = ripple.create_sign_tx_msg(
{
"TransactionType": "Payment",
"Destination": "rNaqKtKrMSwpwZSzRckPf7S96DkimjkF4H",
"Amount": 1,
"Payment": {
"Amount": 1,
"Destination": "rNaqKtKrMSwpwZSzRckPf7S96DkimjkF4H",
},
"Fee": 10,
"Sequence": 1,
}
@ -70,8 +74,10 @@ class TestMsgRippleSignTx(TrezorTest):
msg = ripple.create_sign_tx_msg(
{
"TransactionType": "Payment",
"Destination": "rNaqKtKrMSwpwZSzRckPf7S96DkimjkF4H",
"Amount": 100000009,
"Payment": {
"Amount": 100000009,
"Destination": "rNaqKtKrMSwpwZSzRckPf7S96DkimjkF4H",
},
"Flags": 0,
"Fee": 100,
"Sequence": 100,
@ -92,8 +98,10 @@ class TestMsgRippleSignTx(TrezorTest):
msg = ripple.create_sign_tx_msg(
{
"TransactionType": "Payment",
"Destination": "rNaqKtKrMSwpwZSzRckPf7S96DkimjkF4H",
"Amount": 1,
"Payment": {
"Amount": 1,
"Destination": "rNaqKtKrMSwpwZSzRckPf7S96DkimjkF4H",
},
"Flags": 1,
"Fee": 1,
"Sequence": 1,