Пример #1
0
def test_get_all_auth_rule_transactions_after_write(looper,
                                                    sdk_wallet_trustee,
                                                    sdk_pool_handle):
    auth_action = ADD_PREFIX
    auth_type = NYM
    field = ROLE
    new_value = TRUST_ANCHOR
    constraint = generate_constraint_list(auth_constraints=[generate_constraint_entity(role=TRUSTEE),
                                                            generate_constraint_entity(role=STEWARD)])
    resp = sdk_send_and_check_auth_rule_request(looper,
                                                sdk_pool_handle,
                                                sdk_wallet_trustee,
                                                auth_action=auth_action,
                                                auth_type=auth_type,
                                                field=field,
                                                new_value=new_value,
                                                constraint=constraint)
    str_auth_key = ConfigReqHandler.get_auth_key(resp[0][0][OPERATION])
    resp = sdk_send_and_check_get_auth_rule_request(
        looper, sdk_pool_handle, sdk_wallet_trustee
    )

    result = resp[0][1]["result"][DATA]
    for rule in result:
        key = ConfigReqHandler.get_auth_key(rule)
        if auth_map[key] is None:
            assert {} == rule[CONSTRAINT]
        elif key == str_auth_key:
            assert constraint == rule[CONSTRAINT]
        else:
            assert auth_map[key].as_dict == rule[CONSTRAINT]
Пример #2
0
def test_get_all_auth_rule_transactions_after_write(looper, sdk_wallet_trustee,
                                                    sdk_pool_handle):
    auth_action = ADD_PREFIX
    auth_type = NYM
    field = ROLE
    new_value = TRUST_ANCHOR
    auth_constraint = generate_constraint_list(auth_constraints=[
        generate_constraint_entity(role=TRUSTEE),
        generate_constraint_entity(role=STEWARD)
    ])
    resp = sdk_send_and_check_auth_rule_request(looper,
                                                sdk_pool_handle,
                                                sdk_wallet_trustee,
                                                auth_action=auth_action,
                                                auth_type=auth_type,
                                                field=field,
                                                new_value=new_value,
                                                constraint=auth_constraint)
    auth_key = ConfigReqHandler.get_auth_key(resp[0][0][OPERATION])
    resp = sdk_send_and_check_get_auth_rule_request(looper, sdk_pool_handle,
                                                    sdk_wallet_trustee)
    result = resp[0][1]["result"][DATA]
    full_auth_map = OrderedDict(auth_map)
    full_auth_map.update(sovtoken_auth_map)
    full_auth_map.update(sovtokenfees_auth_map)
    full_auth_map[auth_key] = ConstraintCreator.create_constraint(
        auth_constraint)

    for i, (auth_key, constraint) in enumerate(full_auth_map.items()):
        rule = result[i]
        assert auth_key == ConfigReqHandler.get_auth_key(rule)
        if constraint is None:
            assert {} == rule[CONSTRAINT]
        else:
            assert constraint.as_dict == rule[CONSTRAINT]
Пример #3
0
 def getConfigReqHandler(self):
     return ConfigReqHandler(self.configLedger,
                             self.states[CONFIG_LEDGER_ID],
                             self.getIdrCache(),
                             self.upgrader,
                             self.poolManager,
                             self.poolCfg)
Пример #4
0
def test_get_one_auth_rule_transaction_after_write(looper,
                                                   sdk_wallet_trustee,
                                                   sdk_pool_handle):
    auth_action = ADD_PREFIX
    auth_type = NYM
    field = ROLE
    new_value = TRUST_ANCHOR
    constraint = generate_constraint_list(auth_constraints=[generate_constraint_entity(role=TRUSTEE),
                                                            generate_constraint_entity(role=STEWARD)])
    resp = sdk_send_and_check_auth_rule_request(looper,
                                                sdk_wallet_trustee,
                                                sdk_pool_handle,
                                                auth_action=auth_action, auth_type=auth_type,
                                                field=field, new_value=new_value,
                                                constraint=constraint)
    dict_auth_key = generate_key(auth_action=auth_action, auth_type=auth_type,
                                 field=field, new_value=new_value)
    str_key = ConfigReqHandler.get_auth_key(dict_auth_key)
    resp = sdk_get_auth_rule_request(looper,
                                     sdk_wallet_trustee,
                                     sdk_pool_handle,
                                     dict_auth_key)
    print(config.make_state_path_for_auth_rule(str_key))
    result = resp[0][1]["result"][DATA][config.make_state_path_for_auth_rule(str_key).decode()]
    assert result == constraint
    assert resp[0][1]["result"][STATE_PROOF]
