コード例 #1
0
async def test_interledger_confirm_transfer_abort():
    async def foo():
        return {'abort_status': True, 'abort_tx_hash': '0x444'}

    i = Interledger(MockInitiator([]), MockResponder())

    t = Transfer()
    t.payload = {}
    t.payload['id'] = str(uuid4().int)
    t.result = {}
    t.status = TransferStatus.CONFIRMING
    t.confirm_task = asyncio.ensure_future(foo())
    i.results_aborting = [t]

    task = asyncio.ensure_future(i.confirm_transfer())
    assert task.done() == False
    await task

    res = i.results_abort[0]
    assert t.status == TransferStatus.FINALIZED
    assert res['abort_status'] == True
    assert res['abort_tx_hash'] == '0x444'
    assert len(i.results_abort) == 1
    assert len(i.results_commit) == 0

    assert len(i.results_aborting) == 0
コード例 #2
0
async def test_interledger_multi_confirm_transfer_abort():
    async def foo():
        return {'abort_status': True, 'abort_tx_hash': '0x444'}

    init = MockInitiator([])
    resp1 = MockMultiResponder()
    resp2 = MockMultiResponder()
    i = Interledger(init, [resp1, resp2], True, 1)

    t = TransferToMulti()
    t.payload = {}
    t.payload['id'] = str(uuid4().int)
    t.results = []
    t.status = TransferStatus.CONFIRMING
    t.inquiry_decision = True
    t.confirm_task = asyncio.ensure_future(foo())
    i.results_aborting = [t]

    task = asyncio.ensure_future(i.confirm_transfer())
    assert task.done() == False
    await task

    res = i.results_abort[0]
    assert t.status == TransferStatus.FINALIZED
    assert res['abort_status'] == True
    assert res['abort_tx_hash'] == '0x444'
    assert len(i.results_abort) == 1
    assert len(i.results_commit) == 0

    assert len(i.results_aborting) == 0