2018-06-27 07:20:53 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
2019-05-29 16:44:09 +00:00
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
2018-06-27 07:20:53 +00:00
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
|
|
|
|
|
|
import base64
|
2018-08-13 16:21:24 +00:00
|
|
|
|
|
|
|
from trezorlib import messages, stellar
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_stellar_parse_transaction_bytes_simple():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAAAO5/eyAAAAAA="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
tx.source_account == "GAK5MSF74TJW6GLM7NLTL76YZJKM2S4CGP3UH4REJHPHZ4YBZW2GSBPW"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.fee == 100
|
|
|
|
assert tx.sequence_number == 4294967296
|
|
|
|
assert tx.timebounds_start is None
|
|
|
|
assert tx.timebounds_end is None
|
|
|
|
assert tx.memo_type == stellar.MEMO_TYPE_NONE
|
|
|
|
assert tx.memo_text is None
|
|
|
|
assert tx.memo_id is None
|
|
|
|
assert tx.memo_hash is None
|
|
|
|
assert tx.num_operations == len(operations)
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_transaction_bytes_memo_text():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAEAAAAMZXhhbXBsZSBtZW1vAAAAAQAAAAAAAAAAAAAAAF1VZCRmsYW4QxUuniGRUdvFiSAn7EAQGlF77VygMMLgAAAAADuf3sgAAAAA"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
tx.source_account == "GAK5MSF74TJW6GLM7NLTL76YZJKM2S4CGP3UH4REJHPHZ4YBZW2GSBPW"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.fee == 100
|
|
|
|
assert tx.sequence_number == 4294967296
|
|
|
|
assert tx.timebounds_start is None
|
|
|
|
assert tx.timebounds_end is None
|
|
|
|
assert tx.memo_type == stellar.MEMO_TYPE_TEXT
|
2020-02-20 18:21:45 +00:00
|
|
|
assert tx.memo_text == "example memo"
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.memo_id is None
|
|
|
|
assert tx.memo_hash is None
|
|
|
|
assert tx.num_operations == len(operations)
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_transaction_bytes_memo_id():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAIAAAAAB1vNFQAAAAEAAAAAAAAAAAAAAABdVWQkZrGFuEMVLp4hkVHbxYkgJ+xAEBpRe+1coDDC4AAAAAA7n97IAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
tx.source_account == "GAK5MSF74TJW6GLM7NLTL76YZJKM2S4CGP3UH4REJHPHZ4YBZW2GSBPW"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.fee == 100
|
|
|
|
assert tx.sequence_number == 4294967296
|
|
|
|
assert tx.timebounds_start is None
|
|
|
|
assert tx.timebounds_end is None
|
|
|
|
assert tx.memo_type == stellar.MEMO_TYPE_ID
|
|
|
|
assert tx.memo_text is None
|
|
|
|
assert tx.memo_id == 123456789
|
|
|
|
assert tx.memo_hash is None
|
|
|
|
assert tx.num_operations == len(operations)
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_transaction_bytes_memo_hash():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAMjLtb5+r8U47tVOSsYz+PQ/ryU0gzGMnw4odB11uoRjAAAAAEAAAAAAAAAAAAAAABdVWQkZrGFuEMVLp4hkVHbxYkgJ+xAEBpRe+1coDDC4AAAAAA7n97IAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
tx.source_account == "GAK5MSF74TJW6GLM7NLTL76YZJKM2S4CGP3UH4REJHPHZ4YBZW2GSBPW"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.fee == 100
|
|
|
|
assert tx.sequence_number == 4294967296
|
|
|
|
assert tx.timebounds_start is None
|
|
|
|
assert tx.timebounds_end is None
|
|
|
|
assert tx.memo_type == stellar.MEMO_TYPE_HASH
|
|
|
|
assert tx.memo_text is None
|
|
|
|
assert tx.memo_id is None
|
|
|
|
# base-64 encoding of the raw bytes of sha256('stellar')
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
base64.b64encode(tx.memo_hash)
|
|
|
|
== b"Iy7W+fq/FOO7VTkrGM/j0P68lNIMxjJ8OKHQddbqEYw="
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.num_operations == len(operations)
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_transaction_bytes_memo_return():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAQjLtb5+r8U47tVOSsYz+PQ/ryU0gzGMnw4odB11uoRjAAAAAEAAAAAAAAAAAAAAABdVWQkZrGFuEMVLp4hkVHbxYkgJ+xAEBpRe+1coDDC4AAAAAA7n97IAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
tx.source_account == "GAK5MSF74TJW6GLM7NLTL76YZJKM2S4CGP3UH4REJHPHZ4YBZW2GSBPW"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.fee == 100
|
|
|
|
assert tx.sequence_number == 4294967296
|
|
|
|
assert tx.timebounds_start is None
|
|
|
|
assert tx.timebounds_end is None
|
|
|
|
assert tx.memo_type == stellar.MEMO_TYPE_RETURN
|
|
|
|
assert tx.memo_text is None
|
|
|
|
assert tx.memo_id is None
|
|
|
|
# base-64 encoding of the raw bytes of sha256('stellar')
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
base64.b64encode(tx.memo_hash)
|
|
|
|
== b"Iy7W+fq/FOO7VTkrGM/j0P68lNIMxjJ8OKHQddbqEYw="
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert tx.num_operations == len(operations)
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_create_account_simple():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAAAO5/eyAAAAAA="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarCreateAccountOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
2018-08-13 16:21:24 +00:00
|
|
|
assert op.new_account == "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.starting_balance == 1000333000
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_payment_native():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAAAAAAAAB3PFpgAAAAA"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarPaymentOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.asset.type == stellar.ASSET_TYPE_NATIVE
|
|
|
|
assert op.amount == 500111000
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_payment_custom4():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAABVEVTVAAAAAAphJYCwg5YNl8SPBLYehykVQ0QzSGwrg4Y1E4+Vv1qFQAAAAAdzxaYAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
|
|
|
assert op.source_account is None
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.asset.type == stellar.ASSET_TYPE_ALPHA4
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.asset.code == "TEST"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert op.asset.issuer == "GAUYJFQCYIHFQNS7CI6BFWD2DSSFKDIQZUQ3BLQODDKE4PSW7VVBKENC"
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.amount == 500111000
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_payment_custom7():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAACU0VWRU5YWAAAAAAAAAAAACmElgLCDlg2XxI8Eth6HKRVDRDNIbCuDhjUTj5W/WoVAAAAAB3PFpgAAAAA"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarPaymentOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.asset.type == stellar.ASSET_TYPE_ALPHA12
|
|
|
|
# asset codes are either 4 or 12 characters, so this will be null-padded at the end
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.asset.code == "SEVENXX\x00\x00\x00\x00\x00"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert op.asset.issuer == "GAUYJFQCYIHFQNS7CI6BFWD2DSSFKDIQZUQ3BLQODDKE4PSW7VVBKENC"
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.amount == 500111000
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_path_payment_none():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAAAAAAAHfOKn8AAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAABSlBZAAAAAADE+xa3Eb3cy85WSdqgwnUtC6UDwrC41YDANuCqe8vGxgAAAAAL68IBAAAAAAAAAAA="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarPathPaymentOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
assert op.send_asset.type == stellar.ASSET_TYPE_NATIVE
|
|
|
|
assert op.send_max == 2009999999
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.destination_asset.type == stellar.ASSET_TYPE_ALPHA4
|
|
|
|
# asset codes are either 4 or 12 characters, so this will be null-padded at the end
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.destination_asset.code == "JPY\x00"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_asset.issuer
|
|
|
|
== "GDCPWFVXCG65ZS6OKZE5VIGCOUWQXJIDYKYLRVMAYA3OBKT3ZPDMNTIJ"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
assert len(op.paths) == 0
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_path_payment_one():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAAAAAAAHfOKn8AAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAABSlBZAAAAAADE+xa3Eb3cy85WSdqgwnUtC6UDwrC41YDANuCqe8vGxgAAAAAL68IBAAAAAQAAAAFQVEgxAAAAAMz/d9fJ3rFifblw3jT7sRZv/Ja+fqLfob//aLZQRQibAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarPathPaymentOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
assert op.send_asset.type == stellar.ASSET_TYPE_NATIVE
|
|
|
|
assert op.send_max == 2009999999
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.destination_asset.type == stellar.ASSET_TYPE_ALPHA4
|
|
|
|
# asset codes are either 4 or 12 characters, so this will be null-padded at the end
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.destination_asset.code == "JPY\x00"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_asset.issuer
|
|
|
|
== "GDCPWFVXCG65ZS6OKZE5VIGCOUWQXJIDYKYLRVMAYA3OBKT3ZPDMNTIJ"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.destination_amount == 200000001
|
|
|
|
|
|
|
|
assert len(op.paths) == 1
|
|
|
|
assert op.paths[0].type == stellar.ASSET_TYPE_ALPHA4
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.paths[0].code == "PTH1"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.paths[0].issuer == "GDGP656XZHPLCYT5XFYN4NH3WELG77EWXZ7KFX5BX77WRNSQIUEJXAJK"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_manage_offer_new():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAMAAAAAAAAAAVVTRAAAAAAABkAD8fq0d+bofA1LCatUL0dCTJexnyYYd4Y1ghnNUXMAAAAAdzWUAAAKSzYAD0JAAAAAAAAAAAAAAAAA"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarManageOfferOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
|
|
|
assert op.selling_asset.type == stellar.ASSET_TYPE_NATIVE
|
|
|
|
|
|
|
|
assert op.buying_asset.type == stellar.ASSET_TYPE_ALPHA4
|
|
|
|
# asset codes are either 4 or 12 characters, so this will be null-padded at the end
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.buying_asset.code == "USD\x00"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.buying_asset.issuer
|
|
|
|
== "GADEAA7R7K2HPZXIPQGUWCNLKQXUOQSMS6YZ6JQYO6DDLAQZZVIXG74A"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
assert op.amount == 2000000000
|
|
|
|
assert op.price_n == 674614
|
|
|
|
assert op.price_d == 1000000
|
2018-06-28 02:09:14 +00:00
|
|
|
assert op.offer_id == 0 # indicates a new offer
|
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
def test_stellar_parse_operation_bytes_passive_offer_new():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAQAAAAAAAAAAVVTRAAAAAAABkAD8fq0d+bofA1LCatUL0dCTJexnyYYd4Y1ghnNUXMAAAAAdzWUAAAKSzYAD0JAAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarCreatePassiveOfferOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
|
|
|
assert op.selling_asset.type == stellar.ASSET_TYPE_NATIVE
|
|
|
|
|
|
|
|
assert op.buying_asset.type == stellar.ASSET_TYPE_ALPHA4
|
|
|
|
# asset codes are either 4 or 12 characters, so this will be null-padded at the end
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.buying_asset.code == "USD\x00"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.buying_asset.issuer
|
|
|
|
== "GADEAA7R7K2HPZXIPQGUWCNLKQXUOQSMS6YZ6JQYO6DDLAQZZVIXG74A"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
assert op.amount == 2000000000
|
|
|
|
assert op.price_n == 674614
|
|
|
|
assert op.price_d == 1000000
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_set_options_inflation():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUAAAABAAAAAAt5i66vbwH70/2M4Oj0rQW81SNLAjfOsMV2bavzocXhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarSetOptionsOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.inflation_destination_account
|
|
|
|
== "GAFXTC5OV5XQD66T7WGOB2HUVUC3ZVJDJMBDPTVQYV3G3K7TUHC6CLBR"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_change_trust_add():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAYAAAABVVNEAAAAAACkn7CoQZEWAlyO6z6VBUAddrDDR078TtLt/nP/hZJ9KQAAAAJUC+QAAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarChangeTrustOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
|
|
|
assert op.asset.type == stellar.ASSET_TYPE_ALPHA4
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.asset.code == "USD\x00"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert op.asset.issuer == "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
assert op.limit == 10000000000
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_allow_trust_allow():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAcAAAAAZ0Me3OnxI2tuaC8qt95THF1fuB42qARTnP2ookJapQUAAAABSlBZAAAAAAEAAAAA"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarAllowTrustOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
|
|
|
assert op.asset_type == stellar.ASSET_TYPE_ALPHA4
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.asset_code == "JPY\x00"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.trusted_account == "GBTUGHW45HYSG23ONAXSVN66KMOF2X5YDY3KQBCTTT62RISCLKSQLYF4"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_account_merge_simple():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAgAAAAAXVVkJGaxhbhDFS6eIZFR28WJICfsQBAaUXvtXKAwwuAAAAAA"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarAccountMergeOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
|
|
|
op.destination_account
|
|
|
|
== "GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V"
|
|
|
|
)
|
2018-06-27 07:20:53 +00:00
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_manage_data_set_simple():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAoAAAAJdGVzdCBkYXRhAAAAAAAAAQAAAARhc2RmAAAAAA=="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarManageDataOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
2020-02-20 18:21:45 +00:00
|
|
|
assert op.key == "test data"
|
2018-08-13 16:21:24 +00:00
|
|
|
assert op.value == b"asdf"
|
2018-06-27 07:20:53 +00:00
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
|
2018-06-27 07:20:53 +00:00
|
|
|
def test_stellar_parse_operation_bytes_bump_sequence_simple():
|
2018-08-13 16:21:24 +00:00
|
|
|
b64 = b"AAAAABXWSL/k028ZbPtXNf/YylTNS4Iz90PyJEnefPMBzbRpAAAAZAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAsAAAAASZYC0gAAAAA="
|
2018-06-27 07:20:53 +00:00
|
|
|
|
|
|
|
tx, operations = stellar.parse_transaction_bytes(base64.b64decode(b64))
|
|
|
|
op = operations[0]
|
|
|
|
|
2018-06-28 02:20:23 +00:00
|
|
|
assert isinstance(op, messages.StellarBumpSequenceOp)
|
2018-06-27 07:20:53 +00:00
|
|
|
assert op.source_account is None
|
|
|
|
|
2018-06-28 02:09:14 +00:00
|
|
|
assert op.bump_to == 1234567890
|