Exemple #1
0
def test_client_can_send_request_no_catchup(looper,
                                            poolTxnClientData, tdirWithPoolTxns,
                                            txnPoolNodeSet):
    client, _ = new_client(poolTxnClientData, tdirWithPoolTxns)
    looper.add(client)
    req = random_requests(1)[0]
    looper.run(eventually(can_send_request, client, req))
Exemple #2
0
def test_version_not_set_by_default(looper, txnPoolNodeSet, client1, wallet1,
                                    request_num):
    req_dicts = random_requests(request_num)
    reqs = [Request(operation=op) for op in req_dicts]
    for req in reqs:
        assert req.protocolVersion is None
    reqs = sign_request_objects(wallet1, reqs)
    for req in reqs:
        assert req.protocolVersion is None

    send_signed_requests(client1, reqs)
    waitForSufficientRepliesForRequests(looper, client1, requests=reqs)
def test_client_can_send_request_until_catchup(looper, poolTxnClientData,
                                               tdirWithPoolTxns,
                                               txnPoolNodeSet):
    slow_catch_up(txnPoolNodeSet, 60)

    client, _ = new_client(poolTxnClientData, tdirWithPoolTxns)
    looper.add(client)
    req = random_requests(1)[0]

    with pytest.raises(TestException):
        looper.run(eventually(can_send_request, client, req, timeout=4))

    cancel_slow_catch_up(txnPoolNodeSet)
    looper.run(eventually(can_send_request, client, req))
Exemple #4
0
def test_request_executed_once_and_without_failing_behind(
        tconf, looper, txnPoolNodeSet, client1, wallet1):
    """
    Checks that all requests executed only once and without failing behind in
    wrote transactions

    1. Send request
    2. When it is ordered - send checkpoint to replica to force it
    make garbage collection
    3. Check that ordered request executed and client receives reply
    4. Check that ledgers on all nodes are the same and contain all
    expected transactions
    """

    number_of_requests = 5
    tconf.CHK_FREQ = 1

    for node in txnPoolNodeSet:
        for replica in node.replicas:
            set_checkpoint_faking(replica)

    requests = [
        wallet1.signOp(req) for req in random_requests(number_of_requests)
    ]

    for request in requests:
        send_signed_requests(client1, [request])
        waitForSufficientRepliesForRequests(looper,
                                            client1,
                                            requests=[request])

    expected = [request.reqId for request in requests]
    for node in txnPoolNodeSet:
        real_ledger_state = [
            txn[1]['reqId']
            for txn in node.getLedger(DOMAIN_LEDGER_ID).getAllTxn()
            if 'reqId' in txn[1]
        ]
        assert expected == real_ledger_state
Exemple #5
0
def sdk_random_request_objects(count, protocol_version, identifier=None):
    ops = random_requests(count)
    return [Request(operation=op, reqId=random.randint(10, 100000),
                    protocolVersion=protocol_version, identifier=identifier) for op in ops]
def test_client_can_not_send_read_requests_not_started(poolTxnClientData,
                                                       tdirWithPoolTxns):
    client, _ = new_client(poolTxnClientData, tdirWithPoolTxns)
    req = random_requests(1)[0]
    assert not client.can_send_request(req)