Пример #5
0
def test_get_one_auth_rule_transaction_tmp(looper, sdk_wallet_trustee,
                                           sdk_pool_handle):
    key = generate_key(new_value=TRUSTEE)
    str_key = ConfigReqHandler.get_auth_key(key)
    req, resp = sdk_get_auth_rule_request(looper, sdk_wallet_trustee,
                                          sdk_pool_handle, key)[0]
    assert auth_map.get(str_key).as_dict == resp["result"][DATA][str_key]
Пример #6
0
def test_get_all_auth_rule_transactions_after_write(looper, sdk_wallet_trustee,
                                                    sdk_pool_handle):
    auth_action = ADD_PREFIX
    auth_type = NYM
    field = ROLE
    new_value = TRUST_ANCHOR
    constraint = generate_constraint_list(auth_constraints=[
        generate_constraint_entity(role=TRUSTEE),
        generate_constraint_entity(role=STEWARD)
    ])
    resp = sdk_send_and_check_auth_rule_request(looper,
                                                sdk_wallet_trustee,
                                                sdk_pool_handle,
                                                auth_action=auth_action,
                                                auth_type=auth_type,
                                                field=field,
                                                new_value=new_value,
                                                constraint=constraint)
    auth_key = ConfigReqHandler.get_auth_key(resp[0][0][OPERATION])
    resp = sdk_get_auth_rule_request(looper, sdk_wallet_trustee,
                                     sdk_pool_handle)
    expect = {key: constraint.as_dict for key, constraint in auth_map.items()}
    expect[auth_key] = constraint
    result = resp[0][1]["result"][DATA]
    assert result == expect
Пример #7
0
 def init_config_req_handler(self):
     return ConfigReqHandler(self.configLedger,
                             self.states[CONFIG_LEDGER_ID],
                             self.getIdrCache(), self.upgrader,
                             self.poolManager, self.poolCfg,
                             self.write_req_validator,
                             self.bls_bft.bls_store)
Пример #8
0
def test_get_one_auth_rule_transaction(looper, sdk_wallet_trustee,
                                       sdk_pool_handle):
    key = generate_key()
    str_key = ConfigReqHandler.get_auth_key(key)
    req, resp = sdk_get_auth_rule_request(looper, sdk_wallet_trustee,
                                          sdk_pool_handle, key)[0]
    assert auth_map.get(str_key).as_dict == \
           resp["result"][DATA][config.make_state_path_for_auth_rule(str_key).decode()]
Пример #9
0
 def init_config_req_handler(self):
     return ConfigReqHandler(self.configLedger,
                             self.states[CONFIG_LEDGER_ID],
                             self.states[DOMAIN_LEDGER_ID], self.idrCache,
                             self.upgrader, self.poolManager, self.poolCfg,
                             self.write_req_validator,
                             self.bls_bft.bls_store,
                             self.db_manager.get_store(TS_LABEL))
Пример #10
0
def config_req_handler(config_state, config_ledger):

    return ConfigReqHandler(config_ledger,
                            config_state,
                            idrCache=FakeSomething(),
                            upgrader=FakeSomething(),
                            poolManager=FakeSomething(),
                            poolCfg=FakeSomething(),
                            write_req_validator=FakeSomething())
