Exemplo n.º 1
0
def test_get_posts_and_comments(wallet: Wallet, posts):
    for post in posts:
        wallet.post_comment(**post)

    response = wallet.get_posts_and_comments(**{"limit": len(posts)})
    validate_response(response, wallet.get_posts_and_comments.__name__)
    assert len(response) == len(posts)
def test_close_after_starttime(wallet_3hf: Wallet, budget, moderator):
    update_budget_time(wallet_3hf, budget)
    budget_balance = Amount(budget["balance"])
    balance_before = wallet_3hf.get_account_scr_balance(budget["owner"])

    response = wallet_3hf.create_budget(**budget)
    create_block = response["block_num"]
    update_budget_balance(wallet_3hf,
                          budget)  # update budget params / set budget id
    per_block = Amount(budget["per_block"])

    balance_after_create = wallet_3hf.get_account_scr_balance(budget["owner"])

    assert balance_before - balance_after_create == budget_balance

    empower_advertising_moderator(wallet_3hf, moderator)
    response = wallet_3hf.close_budget_by_advertising_moderator(
        budget["uuid"], moderator, budget["type"])
    validate_response(
        response, wallet_3hf.close_budget_by_advertising_moderator.__name__)
    close_block = response["block_num"]

    balance_after_close = wallet_3hf.get_account_scr_balance(budget["owner"])
    assert balance_after_close == balance_after_create + budget_balance - per_block * (
        close_block - create_block)

    check_virt_ops(
        wallet_3hf, close_block, close_block, {
            'close_budget_by_advertising_moderator', 'budget_closing',
            'budget_owner_income', 'budget_outgo'
        })
    assert len(wallet_3hf.get_budgets([budget['owner']], budget['type'])) == 0
    assert len(wallet_3hf.list_buddget_owners(budget_type=budget['type'])) == 0
Exemplo n.º 3
0
def test_get_ops_history(wallet: Wallet, block_num):
    wallet.get_block(block_num, wait_for_block=True)
    response = wallet.get_ops_history(-1, 100, 0)  # get all operations
    validate_response(response, wallet.get_ops_history.__name__)
    assert len(
        response
    ) == block_num, "Each block should be provided 'producer_reward' operation."
Exemplo n.º 4
0
def test_active_sp_holder_reward_single_acc_2hf(wallet: Wallet, not_witness_post):
    post = not_witness_post
    account = post["author"]

    def check_reward_operation(start, stop):
        rewards = []
        for i in range(start, stop):
            wallet.get_block(i, wait_for_block=True)
            ops = wallet.get_ops_in_block(i)
            rewards = [data["op"][1] for _, data in ops if data["op"][0].startswith("active")]
            if rewards:
                break
        # Next assert also checks if legacy reward is not provided anymore
        assert len(rewards) == 1, "Should be provided single active_sp_holder_reward payment."
        assert rewards[0]["sp_holder"] == account, "Reward should be payed to specified user."
        return Amount(rewards[0]["reward"])

    apply_hardfork(wallet, 2)

    validate_response(wallet.post_comment(**post), wallet.post_comment.__name__)
    validate_response(wallet.vote(account, account, post["permlink"], 10000), wallet.vote.__name__)

    account_before = wallet.get_account(account)
    dgp_before = wallet.get_dynamic_global_properties()
    assert account_before["active_sp_holders_pending_sp_reward"] == dgp_before["total_pending_sp"]

    # 60 sec for testnet, one week for mainnet
    reward_period_sec = int(wallet.get_config()["SCORUM_ACTIVE_SP_HOLDERS_REWARD_PERIOD"] / 1000000)  # microesc -> sec
    expected_cashout = to_date(account_before["last_vote_time"], tmdelta={"seconds": reward_period_sec})
    actual_cashout = to_date(account_before["active_sp_holders_cashout_time"])
    assert actual_cashout == expected_cashout, \
        "Actual cashout time calculated incorrectly: '%s', expected '%s'" % \
        (date_to_str(actual_cashout), date_to_str(expected_cashout))

    blocks_to_wait = int(reward_period_sec / 3) + 1
    last_block = dgp_before["head_block_number"]
    reward = check_reward_operation(last_block, last_block + blocks_to_wait)

    account_after = wallet.get_account(account)
    assert account_before["balance"] == account_after["balance"]  # until advertising is locked
    assert account_before["scorumpower"] != account_after["scorumpower"]

    reset_cashout = to_date(account_after["active_sp_holders_cashout_time"])
    expected_cashout = to_date(account_before["active_sp_holders_cashout_time"], tmdelta={"seconds": reward_period_sec})
    assert reset_cashout == expected_cashout, \
        "Cashout time for active_sp_holder_reward was not reset: '%s', expected '%s'" % \
        (date_to_str(reset_cashout), date_to_str(expected_cashout))

    dgp_after = wallet.get_dynamic_global_properties()
    assert dgp_before["total_pending_scr"] == dgp_after["total_pending_scr"]  # until advertising is locked
    assert Amount(dgp_after["total_pending_sp"]) == Amount("0 SP")
    assert dgp_before["total_pending_sp"] != dgp_after["total_pending_sp"]
    assert dgp_before["total_scorumpower"] != dgp_after["total_scorumpower"]

    balance_change = Amount(account_after["scorumpower"]) - Amount(account_before["scorumpower"])
    assert balance_change == reward, \
        "Balance change is not equal with reward: '%s', expected '%s'" % (balance_change, reward)

    last_block = dgp_after["head_block_number"]
    check_reward_operation(last_block + 1, last_block + blocks_to_wait)
