def _create_batches(self,
                        batch_count,
                        txn_count,
                        valid_batch=True,
                        valid_txn=True,
                        valid_structure=True,
                        valid_batcher=True):

        batch_list = []

        for _ in range(batch_count):
            txn_list = self._create_transactions(txn_count, valid_txn,
                                                 valid_batcher)
            txn_sig_list = [txn.header_signature for txn in txn_list]
            if not valid_structure:
                txn_sig_list.pop()

            batch_header = BatchHeader(signer_public_key=self.public_key)
            batch_header.transaction_ids.extend(txn_sig_list)

            header_bytes = batch_header.SerializeToString()

            if valid_batch:
                signature = self.signer.sign(header_bytes)
            else:
                signature = "bad_signature"

            batch = Batch(header=header_bytes,
                          transactions=txn_list,
                          header_signature=signature)

            batch_list.append(batch)

        return batch_list
Beispiel #2
0
    def _create_batches(self, batch_count, txn_count,
                        missing_dep=False):

        batch_list = []

        for i in range(batch_count):
            txn_list = self._create_transactions(txn_count,
                                                 missing_dep=missing_dep)
            txn_sig_list = [txn.header_signature for txn in txn_list]

            batch_header = BatchHeader(signer_public_key=self.public_key)
            batch_header.transaction_ids.extend(txn_sig_list)

            header_bytes = batch_header.SerializeToString()


            signature = signing.sign(
                header_bytes,
                self.private_key)

            batch = Batch(header=header_bytes,
                          transactions=txn_list,
                          header_signature=signature)

            batch_list.append(batch)

        return batch_list
Beispiel #3
0
def _make_mock_batch(self, batch_id='batch_id'):
    txn = _make_mock_transaction(batch_id)

    header = BatchHeader(signer_pubkey='pubkey',
                         transaction_ids=[txn.header_signature])

    return Batch(header=header.SerializeToString(),
                 header_signature=batch_id,
                 transactions=[txn])
Beispiel #4
0
def make_mock_batch(base_id='id'):
    batch_id = 'b-' + base_id
    txn = _make_mock_transaction(base_id)

    header = BatchHeader(signer_public_key='public_key-' + base_id,
                         transaction_ids=[txn.header_signature])

    return Batch(header=header.SerializeToString(),
                 header_signature=batch_id,
                 transactions=[txn])
Beispiel #5
0
def make_mock_batch(base_id='id'):
    batch_id = 'a' * (128 - len(base_id)) + base_id
    txn = _make_mock_transaction(base_id)

    signer_public_key = b'public_key' + bytes(base_id, 'utf-8')

    header = BatchHeader(signer_public_key=signer_public_key.hex(),
                         transaction_ids=[txn.header_signature])

    return Batch(header=header.SerializeToString(),
                 header_signature=batch_id,
                 transactions=[txn])
Beispiel #6
0
def create_batch(transactions, signer):
    transaction_signatures = [t.header_signature for t in transactions]

    header = BatchHeader(signer_public_key=signer.get_public_key().as_hex(),
                         transaction_ids=transaction_signatures)

    header_bytes = header.SerializeToString()

    signature = signer.sign(header_bytes)

    batch = Batch(header=header_bytes,
                  transactions=transactions,
                  header_signature=signature)

    return batch
Beispiel #7
0
    def _create_batches(self, batch_count, txn_count):

        batch_list = []

        for _ in range(batch_count):
            txn_list = self._create_transactions(txn_count)
            txn_sig_list = [txn.header_signature for txn in txn_list]

            batch_header = BatchHeader(
                signer_public_key=self.signer.get_public_key().as_hex())
            batch_header.transaction_ids.extend(txn_sig_list)

            header_bytes = batch_header.SerializeToString()

            signature = self.signer.sign(header_bytes)

            batch = Batch(header=header_bytes,
                          transactions=txn_list,
                          header_signature=signature)

            batch_list.append(batch)

        return batch_list