Beispiel #1
0
 def test_text_memo_toolong(self):
     memo_text = "Out, out, brief candle, life is but a walking shadow."
     length = len(memo_text)
     with pytest.raises(
             NotValidParamError,
             match="Text should be <= 28 bytes \(ascii encoded\). "
             "Got {}".format(str(length))):
         TextMemo(memo_text)
Beispiel #2
0
 def test_memo_xdr(self):
     xdr_string = b'AAAAAQAAAA1oZXksIHN0ZWxsYXIhAAAA'
     xdr_memo = TextMemo('hey, stellar!').xdr()
     assert xdr_string == xdr_memo
Beispiel #3
0
 def test_text_memo_wrong_value(self):
     memo_text = ("stellar", )
     with pytest.raises(
             NotValidParamError,
             match='Expects string type got a {}'.format(type(memo_text))):
         TextMemo(memo_text)
Beispiel #4
0
 def test_text_memo(self):
     memo_text = "Hello, world!"
     memo = TextMemo(memo_text)
     if sys.version_info.major >= 3:
         memo_text = bytearray(memo_text, encoding='utf-8')
     self.__asset_memo('text', memo_text, memo)
Beispiel #5
0
# coding: utf-8
import sys
import os
import binascii

import pytest

from kin_base.exceptions import NotValidParamError
from kin_base.memo import (
    NoneMemo, TextMemo, HashMemo, IdMemo, RetHashMemo, xdr_to_memo
)
from kin_base.stellarxdr import Xdr


@pytest.mark.parametrize("memo_obj", [
    TextMemo("Hello, Stellar"),
    NoneMemo(),
    IdMemo(31415926535),
])
def test_xdr_to_memo(memo_obj):
    xdr_obj = memo_obj.to_xdr_object()
    restored_obj = xdr_to_memo(xdr_obj)
    assert memo_obj == restored_obj


class TestMemo:
    def test_none_memo(self):
        memo = NoneMemo()
        self.__asset_memo('none', None, memo)

    def test_text_memo(self):
Alice = Keypair.from_seed(alice_seed)
horizon = horizon_testnet()  # for TESTNET
# horizon = horizon_livenet() # for LIVENET

# create op
payment_op = Payment(
    # source=Alice.address().decode(),
    destination=bob_address,
    asset=Asset('XLM'),
    amount='10.5')

set_home_domain_op = SetOptions(home_domain='fed.network')

# create a memo
msg = TextMemo('Buy yourself a beer!')

# get sequence of Alice
# Python 3
sequence = horizon.account(Alice.address().decode('utf-8')).get('sequence')
# Python 2
# sequence = horizon.account(Alice.address()).get('sequence')

operations = [payment_op, set_home_domain_op]
# construct Tx
tx = Transaction(
    source=Alice.address().decode(),
    sequence=int(sequence),
    # time_bounds = {'minTime': 1531000000, 'maxTime': 1531234600},
    memo=msg,
    fee=100 * len(operations),