Ejemplo n.º 1
0
    def test_pass_bundles_only(self):
        """
    The request only includes bundles.
    """
        request = {
            'bundles': [
                BundleHash(self.trytes1),
                BundleHash(self.trytes2),
            ],
        }

        filter_ = self._filter(request)

        self.assertFilterPasses(filter_)
        self.assertDictEqual(
            filter_.cleaned_data,
            {
                'bundles': [
                    text_type(BundleHash(self.trytes1)),
                    text_type(BundleHash(self.trytes2)),
                ],

                # Null criteria are not included in the request.
                # https://github.com/iotaledger/iota.lib.py/issues/96
                # 'addresses':  [],
                # 'approvees':  [],
                # 'tags':       [],
            },
        )
Ejemplo n.º 2
0
    def test_pass_all_parameters(self):
        """
    The request contains valid values for all parameters.
    """
        # Raw trytes are extracted to match the IRI's JSON protocol.
        request = {
            'bundles': [
                text_type(BundleHash(self.trytes1)),
                text_type(BundleHash(self.trytes2)),
            ],
            'addresses': [
                text_type(Address(self.trytes1)),
                text_type(Address(self.trytes2)),
            ],
            'tags': [
                text_type(Tag(self.trytes1)),
                text_type(Tag(self.trytes3)),
            ],
            'approvees': [
                text_type(TransactionHash(self.trytes1)),
                text_type(TransactionHash(self.trytes3)),
            ],
        }

        filter_ = self._filter(request)

        self.assertFilterPasses(filter_)
        self.assertDictEqual(filter_.cleaned_data, request)
Ejemplo n.º 3
0
def populated_panel(frame):
    bundles = {
        'confirmed': [MagicMock(hash=BundleHash('A'))],
        'unconfirmed': [MagicMock(hash=BundleHash('B'))],
    }
    mock_wallet = MagicMock(bundles=bundles)

    yield HistoryTab(frame, mock_wallet)
  def test_pass_compatible_types(self):
    """
    The request contains values that can be converted to the expected
    types.
    """
    filter_ = self._filter({
      'bundles': [
        self.trytes1.encode('ascii'),
        BundleHash(self.trytes2),
      ],

      'addresses': [
        self.trytes1.encode('ascii'),
        Address(self.trytes2),
      ],

      'tags': [
        self.trytes1.encode('ascii'),
        Tag(self.trytes3),
      ],

      'approvees': [
        self.trytes1.encode('ascii'),
        TransactionHash(self.trytes3),
      ],
    })

    self.assertFilterPasses(filter_)
    self.assertDictEqual(
      filter_.cleaned_data,

      {
        # Raw trytes are extracted to match the IRI's JSON protocol.
        'bundles': [
          text_type(BundleHash(self.trytes1)),
          text_type(BundleHash(self.trytes2)),
        ],

        'addresses': [
          text_type(Address(self.trytes1)),
          text_type(Address(self.trytes2)),
        ],

        'tags': [
          text_type(Tag(self.trytes1)),
          text_type(Tag(self.trytes3)),
        ],

        'approvees': [
          text_type(TransactionHash(self.trytes1)),
          text_type(TransactionHash(self.trytes3)),
        ],
      },
    )
Ejemplo n.º 5
0
    def test_single_transaction(self):
        """
    Getting a bundle that contains a single transaction.
    """
        transaction = \
            Transaction(
                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=Nonce(b''),
                signature_message_fragment=Fragment(b''),

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

                address=Address(
                    b'TESTVALUE9DONTUSEINPRODUCTION99999OCSGVF'
                    b'IBQA99KGTCPCZ9NHR9VGLGADDDIEGGPCGBDEDDTBC',
                ),

                bundle_hash=BundleHash(
                    b'TESTVALUE9DONTUSEINPRODUCTION99999DIOAZD'
                    b'M9AIUHXGVGBC9EMGI9SBVBAIXCBFJ9EELCPDRAD9U',
                ),

                branch_transaction_hash=TransactionHash(
                    b'TESTVALUE9DONTUSEINPRODUCTION99999BBCEDI'
                    b'ZHUDWBYDJEXHHAKDOCKEKDFIMB9AMCLFW9NBDEOFV',
                ),

                trunk_transaction_hash=TransactionHash(
                    b'TESTVALUE9DONTUSEINPRODUCTION999999ARAYA'
                    b'MHCB9DCFEIWEWDLBCDN9LCCBQBKGDDAECFIAAGDAS',
                ),
            )

        self.adapter.seed_response('getTrytes', {
            'trytes': [transaction.as_tryte_string()],
        })

        response = self.command(transaction=transaction.hash)

        bundle = response['bundles'][0]  # type: Bundle
        self.assertEqual(len(bundle), 1)

        self.maxDiff = None
        self.assertDictEqual(
            bundle[0].as_json_compatible(),
            transaction.as_json_compatible(),
        )
Ejemplo n.º 6
0
 def test_fail_bundles_wrong_type(self):
     """
 ``bundles`` is not an array.
 """
     self.assertFilterErrors(
         {
             'bundles': BundleHash(self.trytes1),
         },
         {
             'bundles': [f.Type.CODE_WRONG_TYPE],
         },
     )
Ejemplo n.º 7
0
def finalize(bundle):
    sponge = Kerl()
    last_index = len(bundle) - 1

    for (i, txn) in enumerate(bundle):
        txn.current_index = i
        txn.last_index = last_index
        sponge.absorb(txn.get_signature_validation_trytes().as_trits())

    bundle_hash_trits = [0] * HASH_LENGTH
    sponge.squeeze(bundle_hash_trits)

    bundle_hash = BundleHash.from_trits(bundle_hash_trits)

    for txn in bundle:
        txn.bundle_hash = bundle_hash
        txn.signature_message_fragment = Fragment(txn.message or b'')
Ejemplo n.º 8
0
def finalize(bundle):
    sponge = Kerl()
    last_index = len(bundle) - 1

    for (i, txn) in enumerate(bundle):  # type: Tuple[int, ProposedTransaction]
        txn.current_index = i
        txn.last_index = last_index
        sponge.absorb(txn.get_signature_validation_trytes().as_trits())

    bundle_hash_trits = [0] * HASH_LENGTH  # type: MutableSequence[int]
    sponge.squeeze(bundle_hash_trits)
    bundle_hash = BundleHash.from_trits(bundle_hash_trits)

    for txn in bundle:
        txn.bundle_hash = bundle_hash
        # Initialize signature/message fragment.
        txn.signature_message_fragment = Fragment(txn.message or b'')
