def test_deposit_stellar_no_account( mock_submit, mock_get, mock_sequence, mock_fee, client, acc1_usd_deposit_transaction_factory, ): """ `create_stellar_deposit` sets the transaction with the provided `transaction_id` to status `pending_trust` if the provided transaction's `stellar_account` does not exist yet. This condition is mocked by throwing an error when attempting to load information for the provided account. Normally, this function creates the account. We have mocked out that functionality, as it relies on network calls to Horizon. """ del mock_submit, mock_get, mock_sequence, mock_fee, client deposit = acc1_usd_deposit_transaction_factory() deposit.status = Transaction.STATUS.pending_anchor deposit.save() create_stellar_deposit(deposit.id) assert ( Transaction.objects.get(id=deposit.id).status == Transaction.STATUS.pending_trust )
def test_async_deposit_success( mock_submit, mock_get, mock_sequence, mock_fee, client, acc1_usd_deposit_transaction_factory, ): d = acc1_usd_deposit_transaction_factory() create_stellar_deposit(d.id) assert Transaction.objects.get(id=d.id).status == Transaction.STATUS.completed
def test_deposit_stellar_no_trustline( mock_submit, mock_get, mock_sequence, mock_fee, client, acc1_usd_deposit_transaction_factory, ): """ `create_stellar_deposit` sets the transaction with the provided `transaction_id` to status `pending_trust` if the provided transaction's Stellar account has no trustline for its asset. (We assume the asset's issuer is the server Stellar account.) """ del mock_submit, mock_get, mock_sequence, mock_fee, client deposit = acc1_usd_deposit_transaction_factory() create_stellar_deposit(deposit.id) assert (Transaction.objects.get( id=deposit.id).status == Transaction.STATUS.pending_trust)
def test_deposit_stellar_success( mock_submit, mock_get, mock_sequence, mock_fee, client, acc1_usd_deposit_transaction_factory, ): """ `create_stellar_deposit` succeeds if the provided transaction's `stellar_account` has a trustline to the issuer for its `asset`, and the Stellar transaction completes successfully. All of these conditions and actions are mocked in this test to avoid network calls. """ del mock_submit, mock_get, mock_sequence, mock_fee, client deposit = acc1_usd_deposit_transaction_factory() create_stellar_deposit(deposit.id) assert Transaction.objects.get( id=deposit.id).status == Transaction.STATUS.completed