Exemplo n.º 5
0
def test_get_ops_history_pagination(wallet: Wallet, block_num):
    wallet.get_block(block_num, wait_for_block=True)
    response = wallet.get_ops_history(1, 1, 0)  # get first operation
    validate_response(response, wallet.get_ops_history.__name__)
    assert len(response) == 1, "Should be returned single operation."
    assert response[0][
        0] == 0, "Should be returned first operation (with 'id' = 0)"
def test_close_before_starttime(wallet_3hf: Wallet, budget, moderator):
    update_budget_time(wallet_3hf, budget, start=30,
                       deadline=60)  # to delay opening time for budget
    budget_balance = Amount(budget["balance"])
    balance_before = wallet_3hf.get_account_scr_balance(budget["owner"])

    wallet_3hf.create_budget(**budget)
    update_budget_balance(wallet_3hf,
                          budget)  # update budget params / set budget id

    balance_after_create = wallet_3hf.get_account_scr_balance(budget["owner"])

    assert balance_before - balance_after_create == budget_balance

    empower_advertising_moderator(wallet_3hf, moderator)
    response = wallet_3hf.close_budget_by_advertising_moderator(
        budget["uuid"], moderator, budget["type"])
    validate_response(
        response, wallet_3hf.close_budget_by_advertising_moderator.__name__)

    balance_after_close = wallet_3hf.get_account_scr_balance(budget["owner"])
    assert balance_after_close == balance_after_create + budget_balance

    check_virt_ops(
        wallet_3hf, response['block_num'], response['block_num'], {
            'close_budget_by_advertising_moderator', 'budget_closing',
            'budget_owner_income'
        })
    assert len(wallet_3hf.get_budgets([budget['owner']], budget['type'])) == 0
    assert len(wallet_3hf.list_buddget_owners(budget_type=budget['type'])) == 0
Exemplo n.º 7
0
def test_get_config(wallet: Wallet):
    response = wallet.get_config()
    validate_response(response, wallet.get_config.__name__, [
        ("SCORUM_HARDFORK_REQUIRED_WITNESSES", 17), ("SCORUM_MAX_VOTED_WITNESSES", 20),
        ("SCORUM_MAX_WITNESSES", 21),  # ("SCORUM_ACTIVE_SP_HOLDERS_REWARD_PERIOD", int), due to BLOC-484
        ("SCORUM_ACTIVE_SP_HOLDERS_PER_BLOCK_REWARD_PERCENT", int),
        ("SCORUM_VESTING_WITHDRAW_INTERVALS", 52), ("SCORUM_VESTING_WITHDRAW_INTERVAL_SECONDS", int)
    ])
Exemplo n.º 8
0
def test_get_dynamic_global_properties(wallet: Wallet):
    response = wallet.get_dynamic_global_properties()
    validate_response(response, wallet.get_dynamic_global_properties.__name__, [
        ("head_block_number", int), "head_block_id", "current_witness", "total_supply",
        "circulating_capital", "total_scorumpower", "total_pending_scr", "total_pending_sp",
        "total_witness_reward_scr", "total_witness_reward_sp", "majority_version", ("current_aslot", int),
        "recent_slots_filled", ("participation_count", int), ("last_irreversible_block_num", int),
        "registration_pool_balance", "fund_budget_balance", "reward_pool_balance", "max_virtual_bandwidth",
        "content_reward_scr_balance", "content_reward_sp_balance", ("current_reserve_ratio", int)
    ])
