예제 #1
0
    def test_transaction_status_propagation(self, db_session):

        task = BlockchainTask(uuid=str_uuid())

        assert task.status == 'UNSTARTED'

        transaction_1 = BlockchainTransaction()
        transaction_1.task = task
        transaction_1.status = 'PENDING'

        assert task.status == 'PENDING'

        transaction_2 = BlockchainTransaction()
        transaction_2.task = task
        transaction_2.status = 'SUCCESS'

        assert task.status == 'SUCCESS'
        assert task.status_code == 1

        db_session.add_all([task, transaction_1, transaction_2])
        db_session.commit()

        # Uses a custom expression so worth testing the filter
        queried_task = db_session.query(BlockchainTask).filter(
            BlockchainTask.status == 'SUCCESS').first()
        assert queried_task == task
예제 #2
0
def second_dummy_transaction(db_session, dummy_task, dummy_wallet):
    from sql_persistence.models import BlockchainTransaction

    txn = BlockchainTransaction(signing_wallet=dummy_wallet)

    txn.task = dummy_task

    db_session.add(txn)
    db_session.commit()

    return txn
예제 #3
0
    def create_blockchain_transaction(self, task_uuid):

        task = session.query(BlockchainTask).filter_by(uuid=task_uuid).first()

        blockchain_transaction = BlockchainTransaction(
            signing_wallet=task.signing_wallet,
            first_block_hash=self.first_block_hash)

        session.add(blockchain_transaction)

        if task:
            blockchain_transaction.task = task

        session.commit()

        return blockchain_transaction
예제 #4
0
    def create_blockchain_transaction(self, task_uuid):

        task = self.session.query(BlockchainTask).filter_by(
            uuid=task_uuid).first()

        blockchain_transaction = BlockchainTransaction(
            signing_wallet=task.signing_wallet,
            first_block_hash=self.first_block_hash)

        self.session.add(blockchain_transaction)

        if task:
            # TODO: when is this ever not the case?
            # We should just force signing walelt based off the task
            blockchain_transaction.task = task

        self.session.commit()

        return blockchain_transaction