Example #1
0
def test_token_wallet_handle_xfer_invalid_address(test_wallet, address0):
    invalid_address = Address()
    seq_no = 6
    response = {
        "address": invalid_address.address,
        "outputs": [{
            "address": invalid_address.address,
            "amount": 10000
        }],
        "inputs": [{
            "address": invalid_address.address,
            "seqNo": 1
        }],
        "seqNo": seq_no,
        "reqId": 23432,
        "Identifier": "6ouriXMZkLeHsuXrN1X1fd",
        "type": "10002"
    }

    txn = TxnResponse("10002", response, seq_no=seq_no).form_response()
    test_wallet.handle_xfer(txn)
    #Raises KeyError because (6, 10000) has been added to invalid_address obj not address0 obj
    with pytest.raises(KeyError):
        assert address0.outputs[0][seq_no] != 10000 and address0.outputs[1][
            1] != 50000
Example #2
0
def test_token_wallet_on_reply_from_network_invalid_address2(
        test_wallet, address0):
    invalid_address = Address()
    observer_name = "ddcebc22-3364-47e6-8500-0e8a00cd6341"
    req_id = 1517251781147288
    seq_no = 6
    frm = "GammaC"
    result = {
        "Identifier": "6ouriXMZkLeHsuXrN1X1fd",
        "address": invalid_address.address,
        "outputs": [{
            "address": invalid_address.address,
            "amount": 10000
        }],
        "inputs": [{
            "address": invalid_address.address,
            "seqNo": 1
        }],
        "type": "10001",
        "reqId": 1517251781147288,
        "seqNo": seq_no
    }
    num_replies = 2
    txn = TxnResponse("10001", result, seq_no=seq_no).form_response()
    test_wallet.on_reply_from_network(observer_name, req_id, frm, txn,
                                      num_replies)
    with pytest.raises(KeyError):
        assert address0.outputs[0][seq_no] != 10000 and address0.outputs[1][
            1] != 50000
def test_token_req_handler_apply_MINT_PUBLIC_success_with_inputs(
        helpers, addresses, token_handler_a):
    [address1, address2] = addresses
    outputs = [{
        "address": address1,
        "amount": 40
    }, {
        "address": address2,
        "amount": 20
    }]
    request = helpers.request.mint(outputs)
    request.operation[INPUTS] = [[address1, 1]]

    seq_no, txn = token_handler_a.apply(request, CONS_TIME)

    expected = TxnResponse(
        MINT_PUBLIC,
        request.operation,
        signatures=request.signatures,
        req_id=request.reqId,
        frm=request._identifier,
    ).form_response()

    assert get_payload_data(txn) == get_payload_data(expected)
    assert get_req_id(txn) == get_req_id(expected)
    assert get_from(txn) == get_from(expected)
    assert get_sorted_signatures(txn) == get_sorted_signatures(txn)
Example #4
0
def test_token_wallet_handle_xfer_success(test_wallet, address0):
    seq_no = 6
    response = {
        "address": address0.address,
        "outputs": [{
            "address": address0.address,
            "amount": 10000
        }],
        "inputs": [{
            "address": address0.address,
            "seqNo": 1
        }],
        "seqNo": seq_no,
        "reqId": 23432,
        "Identifier": "6ouriXMZkLeHsuXrN1X1fd",
        "type": "10002"
    }

    txn = TxnResponse("10002", response, seq_no=seq_no).form_response()
    test_wallet.handle_xfer(txn)
    assert address0.outputs[0][seq_no] == 10000 and address0.outputs[1][
        1] == 50000