Ejemplo n.º 9
0
    def test_fail_unexpected_parameters(self):
        """
    The request contains unexpected parameters.
    """
        self.assertFilterErrors(
            {
                'addresses': [Address(self.trytes1)],
                'approvees': [TransactionHash(self.trytes1)],
                'bundles': [BundleHash(self.trytes1)],
                'tags': [Tag(self.trytes1)],

                # Hey, you're not allowed in he-argh!
                'foo': 'bar',
            },
            {
                'foo': [f.FilterMapper.CODE_EXTRA_KEY],
            },
        )
Ejemplo n.º 10
0
    def test_fail_bundle_hash_invalid(self):
        """
    One of the transactions has an invalid ``bundle_hash`` value.
    """
        # noinspection SpellCheckingInspection
        self.bundle.transactions[3].bundle_hash =\
          BundleHash(
            b'NFDPEEZCWVYLKZGSLCQNOFUSENIXRHWWTZFBXMPS'
            b'QHEDFWZULBZFEOMNLRNIDQKDNNIELAOXOVMYEI9PG'
          )

        validator = BundleValidator(self.bundle)

        self.assertFalse(validator.is_valid())

        self.assertListEqual(
            validator.errors,
            [
                'Transaction 3 has invalid bundle hash.',
            ],
        )
