Beispiel #1
0
def test_state_proof_for_get_fee(looper, helpers,
                                 nodeSetWithIntegratedTokenPlugin,
                                 sdk_pool_handle):
    fees_1 = {NYM_FEES_ALIAS: 1}
    fees_2 = {NYM_FEES_ALIAS: 2}
    node_set = [n.nodeIbStasher for n in nodeSetWithIntegratedTokenPlugin]

    helpers.general.do_set_fees(fees_1)
    response1 = helpers.general.do_get_fees()
    check_state_proof(response1, build_path_for_set_fees(),
                      JsonSerializer().serialize(fees_1))

    config_state = nodeSetWithIntegratedTokenPlugin[0].states[2]
    assert config_state.headHash == config_state.committedHeadHash

    # We delay commit messages to get different committed and uncommitted roots for ledger
    with delay_rules(node_set, cDelay()):
        helpers.general.set_fees_without_waiting(fees_2)
        looper.runFor(3)
        response2 = helpers.general.do_get_fees()
        # Returned state proof for first set_fees, which is committed
        check_state_proof(response2, build_path_for_set_fees(),
                          JsonSerializer().serialize(fees_1))
        # Let's check that uncommitted state differs from committed
        assert config_state.headHash != config_state.committedHeadHash
Beispiel #2
0
def test_get_taa_aml_returns_latest_taa_by_default(looper, nodeSetWithTaa,
                                                   sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_taa_aml(looper, sdk_pool_handle, sdk_wallet_client)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][AML_VERSION] == V2
    check_state_proof(result, '3:latest', taa_aml_value(result, V2, AML2, CONTEXT2))
Beispiel #3
0
def test_get_taa_aml_doesnt_return_taa_aml_when_it_didnt_exist(looper, nodeSetWithTaaAlwaysResponding,
                                                               sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_taa_aml(looper, sdk_pool_handle, sdk_wallet_client,
                            timestamp=TIMESTAMP_V1 - 3)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'] is None
    check_state_proof(result, '3:latest', None)
Beispiel #4
0
def test_get_taa_aml_can_return_taa_aml_for_fresh_ts(looper, nodeSetWithTaaAlwaysResponding,
                                                     sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_taa_aml(looper, sdk_pool_handle, sdk_wallet_client,
                            timestamp=TIMESTAMP_V2 + 2)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][TXN_AUTHOR_AGREEMENT_VERSION] == V2
    check_state_proof(result, '3:latest', taa_aml_value(result, V2, AML2, CONTEXT2))
Beispiel #5
0
def test_get_taa_aml_can_return_taa_for_current_version(looper, nodeSetWithTaa,
                                                        sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_taa_aml(looper, sdk_pool_handle, sdk_wallet_client, version=V2)[1]

    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][TXN_AUTHOR_AGREEMENT_VERSION] == V2
    check_state_proof(result, '3:v:{}'.format(V2), taa_aml_value(result, V2, AML2, CONTEXT2))
Beispiel #6
0
def test_get_taa_aml_doesnt_return_taa_for_nonexistent_version(looper, nodeSetWithTaa,
                                                               sdk_pool_handle, sdk_wallet_client):
    invalid_version = randomString(16)
    reply = sdk_get_taa_aml(looper, sdk_pool_handle, sdk_wallet_client,
                            version=invalid_version)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'] is None
    check_state_proof(result, '3:v:{}'.format(invalid_version), None)
def test_get_txn_author_agreement_doesnt_return_taa_when_it_didnt_exist(
        looper, nodeSetWithTaa, sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_txn_author_agreement(looper,
                                         sdk_pool_handle,
                                         sdk_wallet_client,
                                         timestamp=TIMESTAMP_V1 - 2)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'] is None
    check_state_proof(result, '2:latest', None)
Beispiel #8
0
def test_get_txn_author_agreement_returns_latest_taa_by_default(
        looper, set_txn_author_agreement_aml, nodeSetWithTaa, sdk_pool_handle,
        sdk_wallet_client):
    reply = sdk_get_txn_author_agreement(looper, sdk_pool_handle,
                                         sdk_wallet_client)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][TXN_AUTHOR_AGREEMENT_TEXT] == TEXT_V2
    assert result['data'][TXN_AUTHOR_AGREEMENT_VERSION] == V2
    check_state_proof(result, '2:latest', DIGEST_V2)
def test_get_txn_author_agreement_works_on_clear_state(params, state_key,
                                                       looper,
                                                       nodeSetWithoutTaa,
                                                       sdk_pool_handle,
                                                       sdk_wallet_client):
    reply = sdk_get_txn_author_agreement(looper, sdk_pool_handle,
                                         sdk_wallet_client, **params)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'] is None
    check_state_proof(result, state_key, None)
def test_get_txn_author_agreement_doesnt_return_taa_for_nonexistent_digest(
        looper, nodeSetWithTaa, sdk_pool_handle, sdk_wallet_client):
    invalid_digest = randomString(16)
    reply = sdk_get_txn_author_agreement(looper,
                                         sdk_pool_handle,
                                         sdk_wallet_client,
                                         digest=invalid_digest)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'] is None
    check_state_proof(result, '2:d:{}'.format(invalid_digest), None)
def test_get_txn_author_agreement_can_return_taa_for_current_version(
        looper, nodeSetWithTaa, sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_txn_author_agreement(looper,
                                         sdk_pool_handle,
                                         sdk_wallet_client,
                                         version=V2)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][TXN_AUTHOR_AGREEMENT_TEXT] == TEXT_V2
    assert result['data'][TXN_AUTHOR_AGREEMENT_VERSION] == V2
    check_state_proof(result, '2:v:{}'.format(V2), DIGEST_V2)
Beispiel #12
0
def test_get_txn_author_agreement_can_return_taa_for_fresh_ts(
        looper, nodeSetWithTaa, sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_txn_author_agreement(looper,
                                         sdk_pool_handle,
                                         sdk_wallet_client,
                                         timestamp=TIMESTAMP_V2 + 2)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][TXN_AUTHOR_AGREEMENT_TEXT] == TEXT_V2
    assert result['data'][TXN_AUTHOR_AGREEMENT_VERSION] == V2
    check_state_proof(result, '2:latest', DIGEST_V2)
Beispiel #13
0
def test_get_taa_aml_can_return_taa_aml_for_old_ts(looper, nodeSetWithTaa,
                                                   sdk_pool_handle,
                                                   sdk_wallet_client):
    reply = sdk_get_taa_aml(looper,
                            sdk_pool_handle,
                            sdk_wallet_client,
                            timestamp=TIMESTAMP_V2 - 2)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][TXN_AUTHOR_AGREEMENT_VERSION] == V1
    check_state_proof(result, '3:latest',
                      taa_aml_value(result, V1, AML1, CONTEXT1))