Exemplo n.º 9
0
def test_get_comments(wallet: Wallet, post_with_multilvl_comments):
    posts = post_with_multilvl_comments  # ugly workaround
    for post in posts:
        wallet.post_comment(**post)

    for i in range(1, len(posts)):
        comments = wallet.get_comments(posts[i - 1]["author"],
                                       posts[i - 1]["permlink"], i)
        validate_response(comments, wallet.get_comments.__name__)
        assert len(comments) == 1, "Should be returned single comment"
Exemplo n.º 10
0
def test_get_chain_capital(wallet: Wallet):
    response = wallet.get_chain_capital()
    validate_response(response, wallet.get_chain_capital.__name__, [
        "active_voters_balancer_scr", "active_voters_balancer_sp", "circulating_capital",
        "circulating_scr", "circulating_sp", "content_balancer_scr",
        "content_reward_fifa_world_cup_2018_bounty_fund_sp_balance", "content_reward_fund_scr_balance",
        "content_reward_fund_sp_balance", "current_witness", "dev_pool_scr_balance", "dev_pool_sp_balance",
        "fund_budget_balance", "head_block_id", ("head_block_number", int), "head_block_time",
        "registration_pool_balance", "total_scorumpower", "total_scr", "total_supply", "total_witness_reward_scr",
        "total_witness_reward_sp", "witness_reward_in_sp_migration_fund"
    ])
Exemplo n.º 11
0
def test_get_account(wallet: Wallet):
    response = wallet.get_account(DEFAULT_WITNESS)
    validate_response(response, wallet.get_account.__name__, [
        "active_sp_holders_cashout_time", "active_sp_holders_pending_scr_reward",
        "active_sp_holders_pending_sp_reward", "balance", "scorumpower", "name", "created",
        "last_root_post", "received_scorumpower", ("can_vote", bool), ("created_by_genesis", bool),
        "curation_rewards_sp", "curation_rewards_scr", ("voting_power", int), ("post_count", int),
        "posting_rewards_sp", "posting_rewards_scr", "delegated_scorumpower", "memo_key",
        "last_vote_time", "last_post"
    ])
    assert response["name"] == DEFAULT_WITNESS, "Returned invalid account"
Exemplo n.º 12
0
def test_get_posts_and_comments_truncate(wallet: Wallet, posts, truncate_body):
    for post in posts:
        wallet.post_comment(**post)

    response = wallet.get_posts_and_comments(**{
        "limit": len(posts),
        "truncate_body": truncate_body
    })
    validate_response(response, wallet.get_posts_and_comments.__name__)
    assert len(response) == len(posts)
    for p in response:
        assert len(p["body"]) <= truncate_body
Exemplo n.º 13
0
def test_account_zero_withdraw(wallet: Wallet, account, amount):
    response = wallet.withdraw(account, amount)
    validate_response(response, wallet.withdraw.__name__)

    response = wallet.withdraw(account, Amount("0 SP"))
    validate_response(response, wallet.withdraw.__name__)

    transfers = wallet.get_account_transfers(account)
    expect(len(transfers) == 2, "Was created more withdrawals then was expected.")
    expect(transfers[0][1]["status"] == "interrupted")
    expect(transfers[1][1]["status"] == "empty")
    assert_expectations()
Exemplo n.º 14
0
def test_get_contents(wallet: Wallet, posts):
    for post in posts:
        wallet.post_comment(**post)

    response = wallet.get_contents([{
        "author": p["author"],
        "permlink": p["permlink"]
    } for p in posts])

    validate_response(response, wallet.get_contents.__name__)

    assert len(response) == len(
        posts), "Should be returned all created posts and comments"
Exemplo n.º 15
0
def test_get_parents(wallet: Wallet, posts):
    for post in posts:
        wallet.post_comment(**post)
        content = wallet.get_content(post["author"], post["permlink"])
        parents = wallet.get_parents(**{
            "author": post["author"],
            "permlink": post["permlink"]
        })
        validate_response(parents, wallet.get_parents.__name__)
        assert len(parents) == content["depth"]
        current = post
        for parent in parents:
            assert current["parent_permlink"] == parent["permlink"]
            current = parent
