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)
def test_create_account_with_invalid_name_by_committee(wallet: Wallet, name_and_error): invalid_name, error = name_and_error response = wallet.create_account_by_committee(DEFAULT_WITNESS, invalid_name, test_account_owner_pub_key) print(response) assert error.value == response['error']['data']['code']
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