Beispiel #14
0
def test_get_txn_author_agreement_can_return_taa_for_old_digest(
        looper, nodeSetWithTaa, sdk_pool_handle, sdk_wallet_client):
    reply = sdk_get_txn_author_agreement(looper,
                                         sdk_pool_handle,
                                         sdk_wallet_client,
                                         digest=DIGEST_V1)[1]
    assert reply['op'] == REPLY

    result = reply['result']
    assert result['data'][TXN_AUTHOR_AGREEMENT_TEXT] == TEXT_V1
    assert result['data'][TXN_AUTHOR_AGREEMENT_VERSION] == V1
    check_state_proof(result, '2:d:{}'.format(DIGEST_V1),
                      taa_value(result, TEXT_V1, V1))
Beispiel #15
0
def test_get_fees_when_no_fees_set(helpers, looper):
    def _freshness_done():
        assert audit_ledger.size == length_after + 1

    for n in helpers.node._nodes:
        curr_state = n.states[CONFIG_LEDGER_ID]
        curr_state.remove(build_path_for_set_fees().encode())
    """
    Update config state
    """
    primary = helpers.node.get_primary_node()
    audit_ledger = primary.getLedger(AUDIT_LEDGER_ID)
    length_after = audit_ledger.size
    primary.master_replica._do_send_3pc_batch(ledger_id=CONFIG_LEDGER_ID)
    looper.run(eventually(_freshness_done))
    """
    GET_FEES
    """
    response = helpers.general.do_get_fees()
    ledger_fees = response[FEES]
    assert ledger_fees == {}
    check_state_proof(response, build_path_for_set_fees(), None)
    helpers.node.assert_set_fees_in_memory({})