예제 #1
0
    def _execute(self, request):
        change_address = request['changeAddress']  # type: Optional[Address]
        depth = request['depth']  # type: int
        inputs = request['inputs']  # type: Optional[List[Address]]
        min_weight_magnitude = request['minWeightMagnitude']  # type: int
        seed = request['seed']  # type: Seed
        transfers = request['transfers']  # type: List[ProposedTransaction]

        pt_response = PrepareTransferCommand(self.adapter)(
            changeAddress=change_address,
            inputs=inputs,
            seed=seed,
            transfers=transfers,
        )

        st_response = SendTrytesCommand(self.adapter)(
            depth=depth,
            minWeightMagnitude=min_weight_magnitude,
            trytes=pt_response['trytes'],
        )

        return {
            'bundle': Bundle.from_tryte_strings(st_response['trytes']),
        }
예제 #2
0
    def test_multiple_transactions(self):
        """
    Getting a bundle that contains multiple transactions.
    """
        bundle = Bundle.from_tryte_strings([
            TransactionTrytes(
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999WUQXEGBVIECGIWO9IGSYKWWPYCIVUJJGSJPWGIAFJPYSF9NSQOHWAHS9P'
                b'9PWQHOBXNNQIF9IRHVQXKPZW999999999999999999999999999999999999999999'
                b'999999999999HNLFMVD99A99999999A99999999PDQWLVVDPUU9VIBODGMRIAZPGQX'
                b'DOGSEXIHKIBWSLDAWUKZCZMK9Z9YZSPCKBDJSVDPRQLJSTKUMTNVSXBGUEHHGAIWWQ'
                b'BCJZHZAQOWZMAIDAFUZBVMUVPWQJLUGGQKNKLMGTWXXNZKUCBJLEDAMYVRGABAWBY9'
                b'999MYIYBTGIOQYYZFJBLIAWMPSZEFFTXUZPCDIXSLLQDQSFYGQSQOGSPKCZNLVSZ9L'
                b'MCUWVNGEN9EJEW9999XZUIENOTTBKJMDPRXWGQYG9PWGTXUO9AXMP9FLMDRMADLRPW'
                b'CZCJBROYCDRJMYU9HDYJM9NDBFUPIZVTR'),

            # Well, it was bound to happen sooner or later... the ASCII
            # representation of this tryte sequence contains a very naughty
            # phrase.  But I don't feel like doing another POW, so... enjoy.
            TransactionTrytes(
                b'NBTCPCFDEACCPCBDVC9DTCQAJ9RBTC9D9DCDQAEAKDCDFD9DSCFAJ9VBCDJDTCQAJ9'
                b'ZBMDYBCCKB99999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999999999999999999999999999999999999999999999999999999999'
                b'999999999999HNLFMVD99999999999A99999999PDQWLVVDPUU9VIBODGMRIAZPGQX'
                b'DOGSEXIHKIBWSLDAWUKZCZMK9Z9YZSPCKBDJSVDPRQLJSTKUMTNVSXFSEWUNJOEGNU'
                b'I9QOCRFMYSIFAZLJHKZBPQZZYFG9ORYCRDX9TOMJPFCRB9R9KPUUGFPVOWYXFIWEW9'
                b'999BGUEHHGAIWWQBCJZHZAQOWZMAIDAFUZBVMUVPWQJLUGGQKNKLMGTWXXNZKUCBJL'
                b'EDAMYVRGABAWBY9999SYRABNN9JD9PNDLIKUNCECUELTOQZPSBDILVHJQVCEOICFAD'
                b'YKZVGMOAXJRQNTCKMHGTAUMPGJJMX9LNF'),
        ])

        for txn in bundle:
            self.adapter.seed_response('getTrytes', {
                'trytes': [txn.as_tryte_string()],
            })

        self.adapter.seed_response(
            'getTrytes', {
                'trytes': [
                    'SPAMSPAMSPAM999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999999999999999999'
                    '999999999999999999999999999999999999999999999999999JECDITWO9999999'
                    '999999999999ONLFMVD99999999999999999999VVCHSQSRVFKSBONDWB9EAQEMQOY'
                    'YRBIZHTBJLYNAVDHZPUZAZ9LYHXWKBEJ9IPR9FAMFLT9EEOHVYWUPRHHSRCILCLWFD'
                    'GBYBFFOKMCSAPVD9VGZZRRGBLGMZMXD9RMZQDBLMGN9BATWZGULRBCYQEIKIRBPHC9'
                    '999KTLTRSYOWBD9HVNP9GCUABARNGMYXUZKXWRPGOPETZLKYYC9Z9EYXIWVARUBMBM'
                    'BPXGORN9WPBLY99999ZRBVQWULRFXDNDYZKRKIXPZQT9JJJH9FZU9PVWZJWLXBPODP'
                    'EHMKTTAGEPLPHUQCZNLDSHERONOMHJCOI'
                ],
            })

        response = self.command(transaction=TransactionHash(
            b'TOYJPHKMLQNDVLDHDILARUJCCIUMQBLUSWPCTIVA'
            b'DRXICGYDGSVPXFTILFFGAPICYHGGJ9OHXINFX9999'), )

        self.maxDiff = None
        self.assertListEqual(
            response['bundles'][0].as_json_compatible(),
            bundle.as_json_compatible(),
        )