Esempio n. 1
0
def test_transfer_to_vesting(wallet: Wallet):
    initdelegate_scr_balance_before = wallet.get_account_scr_balance('initdelegate')
    alice_sp_balance_before = wallet.get_account_sp_balance('alice')

    amount = Amount('1.000000000 SCR')

    wallet.transfer_to_scorumpower('initdelegate', 'alice', amount)

    initdelegate_scr_balance_after = wallet.get_account_scr_balance('initdelegate')
    alice_sp_balance_after = wallet.get_account_sp_balance('alice')

    assert initdelegate_scr_balance_after == initdelegate_scr_balance_before - amount
    assert alice_sp_balance_after == alice_sp_balance_before + amount
Esempio n. 2
0
def test_registration_schedule(wallet: Wallet, genesis: Genesis):
    def expected_reward_value(schedule):
        registration_bonus = Amount(genesis['registration_bonus'])
        total_accounts = len(wallet.list_accounts())

        for s in schedule:
            if total_accounts <= s['users']:
                return registration_bonus * s['bonus_percent'] // 100
        return registration_bonus * schedule[-1]['bonus_percent'] // 100

    registration_schedule = list(genesis['registration_schedule'])
    total_users_in_schedule = 0
    for stage in registration_schedule:
        total_users_in_schedule += stage['users']
        stage['users'] = total_users_in_schedule

    names = ['martin', 'doug', 'kevin', 'joe', 'jim']
    accounts = [Account(name) for name in names]

    for account in accounts:
        wallet.create_account_by_committee(
            DEFAULT_WITNESS,
            account.name,
            active=account.active.get_public_key(),
            owner=account.owner.get_public_key(),
            posting=account.posting.get_public_key())

        assert wallet.get_account_sp_balance(account.name) == expected_reward_value(registration_schedule), \
            '{} sp balance differs from expected'.format(account.name)
Esempio n. 3
0
def test_create_account_by_committee(wallet: Wallet, genesis: Genesis,
                                     valid_name):
    accounts_before = wallet.list_accounts()
    creator_balance_before = wallet.get_account_scr_balance(DEFAULT_WITNESS)
    print(
        wallet.create_account_by_committee(
            DEFAULT_WITNESS,
            newname=valid_name,
            owner=test_account_owner_pub_key,
            active=test_account_active_pub_key,
            posting=test_accout_posting_pub_key,
            memo=test_account_memo_key,
        ))
    assert creator_balance_before == wallet.get_account_scr_balance(
        DEFAULT_WITNESS)

    assert wallet.get_account(
        valid_name)['recovery_account'] == DEFAULT_WITNESS

    accounts_after = wallet.list_accounts()
    assert len(accounts_after) == len(accounts_before) + 1
    assert valid_name in accounts_after

    account_by_active_key = wallet.get_account_by_key(
        test_account_active_pub_key)[0][0]
    assert account_by_active_key == valid_name

    account_by_posting_key = wallet.get_account_by_key(
        test_accout_posting_pub_key)[0][0]
    assert account_by_posting_key == valid_name

    account_by_owner_key = wallet.get_account_by_key(
        test_account_owner_pub_key)[0][0]
    assert account_by_owner_key == valid_name

    account_by_memo_key = wallet.get_account_by_key(test_account_memo_key)[0]
    assert account_by_memo_key == []

    new_account_sp_balance_amount = str(
        wallet.get_account_sp_balance(valid_name)).split()[0]
    registration_bonus_amount = genesis['registration_bonus'].split()[0]
    assert new_account_sp_balance_amount == registration_bonus_amount

    # TODO add assert to check registration_supply delta

    keys_auths = wallet.get_account_keys_auths(valid_name)
    assert keys_auths['owner'] == test_account_owner_pub_key
    assert keys_auths['active'] == test_account_active_pub_key
    assert keys_auths['posting'] == test_accout_posting_pub_key
    assert keys_auths['memo'] == test_account_memo_key
Esempio n. 4
0
def test_create_account(wallet: Wallet, valid_name):
    fee = Amount('0.000001000 SCR')
    account_before = wallet.list_accounts()

    creator_balance_before = wallet.get_account_scr_balance(DEFAULT_WITNESS)
    print(
        wallet.create_account(DEFAULT_WITNESS,
                              newname=valid_name,
                              owner=test_account_owner_pub_key,
                              active=test_account_active_pub_key,
                              posting=test_accout_posting_pub_key,
                              memo=test_account_memo_key,
                              fee=fee))
    creator_balance_delta = creator_balance_before - wallet.get_account_scr_balance(
        DEFAULT_WITNESS)
    assert creator_balance_delta == fee

    assert wallet.get_account(
        valid_name)['recovery_account'] == DEFAULT_WITNESS

    accounts_after = wallet.list_accounts()
    assert len(accounts_after) == len(account_before) + 1
    assert valid_name in accounts_after

    account_by_active_key = wallet.get_account_by_key(
        test_account_active_pub_key)[0][0]
    assert account_by_active_key == valid_name

    account_by_posting_key = wallet.get_account_by_key(
        test_accout_posting_pub_key)[0][0]
    assert account_by_posting_key == valid_name

    account_by_owner_key = wallet.get_account_by_key(
        test_account_owner_pub_key)[0][0]
    assert account_by_owner_key == valid_name

    account_by_memo_key = wallet.get_account_by_key(test_account_memo_key)[0]
    assert account_by_memo_key == []

    new_account_sp_balance_amount = str(
        wallet.get_account_sp_balance(valid_name)).split()[0]
    fee_amount = str(fee).split()[0]
    assert new_account_sp_balance_amount == fee_amount

    keys_auths = wallet.get_account_keys_auths(valid_name)
    assert keys_auths['owner'] == test_account_owner_pub_key
    assert keys_auths['active'] == test_account_active_pub_key
    assert keys_auths['posting'] == test_accout_posting_pub_key
    assert keys_auths['memo'] == test_account_memo_key