Summary commiting changes made since the last commit

modified:   libraries/app/impacted.cpp
	modified:   libraries/chain/db_init.cpp
	modified:   libraries/chain/db_maint.cpp
	modified:   libraries/chain/game_object.cpp
	modified:   libraries/chain/include/graphene/chain/protocol/operations.hpp
	modified:   libraries/chain/include/graphene/chain/protocol/tournament.hpp
	modified:   libraries/chain/protocol/tournament.cpp
	modified:   libraries/chain/tournament_object.cpp
	modified:   libraries/wallet/wallet.cpp
	modified:   programs/witness_node/main.cpp
	modified:   tests/CMakeLists.txt
	modified:   tests/common/database_fixture.cpp
	new file:   tests/tournament/tournament_tests.cpp
This commit is contained in:
Roman Olearski 2016-11-28 12:36:18 +01:00
parent 278c9b1683
commit 787019617f
13 changed files with 1231 additions and 162 deletions

View file

@ -222,7 +222,10 @@ struct get_impacted_account_visitor
{
_impacted.insert( op.player_account_id );
}
void operator()( const tournament_payout_operation& op )
{
_impacted.insert( op.payout_account_id );
}
};
void operation_get_impacted_accounts( const operation& op, flat_set<account_id_type>& result )

View file

@ -371,12 +371,12 @@ void database::init_genesis(const genesis_state_type& genesis_state)
a.options.payout_interval = 7*24*60*60;
a.dividend_distribution_account = TOURNAMENT_RAKE_FEE_ACCOUNT_ID;
});
const asset_bitasset_data_object& bit_asset =
create<asset_bitasset_data_object>([&](asset_bitasset_data_object& a) {
a.current_feed.maintenance_collateral_ratio = 1750;
a.current_feed.maximum_short_squeeze_ratio = 1500;
a.current_feed_publication_time = genesis_state.initial_timestamp + fc::hours(1);
});
// const asset_bitasset_data_object& bit_asset =
// create<asset_bitasset_data_object>([&](asset_bitasset_data_object& a) {
// a.current_feed.maintenance_collateral_ratio = 1750;
// a.current_feed.maximum_short_squeeze_ratio = 1500;
// a.current_feed_publication_time = genesis_state.initial_timestamp + fc::hours(1);
// });
const asset_object& core_asset =
create<asset_object>( [&]( asset_object& a ) {
@ -392,7 +392,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
a.options.core_exchange_rate.quote.asset_id = asset_id_type(0);
a.dynamic_asset_data_id = dyn_asset.id;
a.dividend_data_id = div_asset.id;
a.bitasset_data_id = bit_asset.id;
// a.bitasset_data_id = bit_asset.id;
});
assert( asset_id_type(core_asset.id) == asset().asset_id );
assert( get_balance(account_id_type(), asset_id_type()) == asset(dyn_asset.current_supply) );

View file