Exemplo n.º 16
0
def test_devcommittee_active_withdraw(wallet: Wallet):
    amount = Amount("10.000000000 SP")

    validate_response(
        wallet.devcommittee_withdraw_vesting(DEFAULT_WITNESS, amount),
        wallet.devcommittee_withdraw_vesting.__name__
    )

    proposals = wallet.list_proposals()
    validate_response(proposals, wallet.list_proposals.__name__)
    assert len(proposals) == 1, "Was created %d proposals, expected only one: %s" % (len(proposals), proposals)

    validate_response(wallet.proposal_vote(DEFAULT_WITNESS, proposals[0]["id"]), wallet.proposal_vote.__name__)

    transfers = wallet.get_devcommittee_transfers()
    validate_response(transfers, wallet.get_devcommittee_transfers.__name__)
    assert len(transfers) == 1, "Was created more transfers then was expected."

    withdraw = transfers[0]
    expect(withdraw["status"] == "active")
    expect(Amount(withdraw["withdrawn"]) == Amount("0 SP"))  # e.g. any payment was not provided yet
    expect(withdraw["op"][0] == "proposal_virtual")
    expect(withdraw["op"][1]["proposal_op"][0] == "development_committee_withdraw_vesting")
    expect(Amount(withdraw["op"][1]["proposal_op"][1]["vesting_shares"]) == amount)
    assert_expectations()
Exemplo n.º 17
0
def test_close_before_starttime(wallet_3hf: Wallet, budget):
    update_budget_time(wallet_3hf, budget, start=30, deadline=60)  # to delay opening time for budget
    balance_before = wallet_3hf.get_account_scr_balance(budget["owner"])
    wallet_3hf.create_budget(**budget)
    update_budget_balance(wallet_3hf, budget)  # update budget params / set budget id
    response = wallet_3hf.close_budget(budget['uuid'], budget["owner"], budget["type"])
    validate_response(response, wallet_3hf.close_budget.__name__)
    balance_after = wallet_3hf.get_account_scr_balance(budget["owner"])
    assert balance_after == balance_before
    check_virt_ops(
        wallet_3hf, response['block_num'], response['block_num'],
        {'close_budget', 'budget_closing', 'budget_owner_income'}
    )
    assert len(wallet_3hf.get_budgets([budget['owner']], budget['type'])) == 0
    assert len(wallet_3hf.list_buddget_owners(budget_type=budget['type'])) == 0
Exemplo n.º 18
0
def test_close_budgets(wallet_3hf: Wallet, opened_budgets_same_acc):
    budgets = opened_budgets_same_acc  # just renaming
    validate_response(
        wallet_3hf.close_budget(budgets[0]["uuid"], budgets[0]["owner"], budgets[0]["type"]),
        wallet_3hf.close_budget.__name__
    )

    rest_budgets = wallet_3hf.get_budgets([budgets[-1]["owner"]], budgets[-1]["type"])
    assert len(rest_budgets) == len(budgets) - 1
    assert all(rb["id"] != budgets[0]["id"] for rb in rest_budgets)
    # delete already deleted
    validate_error_response(
        wallet_3hf.close_budget(budgets[0]['uuid'], budgets[0]["owner"], budgets[0]["type"]),
        wallet_3hf.close_budget.__name__,
        RE_BUDGET_NOT_EXIST
    )
Exemplo n.º 19
0
def test_active_sp_holder_reward_legacy(wallet: Wallet, post, accounts):
    op_name = "active_sp_holders_reward_legacy"

    validate_response(wallet.post_comment(**post), wallet.post_comment.__name__)
    for acc in accounts:
        validate_response(wallet.vote(acc, post["author"], post["permlink"]), wallet.vote.__name__)

    last_block = wallet.get_dynamic_global_properties()["head_block_number"]

    # e.g. next N blocks should be payed active_sp_holders_reward_legacy
    for i in range(last_block, last_block + 5):
        wallet.get_block(i, wait_for_block=True)
        ops = wallet.get_ops_in_block(i)
        rewards = [data["op"][1]["rewarded"] for _, data in ops if data["op"][0] == op_name][0]
        assert len(rewards) == len(accounts), "Was provided unexpected amount of '%s' operations." % op_name
        for acc, _ in rewards:
            assert acc in accounts, "Provided payment to unexpected account: '%s'" % acc
