Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #76 from iotaledger/release/2.0.0
Browse files Browse the repository at this point in the history
Release/2.0.0
todofixthis authored Oct 3, 2017
2 parents 220c1e0 + 2400d21 commit d69b5c9
Showing 13 changed files with 346 additions and 203 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ deploy:
python: '3.6'
tags: true
provider: pypi
distribution: 'bdist_wheel sdist'
distributions: 'bdist_wheel sdist'
skip_upload_docs: true
user: phx
password:
14 changes: 3 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
@@ -4,10 +4,6 @@
=====
PyOTA
=====
.. warning::
⚠️ This is pre-release software; it may have performance or stability issues.
Please do not use this software on mainnet until v2.0.0 stable is released. ⚠️

This is the official Python library for the IOTA Core.

It implements both the `official API`_, as well as newly-proposed functionality
@@ -32,13 +28,9 @@ PyOTA is compatible with Python 3.6, 3.5 and 2.7.
============
Installation
============
.. warning::
⚠️ This is pre-release software; it may have performance or stability issues.
Please do not use this software on mainnet until v2.0.0 stable is released. ⚠️

To install the latest version::

pip install --pre pyota
pip install pyota

Optional C Extension
====================
@@ -47,7 +39,7 @@ cryptography features significantly (speedups of **60x** are common!).

To install this extension, use the following command::

pip install --pre pyota[ccurl]
pip install pyota[ccurl]


Installing from Source
@@ -75,7 +67,7 @@ For the full documentation of this library, please refer to the
`official API`_


.. _Create virtualenv: https://virtualenvwrapper.readthedocs.io/
.. _Create virtualenv: https://realpython.com/blog/python/python-virtual-environments-a-primer/
.. _PyOTA Bug Tracker: https://github.com/iotaledger/iota.lib.py/issues
.. _Slack: https://slack.iota.org/
.. _dedicated forum: https://forum.iota.org/
2 changes: 1 addition & 1 deletion iota/commands/extended/replay_bundle.py
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ def _execute(self, request):
minWeightMagnitude = min_weight_magnitude,


trytes = bundle.as_tryte_strings(head_to_tail=True),
trytes = bundle.as_tryte_strings(),
)


2 changes: 1 addition & 1 deletion iota/json.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

from abc import ABCMeta, abstractmethod as abstract_method
from json.encoder import JSONEncoder as BaseJsonEncoder
from typing import Mapping, Iterable
from typing import Iterable, Mapping, Text

from six import with_metaclass

110 changes: 88 additions & 22 deletions iota/transaction/base.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
from iota.crypto import Curl, HASH_LENGTH
from iota.json import JsonSerializable
from iota.transaction.types import BundleHash, Fragment, TransactionHash, \
TransactionTrytes
TransactionTrytes, Nonce
from iota.types import Address, Hash, Tag, TryteString, TrytesCompatible, \
int_from_trits, trits_from_int

@@ -53,14 +53,18 @@ def from_tryte_string(cls, trytes, hash_=None):
signature_message_fragment = Fragment(tryte_string[0:2187]),
address = Address(tryte_string[2187:2268]),
value = int_from_trits(tryte_string[2268:2295].as_trits()),
tag = Tag(tryte_string[2295:2322]),
legacy_tag = Tag(tryte_string[2295:2322]),
timestamp = int_from_trits(tryte_string[2322:2331].as_trits()),
current_index = int_from_trits(tryte_string[2331:2340].as_trits()),
last_index = int_from_trits(tryte_string[2340:2349].as_trits()),
bundle_hash = BundleHash(tryte_string[2349:2430]),
trunk_transaction_hash = TransactionHash(tryte_string[2430:2511]),
branch_transaction_hash = TransactionHash(tryte_string[2511:2592]),
nonce = Hash(tryte_string[2592:2673]),
tag = Tag(tryte_string[2592:2619]),
attachment_timestamp = int_from_trits(tryte_string[2619:2628].as_trits()),
attachment_timestamp_lower_bound = int_from_trits(tryte_string[2628:2637].as_trits()),
attachment_timestamp_upper_bound = int_from_trits(tryte_string[2637:2646].as_trits()),
nonce = Nonce(tryte_string[2646:2673]),
)