Пример #11
0
def test_auth_mint(helpers, addresses, looper, sdk_wallet_trustee,
                   sdk_pool_handle):
    """
    1. Send a MINT_PUBLIC txn from 3 TRUSTEE
    2. Change the auth rule for adding MINT_PUBLIC to 1 STEWARD signature
    3. Send a transfer from 3 TRUSTEE, check that auth validation failed.
    4. Send and check that a MINT_PUBLIC request with STEWARD signature pass.
    5. Change the auth rule to a default value.
    6. Send and check a MINT_PUBLIC txn from 3 TRUSTEE.
    """
    outputs = [{ADDRESS: addresses[0], AMOUNT: 1000}]
    helpers.general.do_mint(outputs)

    sdk_send_and_check_auth_rule_request(looper,
                                         sdk_pool_handle,
                                         sdk_wallet_trustee,
                                         auth_action=ADD_PREFIX,
                                         auth_type=MINT_PUBLIC,
                                         field='*',
                                         new_value='*',
                                         constraint=AuthConstraint(
                                             role=STEWARD,
                                             sig_count=1,
                                             need_to_be_owner=False).as_dict)

    outputs = [{ADDRESS: addresses[0], AMOUNT: 1000}]
    with pytest.raises(RequestRejectedException,
                       match="Not enough STEWARD signatures"):
        helpers.general.do_mint(outputs)

    steward_do_mint(helpers, outputs)

    sdk_send_and_check_auth_rule_request(
        looper,
        sdk_pool_handle,
        sdk_wallet_trustee,
        auth_action=ADD_PREFIX,
        auth_type=MINT_PUBLIC,
        field='*',
        new_value='*',
        constraint=sovtoken_auth_map[add_mint.get_action_id()].as_dict)

    helpers.general.do_mint(outputs)
    resp = sdk_send_and_check_get_auth_rule_request(looper, sdk_pool_handle,
                                                    sdk_wallet_trustee)
    full_auth_map = OrderedDict(auth_map)
    full_auth_map.update(sovtoken_auth_map)

    result = resp[0][1]["result"][DATA]
    for i, (auth_key, constraint) in enumerate(full_auth_map.items()):
        rule = result[i]
        assert auth_key == ConfigReqHandler.get_auth_key(rule)
        if constraint is None:
            assert {} == rule[CONSTRAINT]
        else:
            assert constraint.as_dict == rule[CONSTRAINT]
Пример #12
0
def test_get_one_auth_rule_transaction(looper, sdk_wallet_trustee,
                                       sdk_pool_handle):
    key = generate_key()
    str_key = ConfigReqHandler.get_auth_key(key)
    req, resp = sdk_send_and_check_get_auth_rule_request(
        looper, sdk_pool_handle, sdk_wallet_trustee, **key)[0]

    for resp_rule in resp[RESULT][DATA]:
        _check_key(key, resp_rule)
        assert auth_map.get(str_key).as_dict == resp_rule[CONSTRAINT]
Пример #13
0
def test_get_one_auth_rule_transaction(looper, sdk_wallet_trustee,
                                       sdk_pool_handle):
    key = generate_key()
    str_key = ConfigReqHandler.get_auth_key(key)
    req, resp = sdk_send_and_check_get_auth_rule_request(
        looper, sdk_pool_handle, sdk_wallet_trustee, **key)[0]

    result = resp["result"][DATA][0]
    assert len(resp["result"][DATA]) == 1
    _check_key(key, result)
    assert result[CONSTRAINT] == auth_map.get(str_key).as_dict
Пример #14
0
def test_get_one_disabled_auth_rule_transaction(looper, sdk_wallet_trustee,
                                                sdk_pool_handle):
    key = generate_key(auth_action=EDIT_PREFIX,
                       auth_type=SCHEMA,
                       field='*',
                       old_value='*',
                       new_value='*')
    str_key = ConfigReqHandler.get_auth_key(key)
    req, resp = sdk_get_auth_rule_request(looper, sdk_wallet_trustee,
                                          sdk_pool_handle, key)[0]
    assert {} == resp["result"][DATA][config.make_state_path_for_auth_rule(
        str_key).decode()]
Пример #15
0
def test_get_all_auth_rule_transactions(looper, sdk_wallet_trustee,
                                        sdk_pool_handle):
    resp = sdk_send_and_check_get_auth_rule_request(looper, sdk_pool_handle,
                                                    sdk_wallet_trustee)

    result = resp[0][1]["result"][DATA]
    for i, (auth_key, constraint) in enumerate(auth_map.items()):
        rule = result[i]
        assert auth_key == ConfigReqHandler.get_auth_key(rule)
        if constraint is None:
            assert {} == rule[CONSTRAINT]
        else:
            assert constraint.as_dict == rule[CONSTRAINT]