tests: ripple fix

pull/25/head
Tomas Susanka 6 years ago
parent 80766ca6b3
commit 6c15a41514

@ -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")

@ -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,

Loading…
Cancel
Save