Ejemplo n.º 11
0
  def setUp(self):
    super(BundleTestCase, self).setUp()

    self.bundle = Bundle([
      # This transaction does not have a message.
      Transaction(
        signature_message_fragment = Fragment(b''),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999A9PG9A'
            b'XCQANAWGJBTFWEAEQCN9WBZB9BJAIIY9UDLIGFOAA'
          ),

        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                             = 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
      # sequence.
      Transaction(
        signature_message_fragment =
          Fragment(b'OHCFVELH9GYEMHCF9GPHBGIEWHZFU'),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999HAA9UA'
            b'MHCGKEUGYFUBIARAXBFASGLCHCBEVGTBDCSAEBTBM'
          ),

        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                             = 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
      # fragment.
      Transaction(
        signature_message_fragment =
          Fragment.from_unicode('Hello, world!'),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999D99HEA'
            b'M9XADCPFJDFANCIHR9OBDHTAGGE9TGCI9EO9ZCRBN'
          ),

        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                             = 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.
      Transaction(
        signature_message_fragment =
          Fragment(
            b'J9GAQBCDCDSCEAADCDFDBDXCBDVCQAGAEAGDPCXCSCEANBTCTCDDEACCWCCDIDVC'
            b'WCHDEAPCHDEA9DPCGDHDSAJ9GAOBFDSASASAEAQBCDCDSCEAADCDFDBDXCBDVCQA'
            b'EAYBEANBTCTCDDEACCWCCDIDVCWCHDQAGAEAGDPCXCSCEAVBCDCDBDEDIDPCKD9D'
            b'EABDTCFDJDCDIDGD9DMDSAJ9EAEAGANBCDEAMDCDIDEAWCPCJDTCSASASAEATCFD'
            b'QAEAHDWCPCHDEAXCGDSASASAGAJ9GASASASAEAPCBDEAPCBDGDKDTCFDEAUCCDFD'
            b'EAMDCDIDIBGAEAXCBDHDTCFDFDIDDDHDTCSCEANBTCTCDDEACCWCCDIDVCWCHDEA'
            b'ADPCYCTCGDHDXCRCPC9D9DMDSAEAGAHCTCGDSAEASBEAWCPCJDTCSAGAJ9CCWCTC'
            b'EAHDKDCDEAADTCBDEAGDWCXCJDTCFDTCSCEAKDXCHDWCEATCLDDDTCRCHDPCBDRC'
            b'MDSAEACCWCTCXCFDEAKDPCXCHDXCBDVCEAWCPCSCEABDCDHDEAQCTCTCBDEAXCBD'
            b'EAJDPCXCBDSAJ9GACCWCTCFDTCEAFDTCPC9D9DMDEAXCGDEACDBDTCIBGAEAQCFD'
            b'TCPCHDWCTCSCEAZBWCCDIDRCWCVCSAJ9GACCWCTCFDTCEAFDTCPC9D9DMDEAXCGD'
            b'EACDBDTCQAGAEARCCDBDUCXCFDADTCSCEANBTCTCDDEACCWCCDIDVCWCHDSAJ9GA'
            b'CCCDEAOBJDTCFDMDHDWCXCBDVCIBEACCCDEAHDWCTCEAVCFDTCPCHDEA9CIDTCGD'
            b'HDXCCDBDEACDUCEAVBXCUCTCQAEAHDWCTCEADCBDXCJDTCFDGDTCEAPCBDSCEAOB'
            b'JDTCFDMDHDWCXCBDVCIBGAJ9GAHCTCGDSAGAJ9LBCDHDWCEACDUCEAHDWCTCEAAD'
            b'TCBDEAWCPCSCEAQCTCTCBDEAHDFDPCXCBDTCSCEAUCCDFDEAHDWCXCGDEAADCDAD'
            b'TCBDHDEBEAHDWCTCXCFDEA9DXCJDTCGDEAWCPCSCEAQCTCTCBDEAPCJ9EAEADDFD'
            b'TCDDPCFDPCHDXCCDBDEAUCCDFDEAXCHDEBEAHDWCTCMDEAWCPCSCEAQCTCTCBDEA'
            b'GDTC9DTCRCHDTCSCEAPCHDEAQCXCFDHDWCEAPCGDEAHDWCCDGDTCEAKDWCCDEAKD'
            b'CDID9DSCJ9EAEAKDXCHDBDTCGDGDEAHDWCTCEAPCBDGDKDTCFDEBEAQCIDHDEATC'
            b'JDTCBDEAGDCDEAHDWCTCMDEAUCCDIDBDSCEAHDWCTCADGDTC9DJDTCGDEAVCPCGD'
            b'DDXCBDVCEAPCBDSCEAGDEDIDXCFDADXCBDVCJ9EAEA9DXCZCTCEATCLDRCXCHDTC'
            b'SCEARCWCXC9DSCFDTCBDSAJ9GAKBBDSCEAMDCDIDLAFDTCEAFDTCPCSCMDEAHDCD'
            b'EAVCXCJDTCEAXCHDEAHDCDEAIDGDIBGAEAIDFDVCTCSCEAVBCDCDBDEDIDPCKD9D'
            b'SAJ9GASBEAPCADSAGAJ9GAXBCDKDIBGAJ9GAXBCDKDQAGAEAGDPCXCSCEANBTCTC'
            b'DDEACCWCCDIDVCWCHDSAJ9CCWCTCMDEAQCCDHDWCEA9DXCRCZCTCSCEAHDWCTCXC'
            b'FDEASCFDMDEA9DXCDDGDSAJ9GACCWCCDIDVCWCEASBEASCCDBDLAHDEAHDWCXCBD'
            b'ZCQAGAEAPCSCSCTCSCEANBTCTCDDEACCWCCDIDVCWCHDQAEAGAHDWCPCHDEAMDCD'
            b'IDLAFDTCEAVCCDXCBDVCEAHDCDEA9DXCZCTCEAXCHDSAGAJ9GANBCDTCGDBDLAHD'
            b'EAADPCHDHDTCFDQAGAEAGDPCXCSCEAZBWCCDIDRCWCVCSAEAGAFCTCEAADIDGDHD'
            b'EAZCBDCDKDEAXCHDFAEAXBCDKDFAGAJ9GAXBCDKDIBGAEATCBDEDIDXCFDTCSCEA'
            b'NBTCTCDDEACCWCCDIDVCWCHDSAJ9GAHCTCGDFAEAXBCDKDFAGAJ9GAKB9D9DEAFD'
            b'XCVCWCHDQAGAEAGDPCXCSCEAHDWCTCEARCCDADDDIDHDTCFDEAPCBDSCEAGDTCHD'
            b'HD9DTCSCEAXCBDHDCDEAGDXC9DTCBDRCTCEAPCVCPCXCBDSAJ9EAEACCWCTCEAHD'
            b'KDCDEAADTCB'
          ),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999A9PG9A'
            b'XCQANAWGJBTFWEAEQCN9WBZB9BJAIIY9UDLIGFOAA'
          ),

        current_index           = 3,
        last_index              = 7,
        value                   = 30,

        # These values are not relevant to the tests.
        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(
        signature_message_fragment =
          Fragment(
            b'DEAUCXCSCVCTCHDTCSCSAEACCWCTCEAHDTCBDGDXCCDBDEAKDPCGDEAIDBDQCTCP'
            b'CFDPCQC9DTCSAJ9GAHCCDIDLAFDTCEAFDTCPC9D9DMDEABDCDHDEAVCCDXCBDVCE'
            b'AHDCDEA9DXCZCTCEAXCHDQAGAEACDQCGDTCFDJDTCSCEANBTCTCDDEACCWCCDIDV'
            b'CWCHDSAJ9GACCTC9D9DEAIDGDFAGAJ9GAKB9D9DEAFDXCVCWCHDQAGAEAGDPCXCS'
            b'CEANBTCTCDDEACCWCCDIDVCWCHDSAEAGACCWCTCEAKBBDGDKDTCFDEAHDCDEAHDW'
            b'CTCEAQBFDTCPCHDEA9CIDTCGDHDXCCDBDSASASAGAJ9GAHCTCGDIBGAJ9GAYBUCE'
            b'AVBXCUCTCQAEAHDWCTCEADCBDXCJDTCFDGDTCEAPCBDSCEAOBJDTCFDMDHDWCXCB'
            b'DVCSASASAGAEAGDPCXCSCEANBTCTCDDEACCWCCDIDVCWCHDSAJ9GAHCTCGDIBIBG'
            b'AJ9GASBGDSASASAGAJ9GAHCTCGDIBFAGAJ9GAPBCDFDHDMDRAHDKDCDQAGAEAGDP'
            b'CXCSCEANBTCTCDDEACCWCCDIDVCWCHDQAEAKDXCHDWCEAXCBDUCXCBDXCHDTCEAA'
            b'DPCYCTCGDHDMDEAPCBDSCEARCPC9DADSAJ9EAEAEAEAEAEAEAEA'
          ),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999A9PG9A'
            b'XCQANAWGJBTFWEAEQCN9WBZB9BJAIIY9UDLIGFOAA'
          ),

        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                             = 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
      Transaction(
        # Make the signature look like a message, so we can verify that
        # the Bundle skips it correctly.
        signature_message_fragment =
          Fragment.from_unicode('This is a signature, not a message!'),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999WGSBUA'
            b'HDVHYHOBHGP9VCGIZHNCAAQFJGE9YHEHEFTDAGXHY'
          ),

        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                             = 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
      Transaction(
        # Make the signature look like a message, so we can verify that
        # the Bundle skips it correctly.
        signature_message_fragment =
          Fragment.from_unicode('This is a signature, not a message!'),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999WGSBUA'
            b'HDVHYHOBHGP9VCGIZHNCAAQFJGE9YHEHEFTDAGXHY'
          ),

        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                             = 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
      Transaction(
        # It's unusual for a change transaction to have a message, but
        # half the fun of unit tests is designing unusual scenarios!
        signature_message_fragment =
          Fragment.from_unicode('I can haz change?'),

        address =
          Address(
            b'TESTVALUE9DONTUSEINPRODUCTION99999FFYALH'
            b'N9ACYCP99GZBSDK9CECFI9RAIH9BRCCAHAIAWEFAN'
          ),

        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                             = 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,
      ),
    ])