Exemplo n.º 20
0
def test_account_active_withdraw(wallet: Wallet, account, amount):
    response = wallet.withdraw(account, amount)

    validate_response(response, wallet.withdraw.__name__)

    transfers = wallet.get_account_transfers(account)

    expect(len(transfers) == 1, "Was created more withdrawals then was expected.")

    withdraw = transfers[0][1]

    expect(withdraw["status"] == "active")
    expect(Amount(withdraw["withdrawn"]) == Amount("0 SP"))  # e.g. any payment was not provided yet
    expect(withdraw["op"][0] == "withdraw_scorumpower")
    expect(Amount(withdraw["op"][1]["scorumpower"]) == amount)
    expect(withdraw["op"][1]["account"] == account)
    assert_expectations()
Exemplo n.º 21
0
def test_create_budget(wallet: Wallet):
    owner = DEFAULT_WITNESS
    response = wallet.create_budget(owner, Amount("10.000000000 SCR"),
                                    fmt_time_from_now(10),
                                    fmt_time_from_now(40))
    validate_response(response, wallet.create_budget.__name__)

    budget = wallet.get_budgets(owner)[0]
    print(budget)

    per_block_for_10_blocks_budget = Amount('1.000000000 SCR')
    per_block_for_9_blocks_budget = Amount('1.034482758 SCR')

    assert owner in wallet.list_buddget_owners()
    assert Amount(budget['per_block']) in (per_block_for_10_blocks_budget,
                                           per_block_for_9_blocks_budget)
    assert budget['owner'] == owner
Exemplo n.º 22
0
def test_validate_get_content(
        wallet: Wallet, post_with_multilvl_comments, initdelegate_post, bob_comment_lv1, alice_comment_lv2
):
    for post in post_with_multilvl_comments:
        validate_response(wallet.post_comment(**post), wallet.post_comment.__name__)

    time_config = wallet.get_config()

    def validate_cashout_interval(comment: dict):
        date_start = to_date(comment['created'])
        date_finish = to_date(comment['cashout_time'])
        delta = date_finish - date_start
        cashout_window = int(time_config["SCORUM_CASHOUT_WINDOW_SECONDS"])
        assert delta.total_seconds() == cashout_window

    def validate_url(comment: dict):
        if comment['parent_author']:
            assert comment['url'] == '/{category}/@{root_author}/{root_permlink}#@{author}/{permlink}' \
                .format(category=comment['category'],
                        root_author=post['author'],
                        root_permlink=post['permlink'],
                        author=comment['author'],
                        permlink=comment['permlink'])
        else:
            assert comment['url'] == '/{}/@{}/{}'.format(comment['category'], comment['author'], comment['permlink'])

    def validate_content(comment, comment_kwargs, parent=None):
        for key, value in comment_kwargs.items():
            assert comment[key] == value, '{} value differs from expected'.format(key)
        assert comment['category'] == initdelegate_post['parent_permlink']
        expected_depth = parent['depth'] + 1 if parent else 0
        assert comment['depth'] == expected_depth
        assert comment['root_title'] == initdelegate_post['title']
        assert comment['root_comment'] == post['id']
        validate_cashout_interval(comment)
        validate_url(comment)

    post = wallet.get_content(initdelegate_post['author'], initdelegate_post['permlink'])
    validate_content(post, initdelegate_post)

    comment_level_1 = wallet.get_content(bob_comment_lv1['author'], bob_comment_lv1['permlink'])
    validate_content(comment_level_1, bob_comment_lv1, post)

    comment_level_2 = wallet.get_content(alice_comment_lv2['author'], alice_comment_lv2['permlink'])
    validate_content(comment_level_2, alice_comment_lv2, comment_level_1)