@ -47,8 +47,6 @@
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/worker_object.hpp>
#define USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // vesting_balance_object by_asset_balance index needed
namespace graphene { namespace chain {
template<class Index>
@ -756,7 +754,6 @@ void schedule_pending_dividend_balances(database& db,
uint64_t total_fee_per_asset_in_core = distribution_base_fee + holder_account_count * (uint64_t)distribution_fee_per_holder;
std::map<account_id_type, share_type> vesting_amounts;
#ifdef USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX
// get only once a collection of accounts that hold nonzero vesting balances of the dividend asset
auto vesting_balances_begin =
vesting_index.indices().get<by_asset_balance>().lower_bound(boost::make_tuple(dividend_holder_asset_obj.id));
@ -769,20 +766,6 @@ void schedule_pending_dividend_balances(database& db,
("owner", vesting_balance_obj.owner(db).name)
("amount", vesting_balance_obj.balance.amount));
}
#else
// get only once a collection of accounts that hold nonzero vesting balances of the dividend asset
const auto& vesting_balances = vesting_index.indices().get<by_id>();
for (const vesting_balance_object& vesting_balance_obj : vesting_balances)
{
if (vesting_balance_obj.balance.asset_id == dividend_holder_asset_obj.id && vesting_balance_obj.balance.amount)
{
vesting_amounts[vesting_balance_obj.owner] += vesting_balance_obj.balance.amount;
dlog("Vesting balance for account: ${owner}, amount: ${amount}",
("owner", vesting_balance_obj.owner(db).name)
("amount", vesting_balance_obj.balance.amount));
}
}
#endif
auto current_distribution_account_balance_iter = current_distribution_account_balance_range.first;
auto previous_distribution_account_balance_iter = previous_distribution_account_balance_range.first;
@ -801,18 +784,6 @@ void schedule_pending_dividend_balances(database& db,
auto itr = vesting_amounts.find(holder_balance_object.owner);
if (itr != vesting_amounts.end())
total_balance_of_dividend_asset += itr->second;
// // working, but potential performance gap?
// auto vesting_range = vesting_index.indices().get<by_account>().equal_range(holder_balance_object.owner);
// for (const vesting_balance_object& vesting_balance : boost::make_iterator_range(vesting_range.first, vesting_range.second)
// {
// if (vesting_balance.balance.asset_id == dividend_holder_asset_obj.id)
// {
// total_balance_of_dividend_asset += vesting_balance.balance.amount;
// dlog("Vesting balances for account: ${owner}, amount: ${amount}",
// ("owner", vesting_balance.owner(db).name)
// ("amount", vesting_balance.balance.amount));
// }
// }
}
// loop through all of the assets currently or previously held in the distribution account
while (current_distribution_account_balance_iter != current_distribution_account_balance_range.second ||
@ -940,7 +911,6 @@ void schedule_pending_dividend_balances(database& db,
// credit each account with their portion, don't send any back to the dividend distribution account
for (const account_balance_object& holder_balance_object : boost::make_iterator_range(holder_balances_begin, holder_balances_end))
{
//if (holder_balance_object.owner != dividend_data.dividend_distribution_account && holder_balance_object.balance.value)
if (holder_balance_object.owner == dividend_data.dividend_distribution_account) continue;
auto holder_balance = holder_balance_object.balance;
@ -948,25 +918,14 @@ void schedule_pending_dividend_balances(database& db,
auto itr = vesting_amounts.find(holder_balance_object.owner);
if (itr != vesting_amounts.end())
holder_balance += itr->second;
// // working, but potential performance gap?
// auto vesting_range = vesting_index.indices().get<by_account>().equal_range(holder_balance_object.owner);
// for (const vesting_balance_object& vesting_balance : boost::make_iterator_range(vesting_range.first, vesting_range.second))
// {
// if (vesting_balance.balance.asset_id == dividend_holder_asset_obj.id)
// {
// holder_balance += vesting_balance.balance.amount;
// dlog("Vesting balances for account: ${owner}, amount: ${amount}",
// ("owner", vesting_balance.owner(db).name)
// ("amount", vesting_balance.balance.amount));
// }
// }
if (holder_balance.value)
fc::uint128_t amount_to_credit(delta_balance.value);
amount_to_credit *= holder_balance.value;
amount_to_credit /= total_balance_of_dividend_asset.value;
share_type shares_to_credit((int64_t)amount_to_credit.to_uint64());
if (shares_to_credit.value)
{
fc::uint128_t amount_to_credit(delta_balance.value);
amount_to_credit *= holder_balance.value;
amount_to_credit /= total_balance_of_dividend_asset.value;
wdump((delta_balance.value)(holder_balance)(total_balance_of_dividend_asset));
share_type shares_to_credit((int64_t)amount_to_credit.to_uint64());
remaining_amount_to_distribute -= shares_to_credit;
@ -990,9 +949,10 @@ void schedule_pending_dividend_balances(database& db,
}
for (const auto& pending_payout : pending_payout_balance_index.indices())
dlog("Pending payout: ${account_name} -> ${amount}",
("account_name", pending_payout.owner(db).name)
("amount", asset(pending_payout.pending_balance, pending_payout.dividend_payout_asset_type)));
if (pending_payout.pending_balance.value)
dlog("Pending payout: ${account_name} -> ${amount}",
("account_name", pending_payout.owner(db).name)
("amount", asset(pending_payout.pending_balance, pending_payout.dividend_payout_asset_type)));
dlog("Remaining balance not paid out: ${amount}",
("amount", asset(remaining_amount_to_distribute, payout_asset_type)));
@ -1144,7 +1104,7 @@ void process_dividend_assets(database& db)
{
const pending_dividend_payout_balance_for_holder_object& pending_balance_object = *pending_balance_object_iter;
if (last_holder_account_id && *last_holder_account_id != pending_balance_object.owner)
if (last_holder_account_id && *last_holder_account_id != pending_balance_object.owner && payouts_for_this_holder.size())
{
// we've moved on to a new account, generate the dividend payment virtual op for the previous one
db.push_applied_operation(asset_dividend_distribution_operation(dividend_holder_asset_obj.id,
@ -1156,14 +1116,15 @@ void process_dividend_assets(database& db)
}
if (is_authorized_asset(db, pending_balance_object.owner(db), pending_balance_object.dividend_payout_asset_type(db)) &&
if (pending_balance_object.pending_balance.value &&
is_authorized_asset(db, pending_balance_object.owner(db), pending_balance_object.dividend_payout_asset_type(db)) &&
is_asset_approved_for_distribution_account(pending_balance_object.dividend_payout_asset_type))
{
dlog("Processing payout of ${asset} to account ${account}",
("asset", asset(pending_balance_object.pending_balance, pending_balance_object.dividend_payout_asset_type))
("account", pending_balance_object.owner(db).name));
db.adjust_balance(pending_balance_object.owner,
db.adjust_balance(pending_balance_object.owner,
asset(pending_balance_object.pending_balance,
pending_balance_object.dividend_payout_asset_type));
payouts_for_this_holder.insert(asset(pending_balance_object.pending_balance,
@ -1179,7 +1140,7 @@ void process_dividend_assets(database& db)
++pending_balance_object_iter;
}
// we will always be left with the last holder's data, generate the virtual op for it now.
if (last_holder_account_id)
if (last_holder_account_id && payouts_for_this_holder.size())
{
// we've moved on to a new account, generate the dividend payment virtual op for the previous one
db.push_applied_operation(asset_dividend_distribution_operation(dividend_holder_asset_obj.id,
@ -1259,7 +1220,6 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
d._total_voting_stake = 0;
const vesting_balance_index& vesting_index = d.get_index_type<vesting_balance_index>();
#ifdef USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX
auto vesting_balances_begin =
vesting_index.indices().get<by_asset_balance>().lower_bound(boost::make_tuple(asset_id_type()));
auto vesting_balances_end =
@ -1271,19 +1231,6 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
("owner", vesting_balance_obj.owner(d).name)
("amount", vesting_balance_obj.balance.amount));
}
#else
const auto& vesting_balances = vesting_index.indices().get<by_id>();
for (const vesting_balance_object& vesting_balance_obj : vesting_balances)
{
if (vesting_balance_obj.balance.asset_id == asset_id_type() && vesting_balance_obj.balance.amount)
{
vesting_amounts[vesting_balance_obj.owner] += vesting_balance_obj.balance.amount;
dlog("Vesting balance for account: ${owner}, amount: ${amount}",
("owner", vesting_balance_obj.owner(d).name)
("amount", vesting_balance_obj.balance.amount));
}
}
#endif
}
void operator()(const account_object& stake_account) {
@ -1305,18 +1252,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
auto itr = vesting_amounts.find(stake_account.id);
if (itr != vesting_amounts.end())
voting_stake += itr->second.value;
// // working, but potential performance gap?
// auto vesting_range = d.get_index_type<vesting_balance_index>().indices().get<by_account>().equal_range(stake_account.id);
// for (const vesting_balance_object& vesting_balance : boost::make_iterator_range(vesting_range.first, vesting_range.second))
// {
// if (vesting_balance.balance.asset_id == asset_id_type())
// {
// voting_stake += vesting_balance.balance.amount.value;
// dlog("Vote_tally_helper vesting balances for account: ${owner}, amount: ${amount}",
// ("owner", vesting_balance.owner(d).name)
// ("amount", vesting_balance.balance.amount));
// }
// }
for( vote_id_type id : opinion_account.options.votes )
{
uint32_t offset = id.instance();

View file

@ -470,7 +470,8 @@ namespace graphene { namespace chain {
{
// we now know who played what, figure out if we have a winner
const rock_paper_scissors_game_details& rps_game_details = game_details.get<rock_paper_scissors_game_details>();
if (rps_game_details.reveal_moves[0]->gesture == rps_game_details.reveal_moves[1]->gesture)
if (rps_game_details.reveal_moves[0] && rps_game_details.reveal_moves[1] &&
rps_game_details.reveal_moves[0]->gesture == rps_game_details.reveal_moves[1]->gesture)
ilog("The game was a tie, both players threw ${gesture}", ("gesture", rps_game_details.reveal_moves[0]->gesture));
else
{

View file

@ -97,7 +97,8 @@ namespace graphene { namespace chain {
tournament_join_operation,
game_move_operation,
asset_update_dividend_operation,
asset_dividend_distribution_operation // VIRTUAL
asset_dividend_distribution_operation, // VIRTUAL
tournament_payout_operation // VIRTUAL
> operation;
/// @} // operations group

View file

@ -36,6 +36,13 @@
namespace graphene { namespace chain {
enum class payout_type
{
prize_award,
buyin_refund,
rake_fee
};
typedef fc::static_variant<rock_paper_scissors_game_options> game_specific_options;
/**
@ -163,8 +170,38 @@ namespace graphene { namespace chain {
void validate()const;
};
struct tournament_payout_operation : public base_operation
{
struct fee_parameters_type {};
asset fee;
/// The account received payout
account_id_type payout_account_id;
/// The tournament generated payout
tournament_id_type tournament_id;
/// The payout amount
asset payout_amount;
payout_type type;
extensions_type extensions;
account_id_type fee_payer()const { return payout_account_id; }
share_type calculate_fee(const fee_parameters_type&)const { return 0; }
void validate()const {}
};
} }
FC_REFLECT_ENUM(graphene::chain::payout_type,
(prize_award)
(buyin_refund)
(rake_fee)
)
FC_REFLECT_TYPENAME( graphene::chain::game_specific_options )
FC_REFLECT_TYPENAME( graphene::chain::game_specific_moves )
FC_REFLECT( graphene::chain::tournament_options,
@ -196,7 +233,16 @@ FC_REFLECT( graphene::chain::game_move_operation,
(player_account_id)
(move)
(extensions))
FC_REFLECT( graphene::chain::tournament_payout_operation,
(fee)
(payout_account_id)
(tournament_id)
(payout_amount)
(type)
(extensions))
FC_REFLECT( graphene::chain::tournament_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::tournament_join_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::game_move_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::tournament_payout_operation::fee_parameters_type, )

View file

@ -61,5 +61,4 @@ void game_move_operation::validate()const
{
}
} } // namespace graphene::chain

View file

@ -180,11 +180,11 @@ namespace graphene { namespace chain {
tournament_details_obj.matches = matches;
});
// OLEK
// find "bye" matches, complete missing player in the next match
for (unsigned i = 0; i < num_matches_in_first_round; ++i)
{
const match_object& match = matches[i](event.db);
if (match.players.size() == 1) // is bye
if (match.players.size() == 1) // is "bye"
{
unsigned tournament_num_matches = tournament_details_obj.matches.size();
unsigned next_round_match_index = (i + tournament_num_matches + 1) / 2;
@ -192,21 +192,19 @@ namespace graphene { namespace chain {
const match_object& next_round_match = tournament_details_obj.matches[next_round_match_index](event.db);
event.db.modify(next_round_match, [&](match_object& next_match) {
next_match.players.emplace_back(match.players[0]);
if (next_match.players.size() > 1) // bye + bye
if (next_match.players.size() > 1) // both previous matches were "bye"
next_match.on_initiate_match(event.db);
});
}
}
// OLEK
#ifdef HELPFULL_DUMP_WHEN_SOLVING_BYE_MATCH_PROBLEM
wlog("###");
wdump((tournament_details_obj.matches[tournament_details_obj.matches.size() - 1]));
for( match_id_type mid : tournament_details_obj.matches )
{
wdump((mid(event.db)));
}
#endif
}
void on_entry(const match_completed& event, tournament_state_machine_& fsm)
@ -243,13 +241,13 @@ namespace graphene { namespace chain {
event.db.modify(next_round_match, [&](match_object& next_match_obj) {
// OLEK
#ifdef HELPFULL_DUMP_WHEN_SOLVING_BYE_MATCH_PROBLEM
wdump((event.match.get_state()));
wdump((event.match));
wdump((other_match.get_state()));
wdump((other_match));
if (!event.match.match_winners.empty()) // if there is a winner
#endif
if (!event.match.match_winners.empty()) // if there is a winner
{
if (winner_index_in_next_match == 0)
next_match_obj.players.insert(next_match_obj.players.begin(), *event.match.match_winners.begin());
@ -257,22 +255,12 @@ namespace graphene { namespace chain {
next_match_obj.players.push_back(*event.match.match_winners.begin());
}
//if (other_match.get_state() == match_state::match_complete)
// OLEK
if (!other_match.match_winners.empty())
if (other_match.get_state() == match_state::match_complete)
{
// // if other match was buy
// if (other_match.games.size() == 0 /*&& next_match_obj.players.size() < 2*/)
// {
// if (winner_index_in_next_match != 0)
// next_match_obj.players.insert(next_match_obj.players.begin(), *other_match.match_winners.begin());
// else
// next_match_obj.players.push_back(*other_match.match_winners.begin());
// }
// OLEK
#ifdef HELPFULL_DUMP_WHEN_SOLVING_BYE_MATCH_PROBLEM
wdump((next_match_obj.get_state()));
wdump((next_match_obj));
#endif
next_match_obj.on_initiate_match(event.db);
}
@ -296,7 +284,16 @@ namespace graphene { namespace chain {
// for a period of time, not as a transfer back to the user; it doesn't matter
// if they are currently authorized to transfer this asset, they never really
// transferred it in the first place
event.db.adjust_balance(payer_pair.first, asset(payer_pair.second, fsm.tournament_obj->options.buy_in.asset_id));
asset amount(payer_pair.second, fsm.tournament_obj->options.buy_in.asset_id);
event.db.adjust_balance(payer_pair.first, amount);
// Generating a virtual operation that shows the payment
tournament_payout_operation op;
op.tournament_id = fsm.tournament_obj->id;
op.payout_amount = amount;
op.payout_account_id = payer_pair.first;
op.type = payout_type::buyin_refund;
event.db.push_applied_operation(op);
}
}
};
@ -305,29 +302,65 @@ namespace graphene { namespace chain {
{
void on_entry(const match_completed& event, tournament_state_machine_& fsm)
{
tournament_object& tournament_obj = *fsm.tournament_obj;
fc_ilog(fc::logger::get("tournament"),
"Tournament ${id} is complete",
("id", fsm.tournament_obj->id));
("id", tournament_obj.id));
tournament_obj.end_time = event.db.head_block_time();
// Distribute prize money when a tournament ends
#ifndef NDEBUG
const tournament_details_object& details = fsm.tournament_obj->tournament_details_id(event.db);
const tournament_details_object& details = tournament_obj.tournament_details_id(event.db);
share_type total_prize = 0;
for (const auto& payer_pair : details.payers)
{
total_prize += payer_pair.second;
}
assert(total_prize == fsm.tournament_obj->prize_pool);
assert(total_prize == tournament_obj.prize_pool);
#endif
assert(event.match.match_winners.size() == 1);
const account_id_type& winner = *event.match.match_winners.begin();
uint16_t rake_fee_percentage = event.db.get_global_properties().parameters.rake_fee_percentage;
share_type rake_amount = (fc::uint128_t(fsm.tournament_obj->prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64();
event.db.adjust_balance(account_id_type(TOURNAMENT_RAKE_FEE_ACCOUNT_ID),
asset(rake_amount, fsm.tournament_obj->options.buy_in.asset_id));
event.db.adjust_balance(winner, asset(fsm.tournament_obj->prize_pool - rake_amount,
fsm.tournament_obj->options.buy_in.asset_id));
fsm.tournament_obj->end_time = event.db.head_block_time();
share_type rake_amount = 0;
const asset_object & asset_obj = tournament_obj.options.buy_in.asset_id(event.db);
optional<asset_dividend_data_id_type> dividend_id = asset_obj.dividend_data_id;
if (dividend_id.valid())
{
rake_amount = (fc::uint128_t(tournament_obj.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64();
}
asset won_prize(tournament_obj.prize_pool - rake_amount, tournament_obj.options.buy_in.asset_id);
tournament_payout_operation op;
if (won_prize.amount.value)
{
// Adjusting balance of winner
event.db.adjust_balance(winner, won_prize);
// Generating a virtual operation that shows the payment
op.tournament_id = tournament_obj.id;
op.payout_amount = won_prize;
op.payout_account_id = winner;
op.type = payout_type::prize_award;
event.db.push_applied_operation(op);
}
if (dividend_id.valid() && rake_amount.value)
{
// Adjusting balance of dividend_distribution_account
const asset_dividend_data_id_type& asset_dividend_data_id_= *dividend_id;
const asset_dividend_data_object& dividend_obj = asset_dividend_data_id_(event.db);
const account_id_type& rake_account_id = dividend_obj.dividend_distribution_account;
asset rake(rake_amount, tournament_obj.options.buy_in.asset_id);
event.db.adjust_balance(rake_account_id, rake);
// Generating a virtual operation that shows the payment
op.payout_amount = rake;
op.payout_account_id = rake_account_id;
op.type = payout_type::rake_fee;
event.db.push_applied_operation(op);
}
}
};
@ -350,45 +383,16 @@ namespace graphene { namespace chain {
fc_ilog(fc::logger::get("tournament"),
"In was_final_match guard, returning ${value}",
("value", event.match.id == tournament_details_obj.matches[tournament_details_obj.matches.size()]));
// OLEK
#ifdef HELPFULL_DUMP_WHEN_SOLVING_BYE_MATCH_PROBLEM
wlog("###");
wdump((event.match.id));
wdump((tournament_details_obj.matches[tournament_details_obj.matches.size() - 1]));
for( match_id_type mid : tournament_details_obj.matches )
{
wdump((mid(event.db)));
}
return event.match.id == tournament_details_obj.matches[tournament_details_obj.matches.size() - 1];
}
#if 0
// OLEK
bool was_buy_match(const match_completed& event)
{
const tournament_details_object& tournament_details_obj = tournament_obj->tournament_details_id(event.db);
fc_ilog(fc::logger::get("tournament"),
"In was_buy_match guard, returning ${value}",
("value", event.match.id == tournament_details_obj.matches[tournament_details_obj.matches.size()]));
// OLEK
wdump((event.match.id));
wdump((event.match));
/*
wdump((tournament_details_obj.matches[tournament_details_obj.matches.size() - 1]));
for( match_id_type mid : tournament_details_obj.matches )
{
wdump((mid(event.db)));
}
return event.match.id == tournament_details_obj.matches[tournament_details_obj.matches.size() - 1];
*/
return true;
}
#endif
return event.match.id == tournament_details_obj.matches[tournament_details_obj.matches.size() - 1];
}
void register_player(const player_registered& event)
{
fc_ilog(fc::logger::get("tournament"),
@ -416,7 +420,6 @@ namespace graphene { namespace chain {
_row < awaiting_start, start_time_arrived, in_progress >,
// +---------------------------+-----------------------------+----------------------------+---------------------+----------------------+
_row < in_progress, match_completed, in_progress >,
//g_row < in_progress, match_completed, in_progress, &x::was_buy_match >,
g_row < in_progress, match_completed, concluded, &x::was_final_match >
// +---------------------------+-----------------------------+----------------------------+---------------------+----------------------+
> {};

View file

@ -134,6 +134,7 @@ public:
std::string operator()(const account_update_operation& op)const;
std::string operator()(const asset_create_operation& op)const;
std::string operator()(const asset_dividend_distribution_operation& op)const;
std::string operator()(const tournament_payout_operation& op)const;
};
template<class T>
@ -3205,6 +3206,18 @@ std::string operation_printer::operator()(const asset_dividend_distribution_oper
return "";
}
std::string operation_printer::operator()(const tournament_payout_operation& op)const
{
asset_object payout_asset = wallet.get_asset(op.payout_amount.asset_id);
out << "Tournament #" << std::string(object_id_type(op.tournament_id)) << " Payout : "
<< "Account '" << wallet.get_account(op.payout_account_id).name
<< "', Amount " << payout_asset.amount_to_pretty_string(op.payout_amount) << ", Type "
<< (op.type == payout_type::buyin_refund ? "buyin refund" : (op.type == payout_type::rake_fee ? "rake fee" : "prize award"))
<< ".";
return "";
}
std::string operation_result_printer::operator()(const void_result& x) const
{
return "";

View file

@ -75,7 +75,7 @@ int main(int argc, char** argv) {
auto witness_plug = node->register_plugin<witness_plugin::witness_plugin>();
auto history_plug = node->register_plugin<account_history::account_history_plugin>();
auto market_history_plug = node->register_plugin<market_history::market_history_plugin>();
auto generate_genesis_plug = node->register_plugin<generate_genesis_plugin::generate_genesis_plugin>();
//auto generate_genesis_plug = node->register_plugin<generate_genesis_plugin::generate_genesis_plugin>();
try
{

View file

@ -17,6 +17,10 @@ file(GLOB PERFORMANCE_TESTS "performance/*.cpp")
add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} )
target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
file(GLOB TOURNAMENT_TESTS "tournament/*.cpp")
add_executable( tournament_test ${TOURNAMENT_TESTS} ${COMMON_SOURCES} )
target_link_libraries( tournament_test graphene_chain graphene_app graphene_account_history graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
file(GLOB BENCH_MARKS "benchmarks/*.cpp")
add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} )
target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_history graphene_time graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )

View file

@ -72,6 +72,7 @@ database_fixture::database_fixture()
if( arg == "--show-test-names" )
std::cout << "running test " << boost::unit_test::framework::current_test_case().p_name << std::endl;
}
auto ahplugin = app.register_plugin<graphene::account_history::account_history_plugin>();
auto mhplugin = app.register_plugin<graphene::market_history::market_history_plugin>();
init_account_pub_key = init_account_priv_key.get_public_key();
@ -163,7 +164,7 @@ void database_fixture::verify_asset_supplies( const database& db )
share_type reported_core_in_orders;
for( const tournament_object& t : tournaments_index )
if (t.get_state() != tournament_state::concluded)
if (t.get_state() != tournament_state::concluded && t.get_state() != tournament_state::registration_period_expired)
total_balances[t.options.buy_in.asset_id] += t.prize_pool;
for( const account_balance_object& b : balance_index )

File diff suppressed because it is too large Load diff