Ejemplo n.º 12
0
  def test_as_tryte_string(self):
    """
    Converting a Transaction into a TryteString.
    """
    transaction = Transaction(
      hash_ =
        TransactionHash(
          b'SYABNCYPLULQQBTDCUWJPVVMYNWHKEHGAZPKRBGE'
          b'QKEHUIKJCHWGAUKLSYMDOUUBMXPKCPTNFWUFU9JKW'
        ),

      signature_message_fragment =
        Fragment(
          b'GYPRVHBEZOOFXSHQBLCYW9ICTCISLHDBNMMVYD9JJHQMPQCTIQAQTJNNNJ9IDXLRCC'
          b'OYOXYPCLR9PBEY9ORZIEPPDNTI9CQWYZUOTAVBXPSBOFEQAPFLWXSWUIUSJMSJIIIZ'
          b'WIKIRH9GCOEVZFKNXEVCUCIIWZQCQEUVRZOCMEL9AMGXJNMLJCIA9UWGRPPHCEOPTS'
          b'VPKPPPCMQXYBHMSODTWUOABPKWFFFQJHCBVYXLHEWPD9YUDFTGNCYAKQKVEZYRBQRB'
          b'XIAUX9SVEDUKGMTWQIYXRGSWYRK9SRONVGTW9YGHSZRIXWGPCCUCDRMAXBPDFVHSRY'
          b'WHGB9DQSQFQKSNICGPIPTRZINYRXQAFSWSEWIFRMSBMGTNYPRWFSOIIWWT9IDSELM9'
          b'JUOOWFNCCSHUSMGNROBFJX9JQ9XT9PKEGQYQAWAFPRVRRVQPUQBHLSNTEFCDKBWRCD'
          b'X9EYOBB9KPMTLNNQLADBDLZPRVBCKVCYQEOLARJYAGTBFR9QLPKZBOYWZQOVKCVYRG'
          b'YI9ZEFIQRKYXLJBZJDBJDJVQZCGYQMROVHNDBLGNLQODPUXFNTADDVYNZJUVPGB9LV'
          b'PJIYLAPBOEHPMRWUIAJXVQOEM9ROEYUOTNLXVVQEYRQWDTQGDLEYFIYNDPRAIXOZEB'
          b'CS9P99AZTQQLKEILEVXMSHBIDHLXKUOMMNFKPYHONKEYDCHMUNTTNRYVMMEYHPGASP'
          b'ZXASKRUPWQSHDMU9VPS99ZZ9SJJYFUJFFMFORBYDILBXCAVJDPDFHTTTIYOVGLRDYR'
          b'TKHXJORJVYRPTDH9ZCPZ9ZADXZFRSFPIQKWLBRNTWJHXTOAUOL9FVGTUMMPYGYICJD'
          b'XMOESEVDJWLMCVTJLPIEKBE9JTHDQWV9MRMEWFLPWGJFLUXI9BXPSVWCMUWLZSEWHB'
          b'DZKXOLYNOZAPOYLQVZAQMOHGTTQEUAOVKVRRGAHNGPUEKHFVPVCOYSJAWHZU9DRROH'
          b'BETBAFTATVAUGOEGCAYUXACLSSHHVYDHMDGJP9AUCLWLNTFEVGQGHQXSKEMVOVSKQE'
          b'EWHWZUDTYOBGCURRZSJZLFVQQAAYQO9TRLFFN9HTDQXBSPPJYXMNGLLBHOMNVXNOWE'
          b'IDMJVCLLDFHBDONQJCJVLBLCSMDOUQCKKCQJMGTSTHBXPXAMLMSXRIPUBMBAWBFNLH'
          b'LUJTRJLDERLZFUBUSMF999XNHLEEXEENQJNOFFPNPQ9PQICHSATPLZVMVIWLRTKYPI'
          b'XNFGYWOJSQDAXGFHKZPFLPXQEHCYEAGTIWIJEZTAVLNUMAFWGGLXMBNUQTOFCNLJTC'
          b'DMWVVZGVBSEBCPFSM99FLOIDTCLUGPSEDLOKZUAEVBLWNMODGZBWOVQT9DPFOTSKRA'
          b'BQAVOQ9RXWBMAKFYNDCZOJGTCIDMQSQQSODKDXTPFLNOKSIZEOY9HFUTLQRXQMEPGO'
          b'XQGLLPNSXAUCYPGZMNWMQWSWCKAQYKXJTWINSGPPZG9HLDLEAWUWEVCTVRCBDFOXKU'
          b'ROXH9HXXAXVPEJFRSLOGRVGYZASTEBAQNXJJROCYRTDPYFUIQJVDHAKEG9YACV9HCP'
          b'JUEUKOYFNWDXCCJBIFQKYOXGRDHVTHEQUMHO999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999999999999999999999999999999999999999999999999999999999999'
          b'999999999'
        ),

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

      value         = 0,
      timestamp     = 1480690413,
      current_index = 1,
      last_index    = 1,

      bundle_hash =
        BundleHash(
          b'NFDPEEZCWVYLKZGSLCQNOFUSENIXRHWWTZFBXMPS'
          b'QHEDFWZULBZFEOMNLRNIDQKDNNIELAOXOVMYEI9PG'
        ),

      trunk_transaction_hash =
        TransactionHash(
          b'TKORV9IKTJZQUBQAWTKBKZ9NEZHBFIMCLV9TTNJN'
          b'QZUIJDFPTTCTKBJRHAITVSKUCUEMD9M9SQJ999999'
        ),

      branch_transaction_hash =
        TransactionHash(
          b'TKORV9IKTJZQUBQAWTKBKZ9NEZHBFIMCLV9TTNJN'
          b'QZUIJDFPTTCTKBJRHAITVSKUCUEMD9M9SQJ999999'
        ),

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


      nonce =
        Nonce(
          b'999999999999999999999999999'
        ),
    )

    self.assertEqual(
      transaction.as_tryte_string(),

     TransactionTrytes(
        b'GYPRVHBEZOOFXSHQBLCYW9ICTCISLHDBNMMVYD9JJHQMPQCTIQAQTJNNNJ9IDXLRCC'
        b'OYOXYPCLR9PBEY9ORZIEPPDNTI9CQWYZUOTAVBXPSBOFEQAPFLWXSWUIUSJMSJIIIZ'
        b'WIKIRH9GCOEVZFKNXEVCUCIIWZQCQEUVRZOCMEL9AMGXJNMLJCIA9UWGRPPHCEOPTS'
        b'VPKPPPCMQXYBHMSODTWUOABPKWFFFQJHCBVYXLHEWPD9YUDFTGNCYAKQKVEZYRBQRB'
        b'XIAUX9SVEDUKGMTWQIYXRGSWYRK9SRONVGTW9YGHSZRIXWGPCCUCDRMAXBPDFVHSRY'
        b'WHGB9DQSQFQKSNICGPIPTRZINYRXQAFSWSEWIFRMSBMGTNYPRWFSOIIWWT9IDSELM9'
        b'JUOOWFNCCSHUSMGNROBFJX9JQ9XT9PKEGQYQAWAFPRVRRVQPUQBHLSNTEFCDKBWRCD'
        b'X9EYOBB9KPMTLNNQLADBDLZPRVBCKVCYQEOLARJYAGTBFR9QLPKZBOYWZQOVKCVYRG'
        b'YI9ZEFIQRKYXLJBZJDBJDJVQZCGYQMROVHNDBLGNLQODPUXFNTADDVYNZJUVPGB9LV'
        b'PJIYLAPBOEHPMRWUIAJXVQOEM9ROEYUOTNLXVVQEYRQWDTQGDLEYFIYNDPRAIXOZEB'
        b'CS9P99AZTQQLKEILEVXMSHBIDHLXKUOMMNFKPYHONKEYDCHMUNTTNRYVMMEYHPGASP'
        b'ZXASKRUPWQSHDMU9VPS99ZZ9SJJYFUJFFMFORBYDILBXCAVJDPDFHTTTIYOVGLRDYR'
        b'TKHXJORJVYRPTDH9ZCPZ9ZADXZFRSFPIQKWLBRNTWJHXTOAUOL9FVGTUMMPYGYICJD'
        b'XMOESEVDJWLMCVTJLPIEKBE9JTHDQWV9MRMEWFLPWGJFLUXI9BXPSVWCMUWLZSEWHB'
        b'DZKXOLYNOZAPOYLQVZAQMOHGTTQEUAOVKVRRGAHNGPUEKHFVPVCOYSJAWHZU9DRROH'
        b'BETBAFTATVAUGOEGCAYUXACLSSHHVYDHMDGJP9AUCLWLNTFEVGQGHQXSKEMVOVSKQE'
        b'EWHWZUDTYOBGCURRZSJZLFVQQAAYQO9TRLFFN9HTDQXBSPPJYXMNGLLBHOMNVXNOWE'
        b'IDMJVCLLDFHBDONQJCJVLBLCSMDOUQCKKCQJMGTSTHBXPXAMLMSXRIPUBMBAWBFNLH'
        b'LUJTRJLDERLZFUBUSMF999XNHLEEXEENQJNOFFPNPQ9PQICHSATPLZVMVIWLRTKYPI'
        b'XNFGYWOJSQDAXGFHKZPFLPXQEHCYEAGTIWIJEZTAVLNUMAFWGGLXMBNUQTOFCNLJTC'
        b'DMWVVZGVBSEBCPFSM99FLOIDTCLUGPSEDLOKZUAEVBLWNMODGZBWOVQT9DPFOTSKRA'
        b'BQAVOQ9RXWBMAKFYNDCZOJGTCIDMQSQQSODKDXTPFLNOKSIZEOY9HFUTLQRXQMEPGO'
        b'XQGLLPNSXAUCYPGZMNWMQWSWCKAQYKXJTWINSGPPZG9HLDLEAWUWEVCTVRCBDFOXKU'
        b'ROXH9HXXAXVPEJFRSLOGRVGYZASTEBAQNXJJROCYRTDPYFUIQJVDHAKEG9YACV9HCP'
        b'JUEUKOYFNWDXCCJBIFQKYOXGRDHVTHEQUMHO999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999999999999999999999999999999999999999999999999999999999'
        b'999999999999RKWEEVD99A99999999A99999999NFDPEEZCWVYLKZGSLCQNOFUSENI'
        b'XRHWWTZFBXMPSQHEDFWZULBZFEOMNLRNIDQKDNNIELAOXOVMYEI9PGTKORV9IKTJZQ'
        b'UBQAWTKBKZ9NEZHBFIMCLV9TTNJNQZUIJDFPTTCTKBJRHAITVSKUCUEMD9M9SQJ999'
        b'999TKORV9IKTJZQUBQAWTKBKZ9NEZHBFIMCLV9TTNJNQZUIJDFPTTCTKBJRHAITVSK'
        b'UCUEMD9M9SQJ999999999999999999999999999999999RKWEEVD99RKWEEVD99RKW'
        b'EEVD99999999999999999999999999999'
      ),
    )