def test_close_budgets(wallet_3hf: Wallet, moderator, opened_budgets_same_acc):
    budgets = opened_budgets_same_acc  # just renaming
    empower_advertising_moderator(wallet_3hf, moderator)
    validate_response(
        wallet_3hf.close_budget_by_advertising_moderator(
            budgets[0]["uuid"], moderator, budgets[0]["type"]),
        wallet_3hf.close_budget_by_advertising_moderator.__name__)

    rest_budgets = wallet_3hf.get_budgets([budgets[-1]["owner"]],
                                          budgets[-1]["type"])
    assert len(rest_budgets) == len(budgets) - 1
    assert all(rb["id"] != budgets[0]["id"] for rb in rest_budgets)
    # delete already deleted
    validate_error_response(
        wallet_3hf.close_budget_by_advertising_moderator(
            budgets[0]["uuid"], moderator, budgets[0]["type"]),
        wallet_3hf.close_budget_by_advertising_moderator.__name__,
        RE_BUDGET_NOT_EXIST)
Exemplo n.º 24
0
def test_get_discussions_by_created_exclude_tags(wallet: Wallet, by_tags,
                                                 exclude_tags, expected_cnt,
                                                 only_posts):
    for post in only_posts:
        wallet.post_comment(**post)

    posts = wallet.get_discussions_by(
        "created", **{
            "tags": by_tags,
            "limit": 100,
            "tags_logical_and": False,
            "exclude_tags": exclude_tags
        })
    validate_response(posts, wallet.get_discussions_by.__name__)
    assert len(posts) == expected_cnt
    for post in posts:
        tags = set(json.loads(post["json_metadata"])["tags"])
        assert not tags.intersection(set(exclude_tags))
Exemplo n.º 25
0
def test_account_final_withdraw(wallet: Wallet, account, amount):
    response = wallet.withdraw(account, amount)
    validate_response(response, wallet.withdraw.__name__)

    account_before = wallet.get_account(account)

    constants = wallet.get_config()
    intervals = constants["SCORUM_VESTING_WITHDRAW_INTERVALS"]

    single_payment = amount / intervals

    interval_sec = constants["SCORUM_VESTING_WITHDRAW_INTERVAL_SECONDS"]

    for i in range(1, intervals + 1):
        time.sleep(interval_sec + 1)

        expected_withdraw = single_payment * i

        transfers = wallet.get_account_transfers(account)
        expect(len(transfers) == 1, "Was created more withdrawals then was expected.")

        withdrawn = Amount(transfers[0][1]["withdrawn"])
        expect(
            withdrawn == expected_withdraw,
            "step: %d, actual '%s', expected '%s'" % (i, withdrawn, expected_withdraw)
        )

        account_after = wallet.get_account(account)
        sp_change = Amount(account_before["scorumpower"]) - Amount(account_after["scorumpower"])
        expect(
            sp_change == expected_withdraw,
            "step: %d, actual '%s', expected '%s'" % (i, sp_change, expected_withdraw)
        )

        scr_change = Amount(account_after["balance"]) - Amount(account_before["balance"])
        expect(
            scr_change == expected_withdraw,
            "step: %d, actual '%s', expected '%s'" % (i, scr_change, expected_withdraw)
        )

        assert_expectations()

        if i == intervals:
            assert transfers[0][1]["status"] == "finished"
Exemplo n.º 26
0
def test_create_budget(wallet_3hf: Wallet, node, budget, start, deadline):
    update_budget_time(wallet_3hf, budget, start=start, deadline=deadline + start)
    budget_balance = Amount(budget["balance"])
    balance_before = wallet_3hf.get_account_scr_balance(budget["owner"])
    response = wallet_3hf.create_budget(**budget)
    validate_response(response, wallet_3hf.create_budget.__name__)
    check_virt_ops(wallet_3hf, response["block_num"], response["block_num"], {'create_budget'})
    balance_after = wallet_3hf.get_account_scr_balance(budget["owner"])
    assert balance_before == balance_after + budget_balance

    update_budget_balance(wallet_3hf, budget)
    assert budget_balance == Amount(budget['balance']) + Amount(budget['owner_pending_income']) + \
        Amount(budget['budget_pending_outgo'])

    per_block, _ = calc_per_block(get_per_blocks_count(start, deadline), budget_balance)
    assert per_block == Amount(budget['per_block'])

    budgets_summary = wallet_3hf.get_dynamic_global_properties()['advertising'][DGP_BUDGETS[budget['type']]]
    assert all(budgets_summary[k] == budget[v] for k, v in DGP_PARAMS_MAP.items())
