Esempio n. 1
0
def test_authenticate_errors_on_invalid_inputs(node):

    state = node[0].getState(DOMAIN_LEDGER_ID)
    fees_authenticator = FeesAuthNr(state, None)

    req_data = {
        'signatures': {
            'E7QRhdcnhAwA6E46k9EtZo':
            '32H37GfuchojdbNeMxwNUhZJwWyJCz48aP5u1AvN3xhNramVqrq74H4pE8LKMgZw7rAdyrPvHUWzWAZdB243fqhA',
            'CA4bVFDU4GLbX8xZju811o':
            '3tkZU65KeybmkUcrA6HuovVTDD8vsVm2VvB7bpUhPt2MLpez6eRrRvysUutusJz6xryCtk7g1b115pKhNGcqRTss',
            'M9BJDuS24bqbJNvBRsoGg3':
            '00XHdWTeWYRpoyCAZgpM7qA7Ms2MRYu6NpasPagPQRGoUukE2NdSXGonu6dWgsPNgybqW7fotw9BjccXAy7BzMsY',
            'B8fV7naUqLATYocqu7yZ8W':
            '00q55hTSBafovXS9gTNkW1GM9vVF6Y4s2fLEsmew9DaN95rmZ5ZwXj74NgTmGeGszPomWXPsRr5QGNZb6GsG57PV'
        },
        'reqId': 1524500821797147,
        'operation': {
            'fees': {
                '10001': 8,
                '1': 4
            },
            'type': '20000'
        },
        'protocolVersion': 1
    }

    with pytest.raises(InvalidSignatureFormat):
        fees_authenticator.authenticate(req_data)
Esempio n. 2
0
def test_authenticate_success_one_signature(node):
    fees_authenticator = FeesAuthNr(ACCEPTABLE_WRITE_TYPES_FEE,
                                    ACCEPTABLE_QUERY_TYPES_FEE,
                                    ACCEPTABLE_ACTION_TYPES_FEE,
                                    node[0].db_manager.idr_cache, None)

    req_data = {
        'signatures': {
            'E7QRhdcnhAwA6E46k9EtZo':
            '32H37GfuchojdbNeMxwNUhZJwWyJCz48aP5u1AvN3xhNramVqrq74H4pE8LKMgZw7rAdyrPvHUWzWAZdB243fqhA'
        },
        'reqId': 1524500821797147,
        'operation': {
            'fees': {
                '10001': 8,
                '1': 4
            },
            'type': '20000'
        },
        'protocolVersion': 1
    }

    with pytest.raises(InsufficientCorrectSignatures) as ex:
        fees_authenticator.authenticate(req_data)
    assert ex.value.args == (1, 0, req_data['signatures'])
Esempio n. 3
0
def test_authenticate_invalid():
    state = pruning_state()
    fees_authenticator = FeesAuthNr(state, None)
    req_data = {
        'signatures': SIGNATURES,
        'reqId': VALID_REQID,
        'operation': {
            'type': 'INVALID_TXN_TYPE',
            'fees': {
                '1': 4,
                '10001': 8
            }
        }
    }
    with pytest.raises(InvalidClientRequest):
        fees_authenticator.authenticate(req_data, VALID_IDENTIFIER)
Esempio n. 4
0
def test_authenticate_invalid(node):
    fees_authenticator = FeesAuthNr(ACCEPTABLE_WRITE_TYPES_FEE,
                                    ACCEPTABLE_QUERY_TYPES_FEE,
                                    ACCEPTABLE_ACTION_TYPES_FEE,
                                    node[0].db_manager.idr_cache, None)
    req_data = {
        'signatures': SIGNATURES,
        'reqId': VALID_REQID,
        'operation': {
            'type': 'INVALID_TXN_TYPE',
            'fees': {
                '1': 4,
                '10001': 8
            }
        }
    }
    with pytest.raises(InvalidClientRequest):
        fees_authenticator.authenticate(req_data, VALID_IDENTIFIER)
Esempio n. 5
0
def test_authenticate_success_one_signature(node):

    state = node[0].getState(DOMAIN_LEDGER_ID)
    fees_authenticator = FeesAuthNr(state, None)

    req_data = {
        'signatures': {
            'E7QRhdcnhAwA6E46k9EtZo':
            '32H37GfuchojdbNeMxwNUhZJwWyJCz48aP5u1AvN3xhNramVqrq74H4pE8LKMgZw7rAdyrPvHUWzWAZdB243fqhA'
        },
        'reqId': 1524500821797147,
        'operation': {
            'fees': {
                '10001': 8,
                '1': 4
            },
            'type': '20000'
        },
        'protocolVersion': 1
    }

    with pytest.raises(InsufficientCorrectSignatures) as ex:
        fees_authenticator.authenticate(req_data)
    assert ex.value.args == (0, 1)
Esempio n. 6
0
def test_authenticate_success_one_signature(node):

    state = node[0].getState(DOMAIN_LEDGER_ID)
    fees_authenticator = FeesAuthNr(state, None)

    req_data = {
        'signatures': {
            'E7QRhdcnhAwA6E46k9EtZo':
            '32H37GfuchojdbNeMxwNUhZJwWyJCz48aP5u1AvN3xhNramVqrq74H4pE8LKMgZw7rAdyrPvHUWzWAZdB243fqhA'
        },
        'reqId': 1524500821797147,
        'operation': {
            'fees': {
                '10001': 8,
                '1': 4
            },
            'type': '20000'
        },
        'protocolVersion': 1
    }

    value = fees_authenticator.authenticate(req_data)
    assert value is not None
    assert 1 == len(value)