Ejemplo n.º 13
0
    def test_happy_path(self):
        """
    Successfully replaying a bundle.
    """
        # noinspection SpellCheckingInspection
        bundle = Bundle([
            # "Spend" transaction, Part 1 of 1
            Transaction(
                hash_=TransactionHash(
                    b'LUQJUUDAZIHSTPBLCZYXWXYKXTFCOCQJ9EHXKLEB'
                    b'IJBPSRFSBYRBYODDAZ9NPKPYSMPVNEFXYZQ999999'),
                address=Address(b'FZXUHBBLASPIMBDIHYTDFCDFIRII9LRJPXFTQTPO'
                                b'VLEIFE9NWTFPPQZHDCXYUOUCXHHNRPKCIROYYTWSA'),
                branch_transaction_hash=TransactionHash(
                    b'UKGIAYNLALFGJOVUZYJGNIOZSXBBZDXVQLUMHGQE'
                    b'PZJWYDMGTPJIQXS9GOKXR9WIGWFRWRSKGCJ999999'),
                bundle_hash=BundleHash(
                    b'ZSATLX9HDENCIARERVLWYHXPQETFL9QKTNC9LUOL'
                    b'CDXKKW9MYTLZJDXBNOHURUXSYWMGGD9UDGLHCSZO9'),
                nonce=Nonce(b'LIJVXBVTYMEEPCKJRIQTGAKWJRA'),
                trunk_transaction_hash=TransactionHash(
                    b'KFCQSGDYENCECCPNNZDVDTBINCBRBERPTQIHFH9G'
                    b'YLTCSGUFMVWWSAHVZFXDVEZO9UHAUIU9LNX999999'),
                signature_message_fragment=Fragment(b''),
                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
            Transaction(
                hash_=TransactionHash(
                    b'KFCQSGDYENCECCPNNZDVDTBINCBRBERPTQIHFH9G'
                    b'YLTCSGUFMVWWSAHVZFXDVEZO9UHAUIU9LNX999999'),
                address=Address(b'GMHOSRRGXJLDPVWRWVSRWI9BCIVLUXWKTJYZATIA'
                                b'RAZRUCRGTWXWP9SZPFOVAMLISUPQUKHNDMITUJKIB'),
                branch_transaction_hash=TransactionHash(
                    b'UKGIAYNLALFGJOVUZYJGNIOZSXBBZDXVQLUMHGQE'
                    b'PZJWYDMGTPJIQXS9GOKXR9WIGWFRWRSKGCJ999999'),
                bundle_hash=BundleHash(
                    b'ZSATLX9HDENCIARERVLWYHXPQETFL9QKTNC9LUOL'
                    b'CDXKKW9MYTLZJDXBNOHURUXSYWMGGD9UDGLHCSZO9'),
                nonce=Nonce(b'VRYLDCKEWZJXPQVSWOJVYVBJSCW'),
                trunk_transaction_hash=TransactionHash(
                    b'QSTUKDIBYAZIQVEOMFGKQPHAIPBHUPSDQFFKKHRA'
                    b'ABYMYMQDHMTEWCM9IMZHQMGXOTWNSJYHRNA999999'),
                signature_message_fragment=Fragment(
                    b'XS9OVIXHIGGR9IYQBHGMFAHPZBWLIBNAQPFMPVYUZDOLLFDJIPZEMIOGVANQJSCU'
                    b'IPDNNUNAMWEL9OFXXK9NV9UTCRBYTARBJHPQYJYKNAQGMATG9EXQMHGXY9QOHPBA'
                    b'FEVABDYMCXORXHBMPLEWJYGYFFBWVXAUXHGLTABBKOQMZLFAYWDAKEOMJPJX9TMT'
                    b'GXIJXZTKRRIPAMYY9UNSPPEGFPJE9NFSJFWKYOFZRMPBXZDNQUEKLRUVPXMCTQRE'
                    b'ZWICSCVXN9VBLN9DRINRPAZTYJYXPGGRZJLMYXGCLUQNZ9NJGH9GFQPKKVK9N9WR'
                    b'IJXDNKUMLLJUVIQRGPHEVWTXQHRLRCWQJCHTPASCVLRGPNWSIUKWIBMDJJ9EUTQ9'
                    b'NXZZEJFWY9LCJJSOEPXWETUBKKVZNUKTLUPEPDBLUWCQGYTOXZ9NZUXHBDOUYQBP'
                    b'MNECVJ9HGWA9AWU9VHGETWKBU9YZEZGEQKMVTAKPLCZVWKQFXDEFBPKNUCQDSPWA'
                    b'LMPFTUFGRFDZH9PQHJ9WXZPCDWGMNASVVEUXEGWATM9ZIMCEEXTHCXFLYG9LQAKV'
                    b'UOGORP9UUWYFTWGZ9OFOGSP9KDNPDSQKEMMISEMWQDVFKCSQXSP9RUMNUQJOBACU'
                    b'MPIXCGBJLQQGB9GDSMUUUSYWIY9ZNIAIZBJYTAJKJKZIBFPMGDWUEPXSO9HUJRNV'
                    b'QE9OTVUPKBVNVUBSILVZEDPC9AMEYAIATE9JEIQQWIMGCZXMHOPXPFUTEPJEATJN'
                    b'QWDFZQ9OGPNBFUHLJDJZQJLXCFEUDPZKVCPEBTNBRYNIIKJHUV9EUFVMB9AHTARQ'
                    b'DN9TZ9JPAPCEXSYHZPAQLBJMNQ9R9KPWVZLDLFNHYCCQBFVEPMEZSXAB9GOKGOGC'
                    b'SOVL9XJSAQYSECY9UUNSVQSJB9BZVYRUURNUDMZVBJTMIDQUKQLMVW99XFDWTOPR'
                    b'UBRPKS9BGEAQPIODAMJAILNCH9UVYVWSDCZXZWLO9XJJZ9FQOL9F9ZJDNGMUGFKJ'
                    b'PCYURGYBGYRVKPEBKMJPZZGDKZKT9UBFSJEELREWOYDQZVUPVSGPZYIDVOJGNTXC'
                    b'OFGCHBGVZPQDNRKAQNVJEYKYTKHTFBJRDMKVSHEWADNYIQOAUFXYMZKNJPLXGYFX'
                    b'DTCVDDBUHBDPG9WLNMWPSCCCGVTIOOLEECXKNVAYNNTDLJMDGDGSKOGWO9UYXTTF'
                    b'FCRZEDDQNN9ZODTETGMGGUXOYECGNMHGMGXHZSPODIBMBATJJHSPQHDUCZOMWQNI'
                    b'CUZG9LAMBOQRQQDIPIBMIDCIAJBBBNDUAIEMFCEASHPUJPFPPXNDUVGDNNYBRRTW'
                    b'SPXGXMCSUXYJSTFIRUIDNEUSVKNIDKIBRQNMEDCYQOMJYTMGRZLYHBUYXCRGSAXR'
                    b'ZVHTZEAKNAUKJPFGPOGQLTDMSOXR9NVOIAIMCBVWOF9FXAZUKKZKHJEGHFNLUB9B'
                    b'TGAICGQGAYZRRHSFIDTNIJPHIHCXTHQUSKJRSVAWFUXLBYA99QKMGLHDNUHOPEW9'
                    b'OFNWPDXXRVZREUIQKSVSDCFIJ99TSGSZ9KU9JGE9VXDVVOLMGNMUGSHUZAOFCIMK'
                    b'CPEWMG9IHUZAILQCANIUUG9JNEZMT9EONSN9CWWQOTFBEPZRTTJTQFSTQTBERKGE'
                    b'NGFFIYMZMCFBYNIOBPOFOIYPUMYYPRXEHUJEVVELOPNXAPCYFXQ9ORMSFICDOZTS'
                    b'GQOMDI9FKEKRIMZTWSIWMYAUSBIN9TPFSMQZCYGVPVWKSFZXPE9BP9ALNWQOVJGM'
                    b'SCSJSTNUTMUAJUIQTITPPOHG9NKIFRNXSCMDAEW9LSUCTCXITSTZSBYMPOMSMTXP'
                    b'CEBEOAUJK9STIZRXUORRQBCYJPCNHFKEVY9YBJL9QGLVUCSZKOLHD9BDNKIVJX9T'
                    b'PPXQVGAXUSQQYGFDWQRZPKZKKWB9ZBFXTUGUGOAQLDTJPQXPUPHNATSGILEQCSQX'
                    b'X9IAGIVKUW9MVNGKTSCYDMPSVWXCGLXEHWKRPVARKJFWGRYFCATYNZDTRZDGNZAI'
                    b'OULYHRIPACAZLN9YHOFDSZYIRZJEGDUZBHFFWWQRNOLLWKZZENKOWQQYHGLMBMPF'
                    b'HE9VHDDTBZYHMKQGZNCSLACYRCGYSFFTZQJUSZGJTZKKLWAEBGCRLXQRADCSFQYZ'
                    b'G9CM9VLMQZA'),
                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
            Transaction(
                hash_=TransactionHash(
                    b'QSTUKDIBYAZIQVEOMFGKQPHAIPBHUPSDQFFKKHRA'
                    b'ABYMYMQDHMTEWCM9IMZHQMGXOTWNSJYHRNA999999'),
                address=Address(b'GMHOSRRGXJLDPVWRWVSRWI9BCIVLUXWKTJYZATIA'
                                b'RAZRUCRGTWXWP9SZPFOVAMLISUPQUKHNDMITUJKIB'),
                branch_transaction_hash=TransactionHash(
                    b'UKGIAYNLALFGJOVUZYJGNIOZSXBBZDXVQLUMHGQE'
                    b'PZJWYDMGTPJIQXS9GOKXR9WIGWFRWRSKGCJ999999'),
                bundle_hash=BundleHash(
                    b'ZSATLX9HDENCIARERVLWYHXPQETFL9QKTNC9LUOL'
                    b'CDXKKW9MYTLZJDXBNOHURUXSYWMGGD9UDGLHCSZO9'),
                nonce=Nonce(b'AAKVYZOEZSOXTX9LOLHZYLNAS9C'),
                trunk_transaction_hash=TransactionHash(
                    b'ZYQGVZABMFVLJXHXXJMVAXOXHRJTTQUVDIIQOOXN'
                    b'NDPQGDFDRIDQMUWJGCQKKLGEUQRBFAJWZBC999999'),
                signature_message_fragment=Fragment(
                    b'YSNEGUCUHXEEFXPQEABV9ATGQMMXEVGMZWKKAFAVOVGUECOZZJFQDNRBCSXCOTBD'
                    b'BRUJ9HF9CITXQI9ZQGZFKCXMFZTOYHUTCXDIBIMTBKVXMMTPNKRDRLQESLWFZSQQ'
                    b'9BCGKVIZAHBWYTNXG9OWOXHAMQECMOVKN9SOEVJBBARPXUXYUQVFPYXWXQQMDIVP'
                    b'VITRWTNNBY9CYBHXJTZUVIPJJG9WLTNMFVPXGYZCNOGSLGVMS9YXXNSV9AYPXZTA'
                    b'QJYUNUFBCSZBZNKWCPMVMOGFIDENTOOOCPRDJTNGQRLA9YKMLYZQRO9QQJMCSYVF'
                    b'YLISFIWQQYMWMHUOEZPATYCEZARLWLAMCZWYWJZVD9WWKYJURTOLITFFRXQUBKST'
                    b'DG9CKDBLPXTPCIMKEKRGEXJGLRL9ZST9VOLV9NOFZLIMVOZBDZJUQISUWZKOJCRN'
                    b'YRBRJLCTNPV9QIWQJZDQFVPSTW9BJYWHNRVQTITWJYB9HBUQBXTAGK9BZCHYWYPE'
                    b'IREDOXCYRW9UXVSLZBBPAFIUEJABMBYKSUPNWVVKAFQJKDAYYRDICTGOTWWDSFLG'
                    b'BQFZZ9NBEHZHPHVQUYEETIRUDM9V9LBXFUXTUGUMZG9HRBLXCKMMWWMK9VTKVZSA'
                    b'PRSMJVBLFFDHTYCPDXKBUYYLZDPW9EVXANPZOPBASQUPRNCDGHNUK9NDUQSULUZI'
                    b'VMIJTPUGMZPCYR9AERBAGUYNGVEHWIIADAAPPMYQOAGBQCXEDTQOGHWHHSWDFZLC'
                    b'DVLNPYMGDPZWOZURT9OZKDJKFECXSFIALXJDRJWMWMTNUUNVDUCJAZLDRN9ZWLHH'
                    b'SNXDWULUBNLVRDJZQMKCTRCKULKS9VARFZSRYZCPNH9FHXCAFWKPNGOPOFMYXJLE'
                    b'LTKUHSZVDQRDJIGQRGOSKYWDCU9EBJMXQDBKTBNQTIZNCALHRNTHKN99WOBQVVEV'
                    b'HEDTDRKFPGLIWOSPLAAELQQXDCDWPIFED9OEUPYPKHZBOHPQGQGSEKO9BFIQFYZK'
                    b'YEULWSIBZVSPXBGOJTTYBVIIIPAXGL9ZJNNIELFYAUOUBRDWLJJMSAXHQOYGOWDV'
                    b'HHPISRZFSHPDLNQDFWRHLWNAJPYM9REAJLZDIAIVLQBFAUJIQKVHJDFPXENI9ZM9'
                    b'SFNGSQHDFEDC9CQVXAXTQVLWYMVSLEDCOVNSQLSANLVA9TWSY9BHAJKOCGI9YLAB'
                    b'VROCBJRVXRWBKNUXCAXJIAYWSFRDZHIPQSNBRYNKZAFXHDUENVLHFHYIKH9IANFV'
                    b'FKWVFJCSEELVTDDUHBPIYNFLTJLINNORIMDEAXMN9LGNGBWVWYWQIPWKBFDKNDOX'
                    b'WFKGBAMZIUFYA9DXGAL9OQQTJAUUXTINWZSQUTPUKUMOZCGOBKKFBXCVR9AGTAQS'
                    b'SVGTUBBHSIRHFRSIR9SKSZPXQFG9AOYAHZNQR9AHSEFCKWCJHUTLREDVGBQYVBZR'
                    b'CZDXFG9PTSAWQOURYKNWYAZNASV9UMUYUMFCQSFDHZD99WUMCORLYTIZMRGNBAY9'
                    b'UJYJMMRCLJP9XVLXTAZOHNVVYSCOSDHGUOPXIRBJDXJUCJYLQKUJOTNJCPRBDOKV'
                    b'ZEMIGZRNJOQKFFAXQVGGY9YRJORZCOD9REIIIDDTRQ9TJWTFYRKOPLAFNUUPCHXA'
                    b'WVPYUQXAFFCTYAESWAFUTQQYZRQVLVZW9OWAAJMPSAEPKWXVEZVTVPQEEBVXNZJP'
                    b'ZU9JJSIAEPIT9HE99XNAUYOAKRIFQQJQTFIMWEOKLCH9JKCQTGZPEGWORFB9ARNS'
                    b'DPYKRONBONYOGEVEFXGTMQTQBEMFQWEMIDSGAVEQHVHAPSMTCJ9FMEYBWAQWWJCE'
                    b'ABUUMMVNDMSBORFLHVIIDOUQHHXQKXTVGRAYTLMECCSVZOZM9JKUWIGGFLMMDGBU'
                    b'DBIHJFUINVOKSFTOGFCZEMIBSZNGPL9HXWGTNNAKYIMDITCRMSHFR9BDSFGHXQMR'
                    b'ACZOVUOTSJSKMNHNYIFEOD9CVBWYVVMG9ZDNR9FOIXSZSTIO9GLOLPLMW9RPAJYB'
                    b'WTCKV9JMSEVGD9ZPEGKXF9XYQMUMJPWTMFZJODFIEYNLI9PWODSPPW9MVJOWZQZU'
                    b'CIKXCVVXDKWHXV99GOEZ9CMGUH9OWGLLISNZEPSAPEDHVRKKGFFNGBXFLDBQTTQL'
                    b'WVLUITJQ9JM'),
                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
            Transaction(
                hash_=TransactionHash(
                    b'ZYQGVZABMFVLJXHXXJMVAXOXHRJTTQUVDIIQOOXN'
                    b'NDPQGDFDRIDQMUWJGCQKKLGEUQRBFAJWZBC999999'),
                address=Address(b'YOTMYW9YLZQCSLHB9WRSTZDYYYGUUWLVDRHFQFEX'
                                b'UVOQARTQWZGLBU9DVSRDPCWYWQZHLFHY9NGLPZRAQ'),
                branch_transaction_hash=TransactionHash(
                    b'QCHKLZZBG9XQMNGCDVXZGDRXIJMFZP9XUGAWNNVP'
                    b'GXBWB9NVEKEFMUWOEACULFUR9Q9XCWPBRNF999999'),
                bundle_hash=BundleHash(
                    b'ZSATLX9HDENCIARERVLWYHXPQETFL9QKTNC9LUOL'
                    b'CDXKKW9MYTLZJDXBNOHURUXSYWMGGD9UDGLHCSZO9'),
                nonce=Nonce(b'TPGXQFUGNEYYFFKPFWJSXKTWEUK'),
                trunk_transaction_hash=TransactionHash(
                    b'UKGIAYNLALFGJOVUZYJGNIOZSXBBZDXVQLUMHGQE'
                    b'PZJWYDMGTPJIQXS9GOKXR9WIGWFRWRSKGCJ999999'),
                signature_message_fragment=Fragment(b''),
                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,
            ),
        ])

        mock_get_bundles =\
          mock.Mock(return_value={
            'bundles': [bundle],
          })

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

        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',
                mock_get_bundles,
        ):
            with mock.patch(
                    'iota.commands.extended.send_trytes.SendTrytesCommand._execute',
                    mock_send_trytes,
            ):
                response = self.command(
                    depth=100,
                    minWeightMagnitude=18,
                    transaction=bundle[0].hash,
                )

        self.assertDictEqual(response, send_trytes_response)
Ejemplo n.º 14
0
 def test_random(self):
     """
 Creating a random BundleHash object.
 """
     random_bundle_hash = BundleHash.random()
     self.assertEqual(len(random_bundle_hash), BundleHash.LEN)
Ejemplo n.º 15
0
    def test_single_transaction(self):
        """
    Getting a bundle that contains a single transaction.
    """
        transaction =\
          Transaction(
              current_index = 0,
              last_index    = 0,
              tag           = Tag(b''),
              timestamp     = 1484960990,
              value         = 0,

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

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

              address =
                Address(
                  b'TESTVALUE9DONTUSEINPRODUCTION99999OCSGVF'
                  b'IBQA99KGTCPCZ9NHR9VGLGADDDIEGGPCGBDEDDTBC',
                ),

              bundle_hash =
                BundleHash(
                  b'TESTVALUE9DONTUSEINPRODUCTION99999DIOAZD'
                  b'M9AIUHXGVGBC9EMGI9SBVBAIXCBFJ9EELCPDRAD9U',
                ),

              branch_transaction_hash =
                TransactionHash(
                  b'TESTVALUE9DONTUSEINPRODUCTION99999BBCEDI'
                  b'ZHUDWBYDJEXHHAKDOCKEKDFIMB9AMCLFW9NBDEOFV',
                ),

              trunk_transaction_hash =
                TransactionHash(
                  b'TESTVALUE9DONTUSEINPRODUCTION999999ARAYA'
                  b'MHCB9DCFEIWEWDLBCDN9LCCBQBKGDDAECFIAAGDAS',
                ),
            )

        self.adapter.seed_response('getTrytes', {
            'trytes': [transaction.as_tryte_string()],
        })

        response = self.command(transaction=transaction.hash)

        bundle = response['bundles'][0]  # type: Bundle
        self.assertEqual(len(bundle), 1)

        self.maxDiff = None
        self.assertDictEqual(
            bundle[0].as_json_compatible(),
            transaction.as_json_compatible(),
        )
Ejemplo n.º 16
0
    def test_single_transaction(self):
        """
    Getting a bundle that contains a single transaction.
    """
        transaction =\
          Transaction(
              current_index = 0,
              last_index    = 0,
              tag           = Tag(b''),
              timestamp     = 1484960990,
              value         = 0,

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

              # This value is computed automatically, so it has to be real.
              hash_ =
                TransactionHash(
                  b'TAOICZV9ZSXIZINMNRLOLCWNLL9IDKGVWTJITNGU'
                  b'HAIKLHZLBZWOQ9HJSODUDISTYGIYPWTYDCFMVRBQN'
                ),

              address =
                Address(
                  b'TESTVALUE9DONTUSEINPRODUCTION99999OCSGVF'
                  b'IBQA99KGTCPCZ9NHR9VGLGADDDIEGGPCGBDEDDTBC'
                ),

              bundle_hash =
                BundleHash(
                  b'TESTVALUE9DONTUSEINPRODUCTION99999DIOAZD'
                  b'M9AIUHXGVGBC9EMGI9SBVBAIXCBFJ9EELCPDRAD9U'
                ),

              branch_transaction_hash =
                TransactionHash(
                  b'TESTVALUE9DONTUSEINPRODUCTION99999BBCEDI'
                  b'ZHUDWBYDJEXHHAKDOCKEKDFIMB9AMCLFW9NBDEOFV'
                ),

              trunk_transaction_hash =
                TransactionHash(
                  b'TESTVALUE9DONTUSEINPRODUCTION999999ARAYA'
                  b'MHCB9DCFEIWEWDLBCDN9LCCBQBKGDDAECFIAAGDAS'
                ),
            )

        self.adapter.seed_response('getTrytes', {
            'trytes': [transaction.as_tryte_string()],
        })

        response = self.command(transaction=transaction.hash)

        bundle = response['bundles'][0]  # type: Bundle
        self.assertEqual(len(bundle), 1)

        self.maxDiff = None
        self.assertDictEqual(
            bundle[0].as_json_compatible(),
            transaction.as_json_compatible(),
        )