def __init__(
@@ -69,16 +73,20 @@ def __init__(
signature_message_fragment,
address,
value,
tag,
timestamp,
current_index,
last_index,
bundle_hash,
trunk_transaction_hash,
branch_transaction_hash,
tag,
attachment_timestamp,
attachment_timestamp_lower_bound,
attachment_timestamp_upper_bound,
nonce,
legacy_tag = None
):
# type: (Optional[TransactionHash], Optional[Fragment], Address, int, Optional[Tag], int, Optional[int], Optional[int], Optional[BundleHash], Optional[TransactionHash], Optional[TransactionHash], Optional[Hash]) -> None
# type: (Optional[TransactionHash], Optional[Fragment], Address, int, int, Optional[int], Optional[int], Optional[BundleHash], Optional[TransactionHash], Optional[TransactionHash], Optional[Tag], Optional[int], Optional[int], Optional[int] Optional[Hash]) -> None
self.hash = hash_ # type: Optional[TransactionHash]
"""
Transaction ID, generated by taking a hash of the transaction
@@ -104,12 +112,12 @@ def __init__(
Can be negative (i.e., for spending inputs).
"""

self.tag = tag # type: Optional[Tag]
self._legacy_tag = legacy_tag # type: Optional[Tag]
"""
Optional classification tag applied to this transaction.
Optional classification legacy_tag applied to this transaction.
"""

self.nonce = nonce # type: Optional[Hash]
self.nonce = nonce # type: Optional[Nonce]
"""
Unique value used to increase security of the transaction hash.
"""
@@ -154,6 +162,17 @@ def __init__(
The branch transaction generally has no significance.
"""

self.tag = tag # type: Optional[Tag]
"""
Optional classification tag applied to this transaction.
"""

self.attachment_timestamp = attachment_timestamp # type: int

self.attachment_timestamp_lower_bound = attachment_timestamp_lower_bound # type: int

self.attachment_timestamp_upper_bound = attachment_timestamp_upper_bound # type: int

self.signature_message_fragment = signature_message_fragment # type: Optional[Fragment]
"""
@@ -227,6 +246,36 @@ def last_index_as_trytes(self):
"""
# Note that we are padding to 27 _trits_.
return TryteString.from_trits(trits_from_int(self.last_index, pad=27))

@property
def attachment_timestamp_as_trytes(self):
# type: () -> TryteString
"""
Returns a TryteString representation of the transaction's
attachment timestamp.
"""
#Note that we are padding to 27 _trits_.
return TryteString.from_trits(trits_from_int(self.attachment_timestamp, pad=27))

@property
def attachment_timestamp_lower_bound_as_trytes(self):
# type: () -> TryteString
"""
Returns a TryteString representation of the transaction's
attachment timestamp lower bound.
"""
#Note that we are padding to 27 _trits_.
return TryteString.from_trits(trits_from_int(self.attachment_timestamp_lower_bound, pad=27))

@property
def attachment_timestamp_upper_bound_as_trytes(self):
# type: () -> TryteString
"""
Returns a TryteString representation of the transaction's
attachment timestamp upper bound.
"""
#Note that we are padding to 27 _trits_.
return TryteString.from_trits(trits_from_int(self.attachment_timestamp_upper_bound, pad=27))

def as_json_compatible(self):
# type: () -> dict
@@ -237,18 +286,22 @@ def as_json_compatible(self):
- :py:class:`iota.json.JsonEncoder`.
"""
return {
'hash_': self.hash,
'signature_message_fragment': self.signature_message_fragment,
'address': self.address,
'value': self.value,
'tag': self.tag,
'timestamp': self.timestamp,
'current_index': self.current_index,
'last_index': self.last_index,
'bundle_hash': self.bundle_hash,
'trunk_transaction_hash': self.trunk_transaction_hash,
'branch_transaction_hash': self.branch_transaction_hash,
'nonce': self.nonce,
'hash_': self.hash,
'signature_message_fragment': self.signature_message_fragment,
'address': self.address,
'value': self.value,
'legacy_tag': self.legacy_tag,
'timestamp': self.timestamp,
'current_index': self.current_index,
'last_index': self.last_index,
'bundle_hash': self.bundle_hash,
'trunk_transaction_hash': self.trunk_transaction_hash,
'branch_transaction_hash': self.branch_transaction_hash,
'tag': self.tag,
'attachment_timestamp': self.attachment_timestamp,
'attachment_timestamp_lower_bound': self.attachment_timestamp_lower_bound,
'attachment_timestamp_upper_bound': self.attachment_timestamp_upper_bound,
'nonce': self.nonce,
}

def as_tryte_string(self):
@@ -260,13 +313,17 @@ def as_tryte_string(self):
self.signature_message_fragment
+ self.address.address
+ self.value_as_trytes
+ self.tag
+ self.legacy_tag
+ self.timestamp_as_trytes
+ self.current_index_as_trytes
+ self.last_index_as_trytes
+ self.bundle_hash
+ self.trunk_transaction_hash
+ self.branch_transaction_hash
+ self.tag
+ self.attachment_timestamp_as_trytes
+ self.attachment_timestamp_lower_bound_as_trytes
+ self.attachment_timestamp_upper_bound_as_trytes
+ self.nonce
)

@@ -279,11 +336,20 @@ def get_signature_validation_trytes(self):
return (
self.address.address
+ self.value_as_trytes
+ self.tag
+ self.legacy_tag
+ self.timestamp_as_trytes
+ self.current_index_as_trytes
+ self.last_index_as_trytes
)

@property
def legacy_tag(self):
# type: () -> Tag
"""
Return the legacy tag of the transaction.
If no legacy tag was set, returns the tag instead.
"""
return self._legacy_tag or self.tag


class Bundle(JsonSerializable, Sequence[Transaction]):
29 changes: 16 additions & 13 deletions iota/transaction/creation.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
from iota.crypto.types import PrivateKey
from iota.exceptions import with_context
from iota.transaction.base import Bundle, Transaction
from iota.transaction.types import BundleHash, Fragment, TransactionHash
from iota.transaction.types import BundleHash, Fragment, TransactionHash, Nonce
from iota.transaction.utils import get_current_timestamp
from iota.types import Address, Hash, Tag, TryteString

@@ -36,23 +36,26 @@ def __init__(self, address, value, tag=None, message=None, timestamp=None):
timestamp = get_current_timestamp()

super(ProposedTransaction, self).__init__(
address = address,
tag = Tag(b'') if tag is None else tag,
timestamp = timestamp,
value = value,
address = address,
tag = Tag(b'') if tag is None else tag,
timestamp = timestamp,
value = value,

# These values will be populated when the bundle is finalized.
bundle_hash = None,
current_index = None,
hash_ = None,
last_index = None,
signature_message_fragment = None,
bundle_hash = None,
current_index = None,
hash_ = None,
last_index = None,
signature_message_fragment = None,
attachment_timestamp = 0,
attachment_timestamp_lower_bound = 0,
attachment_timestamp_upper_bound = 0,

# These values start out empty; they will be populated when the
# node does PoW.
branch_transaction_hash = TransactionHash(b''),
nonce = Hash(b''),
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
nonce = Nonce(b''),
trunk_transaction_hash = TransactionHash(b''),
)

self.message = TryteString(b'') if message is None else message
23 changes: 23 additions & 0 deletions iota/transaction/types.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
'Fragment',
'TransactionHash',
'TransactionTrytes',
'Nonce'
]