Exemplo n.º 27
0
def test_close_after_starttime(wallet_3hf: Wallet, budget):
    update_budget_time(wallet_3hf, budget)
    balance_before = wallet_3hf.get_account_scr_balance(budget["owner"])
    response = wallet_3hf.create_budget(**budget)
    create_block = response["block_num"]
    update_budget_balance(wallet_3hf, budget)  # update budget params / set budget id
    per_block = Amount(budget["per_block"])

    response = wallet_3hf.close_budget(budget['uuid'], budget["owner"], budget["type"])
    validate_response(response, wallet_3hf.close_budget.__name__)
    close_block = response["block_num"]
    balance_after = wallet_3hf.get_account_scr_balance(budget["owner"])
    assert balance_before == balance_after + per_block * (close_block - create_block)
    check_virt_ops(
        wallet_3hf, close_block, close_block,
        {'close_budget', 'budget_closing', 'budget_outgo', 'budget_owner_income'}
    )
    assert len(wallet_3hf.get_budgets([budget['owner']], budget['type'])) == 0
    assert len(wallet_3hf.list_buddget_owners(budget_type=budget['type'])) == 0
Exemplo n.º 28
0
def test_get_posts_and_comments_pagination(wallet: Wallet, posts):
    for post in posts:
        wallet.post_comment(**post)

    limit = 2  # should be > 1

    responses = []
    response = wallet.get_posts_and_comments(**{"limit": limit})
    validate_response(response, wallet.get_posts_and_comments.__name__)
    while len(response) >= limit:
        responses += response[:-1]
        response = wallet.get_posts_and_comments(
            **{
                "start_author": response[-1]["author"],
                "start_permlink": response[-1]["permlink"],
                "limit": 100
            })
        validate_response(response, wallet.get_posts_and_comments.__name__)
    responses += response
    assert len(responses) == len(posts)
Exemplo n.º 29
0
def test_get_config(wallet: Wallet):
    response = wallet.get_config()
    validate_response(
        response,
        wallet.get_config.__name__,
        [
            ("SCORUM_HARDFORK_REQUIRED_WITNESSES", 17),
            ("SCORUM_MAX_VOTED_WITNESSES", 20),
            (
                "SCORUM_MAX_WITNESSES", 21
            ),  # ("SCORUM_ACTIVE_SP_HOLDERS_REWARD_PERIOD", int), due to BLOC-484
            ("SCORUM_ACTIVE_SP_HOLDERS_PER_BLOCK_REWARD_PERCENT", int),
            ("SCORUM_VESTING_WITHDRAW_INTERVALS", 52),
            ("SCORUM_VESTING_WITHDRAW_INTERVAL_SECONDS", int),
            ("SCORUM_LOW_MEMORY_NODE", bool),
            ("SCORUM_CLEAR_VOTES", bool),
            ("SCORUM_SKIP_BY_TX_ID", bool),
            ("SCORUM_LIVE_TESTNET", bool),
            ("SCORUM_ADVERTISING_CASHOUT_PERIOD_SEC", int),
            ("SCORUM_BUDGETS_LIMIT_PER_OWNER", 100)
        ])
Exemplo n.º 30
0
def test_update_budget(wallet_3hf: Wallet, budget, json_metadata):
    update_budget_time(wallet_3hf, budget)
    wallet_3hf.create_budget(**budget)
    update_budget_balance(wallet_3hf, budget)
    response = wallet_3hf.update_budget(budget['uuid'], budget['owner'],
                                        json_metadata, budget['type'])
    validate_response(response, wallet_3hf.update_budget.__name__,
                      [('block_num', int)])
    check_virt_ops(wallet_3hf, response["block_num"], response["block_num"],
                   {'update_budget'})
    budget_obj = wallet_3hf.get_budget(budget['uuid'], budget['type'])
    assert budget_obj['json_metadata'] == json_metadata
    assert Amount(budget_obj['balance']) == Amount(budget['balance']) - Amount(
        budget['per_block'])
    assert Amount(budget_obj['budget_pending_outgo']) == Amount(budget['budget_pending_outgo']) + \
        Amount(budget['per_block'])
    changed = {"json_metadata", 'balance', 'budget_pending_outgo'}
    assert all(budget[k] == budget_obj[k] for k in set(budget.keys()).difference(changed)), \
        'Not only budget metadata changed after update\n' \
        'before: {}\n' \
        'after: {}'.format(budget, budget_obj)