@@ -72,3 +73,25 @@ def __init__(self, trytes):
'trytes': trytes,
},
)

class Nonce(TryteString):
"""
A TryteString that acts as a transaction nonce.
"""
LEN = 27

def __init__(self, trytes):
# type: (TrytesCompatible) -> None
super(Nonce, self).__init__(trytes, pad=self.LEN)

if len(self._trytes) > self.LEN:
raise with_context(
exc = ValueError('{cls} values must be {len} trytes long.'.format(
cls = type(self).__name__,
len = self.LEN
)),

context = {
'trytes': trytes,
},
)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
name = 'PyOTA',
description = 'IOTA API library for Python',
url = 'https://github.com/iotaledger/iota.lib.py',
version = '2.0.0b2',
version = '2.0.0',

long_description = long_description,

@@ -66,7 +66,7 @@
license = 'MIT',

classifiers = [
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
30 changes: 16 additions & 14 deletions test/commands/extended/get_bundles_test.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
from filters.test import BaseFilterTestCase

from iota import Address, BadApiResponse, Bundle, BundleHash, Fragment, Hash, \
Iota, Tag, Transaction, TransactionHash, TransactionTrytes
Iota, Tag, Transaction, TransactionHash, TransactionTrytes, Nonce
from iota.adapter import MockAdapter
from iota.commands.extended.get_bundles import GetBundlesCommand
from iota.filters import Trytes
@@ -141,21 +141,24 @@ def test_single_transaction(self):
"""
transaction =\
Transaction(
current_index = 0,
last_index = 0,
tag = Tag(b''),
timestamp = 1484960990,
value = 0,
current_index = 0,
last_index = 0,
tag = Tag(b''),
timestamp = 1484960990,
value = 0,
attachment_timestamp = 1484960990,
attachment_timestamp_lower_bound = 12,
attachment_timestamp_upper_bound = 0,

# These values are not relevant for 0-value transactions.
nonce = Hash(b''),
nonce = Nonce(b''),
signature_message_fragment = Fragment(b''),

# This value is computed automatically, so it has to be real.
hash_ =
TransactionHash(
b'UGQBSMKGNXXWDCS9XZCFTPUXFADCT9I9KCNQGUXK'
b'NDJDUXLWODOVJQWJHCLWTODAELDXGL9SMQYQZFWHE',
b'XPJIYZWPF9LBCYZPNBFARDRCSUGJGF9TWZT9K9PX'
b'VYDFPZOZBGXUCKLTJEUCFBEKQQ9VCSQVQDMMJQAY9',
),

address =
@@ -238,8 +241,8 @@ def test_multiple_transactions(self):
b'999999999999999999999999999999999999999999999999999999999999999999'
b'999999999999999999999999999999999999999999999999999999999999999999'
b'999999999WUQXEGBVIECGIWO9IGSYKWWPYCIVUJJGSJPWGIAFJPYSF9NSQOHWAHS9P'
b'9PWQHOBXNNQIF9IRHVQXKPZW999999999999999999999999999999999999999999'
b'999999999999HNLFMVD99A99999999A99999999PDQWLVVDPUU9VIBODGMRIAZPGQX'
b'9PWQHOBXNNQIF9IRHVQXKPZW999999999999999999999999999XZUIENOTTBKJMDP'
b'RXWGQYG9PWGTHNLFMVD99A99999999A99999999PDQWLVVDPUU9VIBODGMRIAZPGQX'
b'DOGSEXIHKIBWSLDAWUKZCZMK9Z9YZSPCKBDJSVDPRQLJSTKUMTNVSXBGUEHHGAIWWQ'
b'BCJZHZAQOWZMAIDAFUZBVMUVPWQJLUGGQKNKLMGTWXXNZKUCBJLEDAMYVRGABAWBY9'
b'999MYIYBTGIOQYYZFJBLIAWMPSZEFFTXUZPCDIXSLLQDQSFYGQSQOGSPKCZNLVSZ9L'
@@ -285,8 +288,8 @@ def test_multiple_transactions(self):
b'999999999999999999999999999999999999999999999999999999999999999999'
b'999999999999999999999999999999999999999999999999999999999999999999'
b'999999999999999999999999999999999999999999999999999999999999999999'
b'999999999999999999999999999999999999999999999999999999999999999999'
b'999999999999HNLFMVD99999999999A99999999PDQWLVVDPUU9VIBODGMRIAZPGQX'
b'999999999999999999999999999999999999999999999999999SYRABNN9JD9PNDL'
b'IKUNCECUELTOHNLFMVD99999999999A99999999PDQWLVVDPUU9VIBODGMRIAZPGQX'
b'DOGSEXIHKIBWSLDAWUKZCZMK9Z9YZSPCKBDJSVDPRQLJSTKUMTNVSXFSEWUNJOEGNU'
b'I9QOCRFMYSIFAZLJHKZBPQZZYFG9ORYCRDX9TOMJPFCRB9R9KPUUGFPVOWYXFIWEW9'
b'999BGUEHHGAIWWQBCJZHZAQOWZMAIDAFUZBVMUVPWQJLUGGQKNKLMGTWXXNZKUCBJL'
@@ -353,7 +356,6 @@ def test_multiple_transactions(self):
b'DRXICGYDGSVPXFTILFFGAPICYHGGJ9OHXINFX9999'
),
)

self.maxDiff = None
self.assertListEqual(
response['bundles'][0].as_json_compatible(),
9 changes: 9 additions & 0 deletions test/commands/extended/get_transfers_test.py
Original file line number Diff line number Diff line change
@@ -410,6 +410,9 @@ def create_generator(ag, start, step=1):
bundle_hash = None,
trunk_transaction_hash = None,
branch_transaction_hash = None,
attachment_timestamp = 1483033814,
attachment_timestamp_lower_bound = 12,
attachment_timestamp_upper_bound = 0,
nonce = None,
)
])
@@ -526,6 +529,9 @@ def create_generator(ag, start, step=1):
bundle_hash = None,
trunk_transaction_hash = None,
branch_transaction_hash = None,
attachment_timestamp = 1483033814,
attachment_timestamp_lower_bound = 12,
attachment_timestamp_upper_bound = 0,
nonce = None,
)
])
@@ -601,6 +607,9 @@ def create_generator(ag, start, step=1):
bundle_hash = None,
trunk_transaction_hash = None,
branch_transaction_hash = None,
attachment_timestamp = 1483033814,
attachment_timestamp_lower_bound = 12,
attachment_timestamp_upper_bound = 0,
nonce = None,
)
])
13 changes: 6 additions & 7 deletions test/commands/extended/prepare_transfer_test.py

Large diffs are not rendered by default.

87 changes: 52 additions & 35 deletions test/commands/extended/replay_bundle_test.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
from six import binary_type

from iota import Address, Bundle, BundleHash, Fragment, Hash, Iota, Tag, \
Transaction, TransactionHash
Transaction, TransactionHash, Nonce
from iota.adapter import MockAdapter
from iota.commands.extended.replay_bundle import ReplayBundleCommand
from iota.filters import Trytes
@@ -343,9 +343,8 @@ def test_happy_path(self):
),

nonce =
Hash(
b'LIJVXBVTYMEEPCKJRIQTGAKWJRAMYNPJEGHEWAUL'
b'XPBBUQPCJTJPRZTISQPJRJGMSBGQLER9OXYQXFGQO'
Nonce(
b'LIJVXBVTYMEEPCKJRIQTGAKWJRA'
),

trunk_transaction_hash =
@@ -356,11 +355,14 @@ def test_happy_path(self):

signature_message_fragment = Fragment(b''),

current_index = 0,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = 1,
current_index = 0,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = 1,
attachment_timestamp = 0,
attachment_timestamp_lower_bound = 0,
attachment_timestamp_upper_bound = 0,
),

# Input #1, Part 1 of 2
@@ -390,9 +392,8 @@ def test_happy_path(self):
),

nonce =
Hash(
b'VRYLDCKEWZJXPQVSWOJVYVBJSCWZQEVKPBG9KGEZ'
b'GPRQFKFSRNBPXCSVQNJINBRNEPIKAXNHOTJFIVYJO'
Nonce(
b'VRYLDCKEWZJXPQVSWOJVYVBJSCW'
),

trunk_transaction_hash =
@@ -440,11 +441,14 @@ def test_happy_path(self):
b'G9CM9VLMQZA'
),

current_index = 1,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = -99,
current_index = 1,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = -99,
attachment_timestamp = 0,
attachment_timestamp_lower_bound = 0,
attachment_timestamp_upper_bound = 0,
),

# Input #1, Part 2 of 2
@@ -474,9 +478,8 @@ def test_happy_path(self):
),

nonce =
Hash(
b'AAKVYZOEZSOXTX9LOLHZYLNAS9CXBLSWVZQAMRGW'
b'YW9GHHMVIOHWBMTXHDBXRTF9DEFFQFQESNVJORNXK'
Nonce(
b'AAKVYZOEZSOXTX9LOLHZYLNAS9C'
),

trunk_transaction_hash =
@@ -524,11 +527,14 @@ def test_happy_path(self):
b'WVLUITJQ9JM'
),

current_index = 2,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = 0,
current_index = 2,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = 0,
attachment_timestamp = 0,
attachment_timestamp_lower_bound = 0,
attachment_timestamp_upper_bound = 0,
),

# "Change" transaction, Part 1 of 1
@@ -558,9 +564,8 @@ def test_happy_path(self):
),

nonce =
Hash(
b'TPGXQFUGNEYYFFKPFWJSXKTWEUKUFTRJCQKKXLXL'
b'PSOHBZTGIBFPGLSVRIVYAC9NZMOMZLARFZYCNNRCM'
Nonce(
b'TPGXQFUGNEYYFFKPFWJSXKTWEUK'
),

trunk_transaction_hash =
@@ -571,11 +576,14 @@ def test_happy_path(self):

signature_message_fragment = Fragment(b''),

current_index = 3,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = 98,
current_index = 3,
last_index = 3,
tag = Tag(b''),
timestamp = 1483033814,
value = 98,
attachment_timestamp = 0,
attachment_timestamp_lower_bound = 0,
attachment_timestamp_upper_bound = 0,
),
])

@@ -585,10 +593,19 @@ def test_happy_path(self):
})

send_trytes_response = {
'trytes': bundle.as_tryte_strings(head_to_tail=True),
'trytes': bundle.as_tryte_strings(),
}

mock_send_trytes = mock.Mock(return_value=send_trytes_response)
def mock_send_trytes(_,request):
"""
Ensures that the correct trytes are sent to the ``sendTrytes`` command
to replay the bundle.
References:
- https://github.com/iotaledger/iota.lib.py/issues/74
"""
self.assertEqual(request['trytes'], send_trytes_response['trytes'])
return send_trytes_response

with mock.patch(
'iota.commands.extended.get_bundles.GetBundlesCommand._execute',
224 changes: 128 additions & 96 deletions test/transaction/base_test.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
from unittest import TestCase

from iota import Address, Bundle, BundleHash, Fragment, Hash, \
Tag, Transaction, TransactionHash, TransactionTrytes
Tag, Transaction, TransactionHash, TransactionTrytes, TryteString, Nonce


class BundleTestCase(TestCase):
@@ -24,18 +24,21 @@ def setUp(self):
b'XCQANAWGJBTFWEAEQCN9WBZB9BJAIIY9UDLIGFOAA'
),

current_index = 0,
last_index = 7,
value = 0,
current_index = 0,
last_index = 7,
value = 0,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),

# This transaction has something that can't be decoded as a UTF-8
@@ -50,18 +53,21 @@ def setUp(self):
b'MHCGKEUGYFUBIARAXBFASGLCHCBEVGTBDCSAEBTBM'
),

current_index = 1,
last_index = 7,
value = 10,
current_index = 1,
last_index = 7,
value = 10,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),

# This transaction has a message that fits into a single
@@ -76,18 +82,21 @@ def setUp(self):
b'M9XADCPFJDFANCIHR9OBDHTAGGE9TGCI9EO9ZCRBN'
),

current_index = 2,
last_index = 7,
value = 20,
current_index = 2,
last_index = 7,
value = 20,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),

# This transaction has a message that spans multiple fragments.
@@ -142,13 +151,16 @@ def setUp(self):
value = 30,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),

Transaction(
@@ -173,18 +185,21 @@ def setUp(self):
b'XCQANAWGJBTFWEAEQCN9WBZB9BJAIIY9UDLIGFOAA'
),

current_index = 4,
last_index = 7,
value = 0,
current_index = 4,
last_index = 7,
value = 0,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),

# Input, Part 1 of 2
@@ -200,18 +215,21 @@ def setUp(self):
b'HDVHYHOBHGP9VCGIZHNCAAQFJGE9YHEHEFTDAGXHY'
),

current_index = 5,
last_index = 7,
value = -100,
current_index = 5,
last_index = 7,
value = -100,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),

# Input, Part 2 of 2
@@ -227,18 +245,21 @@ def setUp(self):
b'HDVHYHOBHGP9VCGIZHNCAAQFJGE9YHEHEFTDAGXHY'
),

current_index = 6,
last_index = 7,
value = 0,
current_index = 6,
last_index = 7,
value = 0,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),

# Change
@@ -254,18 +275,21 @@ def setUp(self):
b'N9ACYCP99GZBSDK9CECFI9RAIH9BRCCAHAIAWEFAN'
),

current_index = 7,
last_index = 7,
value = 40,
current_index = 7,
last_index = 7,
value = 40,

# These values are not relevant to the tests.
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Hash(b''),
tag = Tag(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
branch_transaction_hash = TransactionHash(b''),
bundle_hash = BundleHash(b''),
hash_ = TransactionHash(b''),
nonce = Nonce(b''),
timestamp = 1485020456,
trunk_transaction_hash = TransactionHash(b''),
tag = Tag(b''),
attachment_timestamp = 1485020456,
attachment_timestamp_upper_bound = 1485020456,
attachment_timestamp_lower_bound = 1485020456,
),
])

@@ -411,8 +435,8 @@ def test_from_tryte_string(self):
b'XRHWWTZFBXMPSQHEDFWZULBZFEOMNLRNIDQKDNNIELAOXOVMYEI9PGTKORV9IKTJZQ'
b'UBQAWTKBKZ9NEZHBFIMCLV9TTNJNQZUIJDFPTTCTKBJRHAITVSKUCUEMD9M9SQJ999'
b'999TKORV9IKTJZQUBQAWTKBKZ9NEZHBFIMCLV9TTNJNQZUIJDFPTTCTKBJRHAITVSK'
b'UCUEMD9M9SQJ999999999999999999999999999999999999999999999999999999'
b'999999999999999999999999999999999'
b'UCUEMD9M9SQJ999999999999999999999999999999999RKWEEVD99RKWEEVD99RKW'
b'EEVD99999999999999999999999999999'
)

transaction = Transaction.from_tryte_string(trytes)
@@ -423,8 +447,8 @@ def test_from_tryte_string(self):
transaction.hash,

Hash(
b'SYABNCYPLULQQBTDCUWJPVVMYNWHKEHGAZPKRBGE'
b'QKEHUIKJCHWGAUKLSYMDOUUBMXPKCPTNFWUFU9JKW',
b'JBVVEWEPYNZ9KRHNUUTRENXXAVXT9MKAVPAUQ9SJ'
b'NSIHDCPQM9LJHIZGXO9PIRWUUVBOXNCBE9XJGMOZF'
),
)

@@ -479,7 +503,7 @@ def test_from_tryte_string(self):
)

self.assertEqual(transaction.value, 0)
self.assertEqual(transaction.tag, Tag(b'999999999999999999999999999'))
self.assertEqual(transaction.legacy_tag, Tag(b'999999999999999999999999999'))
self.assertEqual(transaction.timestamp, 1480690413)
self.assertEqual(transaction.current_index, 1)
self.assertEqual(transaction.last_index, 1)
@@ -510,13 +534,17 @@ def test_from_tryte_string(self):
b'QZUIJDFPTTCTKBJRHAITVSKUCUEMD9M9SQJ999999'
),
)

self.assertEqual(transaction.tag, Tag(b'999999999999999999999999999'))
self.assertEqual(transaction.attachment_timestamp,1480690413)
self.assertEqual(transaction.attachment_timestamp_lower_bound,1480690413)
self.assertEqual(transaction.attachment_timestamp_upper_bound,1480690413)

self.assertEqual(
transaction.nonce,

Hash(
b'9999999999999999999999999999999999999999'
b'99999999999999999999999999999999999999999'
Nonce(
b'999999999999999999999999999'
),
)

@@ -544,8 +572,8 @@ def test_as_tryte_string(self):
transaction = Transaction(
hash_ =
TransactionHash(
b'QODOAEJHCFUYFTTPRONYSMMSFDNFWFX9UCMESVWA'
b'FCVUQYOIJGJMBMGQSFIAFQFMVECYIFXHRGHHEOTMK'
b'SYABNCYPLULQQBTDCUWJPVVMYNWHKEHGAZPKRBGE'
b'QKEHUIKJCHWGAUKLSYMDOUUBMXPKCPTNFWUFU9JKW'
),

signature_message_fragment =
@@ -588,12 +616,11 @@ def test_as_tryte_string(self):

address =
Address(
b'9999999999999999999999999999999999999999'
b'99999999999999999999999999999999999999999'
b'9999999999999999999999999999999999999999'
),

value = 0,
tag = Tag(b'999999999999999999999999999'),
timestamp = 1480690413,
current_index = 1,
last_index = 1,
@@ -615,18 +642,23 @@ def test_as_tryte_string(self):
b'TKORV9IKTJZQUBQAWTKBKZ9NEZHBFIMCLV9TTNJN'
b'QZUIJDFPTTCTKBJRHAITVSKUCUEMD9M9SQJ999999'
),

tag = Tag(b'999999999999999999999999999'),
attachment_timestamp = 1480690413,
attachment_timestamp_lower_bound = 1480690413,
attachment_timestamp_upper_bound = 1480690413,


nonce =
Hash(
b'9999999999999999999999999999999999999999'
b'99999999999999999999999999999999999999999'
Nonce(
b'999999999999999999999999999'
),
)

self.assertEqual(
transaction.as_tryte_string(),

TransactionTrytes(
TransactionTrytes(
b'GYPRVHBEZOOFXSHQBLCYW9ICTCISLHDBNMMVYD9JJHQMPQCTIQAQTJNNNJ9IDXLRCC'
b'OYOXYPCLR9PBEY9ORZIEPPDNTI9CQWYZUOTAVBXPSBOFEQAPFLWXSWUIUSJMSJIIIZ'
b'WIKIRH9GCOEVZFKNXEVCUCIIWZQCQEUVRZOCMEL9AMGXJNMLJCIA9UWGRPPHCEOPTS'
@@ -666,7 +698,7 @@ def test_as_tryte_string(self):
b'XRHWWTZFBXMPSQHEDFWZULBZFEOMNLRNIDQKDNNIELAOXOVMYEI9PGTKORV9IKTJZQ'
b'UBQAWTKBKZ9NEZHBFIMCLV9TTNJNQZUIJDFPTTCTKBJRHAITVSKUCUEMD9M9SQJ999'
b'999TKORV9IKTJZQUBQAWTKBKZ9NEZHBFIMCLV9TTNJNQZUIJDFPTTCTKBJRHAITVSK'
b'UCUEMD9M9SQJ999999999999999999999999999999999999999999999999999999'
b'999999999999999999999999999999999',
b'UCUEMD9M9SQJ999999999999999999999999999999999RKWEEVD99RKWEEVD99RKW'
b'EEVD99999999999999999999999999999'
),
)

0 comments on commit d69b5c9

Please sign in to comment.