Fix betting market macros, avoid invalidated object references
This commit is contained in:
parent
cb786554fc
commit
81dc9edd96
3 changed files with 589 additions and 738 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -33,110 +33,110 @@ using namespace graphene::chain;
|
|||
#define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
||||
create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \
|
||||
generate_blocks(1); \
|
||||
const sport_object& ice_hockey = *db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \
|
||||
const sport_id_type ice_hockey_id = (*db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \
|
||||
generate_blocks(1); \
|
||||
const event_group_object& nhl = *db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \
|
||||
const event_group_id_type nhl_id = (*db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \
|
||||
generate_blocks(1); \
|
||||
const event_object& capitals_vs_blackhawks = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
||||
const event_id_type capitals_vs_blackhawks_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_rules_object& betting_market_rules = *db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
const betting_market_rules_id_type betting_market_rules_id = (*db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_group_object& moneyline_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
||||
const betting_market_group_id_type moneyline_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
const betting_market_id_type capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
(void)capitals_win_market; (void)blackhawks_win_market;
|
||||
const betting_market_id_type& blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
(void)capitals_win_market_id; (void)blackhawks_win_market_id;
|
||||
|
||||
// create the basic betting market, plus groups for the first, second, and third period results
|
||||
#define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
||||
CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
||||
create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_group_object& first_period_result_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(first_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
||||
const betting_market_group_id_type first_period_result_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& first_period_capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(first_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
const betting_market_id_type first_period_capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& first_period_blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
(void)first_period_capitals_win_market; (void)first_period_blackhawks_win_market; \
|
||||
const betting_market_id_type first_period_blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
(void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \
|
||||
\
|
||||
create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_group_object& second_period_result_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(second_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
||||
const betting_market_group_id_type second_period_result_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& second_period_capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(second_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
const betting_market_id_type second_period_capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& second_period_blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
(void)second_period_capitals_win_market; (void)second_period_blackhawks_win_market; \
|
||||
const betting_market_id_type second_period_blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
(void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \
|
||||
\
|
||||
create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_group_object& third_period_result_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(third_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
||||
const betting_market_group_id_type third_period_result_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& third_period_capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(third_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
const betting_market_id_type third_period_capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& third_period_blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
(void)third_period_capitals_win_market; (void)third_period_blackhawks_win_market;
|
||||
const betting_market_id_type third_period_blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
(void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id;
|
||||
|
||||
#define CREATE_TENNIS_BETTING_MARKET() \
|
||||
create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_rules_object& tennis_rules = *db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin(); \
|
||||
const betting_market_rules_id_type tennis_rules_id = (*db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_sport({{"en", "Tennis"}}); \
|
||||
generate_blocks(1); \
|
||||
const sport_object& tennis = *db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_event_group({{"en", "Wimbledon"}}, tennis.id); \
|
||||
const sport_id_type tennis_id = (*db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_event_group({{"en", "Wimbledon"}}, tennis_id); \
|
||||
generate_blocks(1); \
|
||||
const event_group_object& wimbledon = *db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon.id); \
|
||||
const event_group_id_type wimbledon_id = (*db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \
|
||||
generate_blocks(1); \
|
||||
const event_object& berdych_vs_federer = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon.id); \
|
||||
const event_id_type berdych_vs_federer_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \
|
||||
generate_blocks(1); \
|
||||
const event_object& cilic_vs_querrey = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \
|
||||
const event_id_type& cilic_vs_querrey_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_group_object& moneyline_berdych_vs_federer = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey.id, tennis_rules.id, asset_id_type(), false, 0); \
|
||||
const betting_market_group_id_type moneyline_berdych_vs_federer_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_group_object& moneyline_cilic_vs_querrey = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "T. Berdych defeats R. Federer"}}); \
|
||||
const betting_market_group_id_type moneyline_cilic_vs_querrey_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& berdych_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "R. Federer defeats T. Berdych"}}); \
|
||||
const betting_market_id_type berdych_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& federer_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "M. Cilic defeats S. Querrey"}}); \
|
||||
const betting_market_id_type federer_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& cilic_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "S. Querrey defeats M. Cilic"}});\
|
||||
const betting_market_id_type cilic_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& querrey_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon.id); \
|
||||
const betting_market_id_type querrey_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \
|
||||
generate_blocks(1); \
|
||||
const event_object& cilic_vs_federer = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \
|
||||
const event_id_type& cilic_vs_federer_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_group_object& moneyline_cilic_vs_federer = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "R. Federer defeats M. Cilic"}}); \
|
||||
const betting_market_group_id_type moneyline_cilic_vs_federer_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& federer_wins_final_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "M. Cilic defeats R. Federer"}}); \
|
||||
const betting_market_id_type federer_wins_final_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \
|
||||
generate_blocks(1); \
|
||||
const betting_market_object& cilic_wins_final_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
||||
(void)federer_wins_market;(void)cilic_wins_market;(void)federer_wins_final_market; (void)cilic_wins_final_market; (void)berdych_wins_market; (void)querrey_wins_market;
|
||||
const betting_market_id_type cilic_wins_final_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
(void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id;
|
||||
|
||||
// set up a fixture that places a series of two matched bets, we'll use this fixture to verify
|
||||
// the result in all three possible outcomes
|
||||
|
|
@ -155,19 +155,18 @@ struct simple_bet_test_fixture : database_fixture {
|
|||
transfer(account_id_type(), bob_id, asset(10000));
|
||||
|
||||
// place bets at 10:1
|
||||
place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
|
||||
// reverse positions at 1:1
|
||||
place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
|
||||
capitals_win_betting_market_id = capitals_win_market.id;
|
||||
blackhawks_win_betting_market_id = blackhawks_win_market.id;
|
||||
moneyline_betting_markets_id = moneyline_betting_markets.id;
|
||||
capitals_win_betting_market_id = capitals_win_market_id;
|
||||
blackhawks_win_betting_market_id = blackhawks_win_market_id;
|
||||
|
||||
// close betting to prepare for the next operation which will be grading or cancel
|
||||
update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||
update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||
generate_blocks(1);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -524,17 +524,17 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test )
|
|||
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
|
||||
|
||||
// place bets at 10:1
|
||||
place_bet(ath.paula_id, capitals_win_market.id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.penny_id, capitals_win_market.id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.paula_id, capitals_win_market_id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.penny_id, capitals_win_market_id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
|
||||
// reverse positions at 1:1
|
||||
place_bet(ath.paula_id, capitals_win_market.id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.penny_id, capitals_win_market.id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.paula_id, capitals_win_market_id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.penny_id, capitals_win_market_id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
|
||||
update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||
resolve_betting_market_group(moneyline_betting_markets.id,
|
||||
{{capitals_win_market.id, betting_market_resolution_type::win},
|
||||
{blackhawks_win_market.id, betting_market_resolution_type::not_win}});
|
||||
update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||
resolve_betting_market_group(moneyline_betting_markets_id,
|
||||
{{capitals_win_market_id, betting_market_resolution_type::win},
|
||||
{blackhawks_win_market_id, betting_market_resolution_type::not_win}});
|
||||
generate_block();
|
||||
|
||||
uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage();
|
||||
|
|
@ -559,31 +559,31 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test )
|
|||
issue_uia( ath.paula_id, asset( 1000000, btc_id ) );
|
||||
issue_uia( ath.petra_id, asset( 1000000, btc_id ) );
|
||||
|
||||
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \
|
||||
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \
|
||||
generate_blocks(1); \
|
||||
const event_object& capitals_vs_blackhawks2 = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
||||
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules.id, btc_id, false, 0);
|
||||
const event_id_type capitals_vs_blackhawks2_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2_id, betting_market_rules_id, btc_id, false, 0);
|
||||
generate_blocks(1);
|
||||
const betting_market_group_object& moneyline_betting_markets2 = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin();
|
||||
create_betting_market(moneyline_betting_markets2.id, {{"en", "Washington Capitals win"}});
|
||||
const betting_market_group_id_type moneyline_betting_markets2_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id;
|
||||
create_betting_market(moneyline_betting_markets2_id, {{"en", "Washington Capitals win"}});
|
||||
generate_blocks(1);
|
||||
const betting_market_object& capitals_win_market2 = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin();
|
||||
create_betting_market(moneyline_betting_markets2.id, {{"en", "Chicago Blackhawks win"}});
|
||||
const betting_market_id_type capitals_win_market2_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id;
|
||||
create_betting_market(moneyline_betting_markets2_id, {{"en", "Chicago Blackhawks win"}});
|
||||
generate_blocks(1);
|
||||
const betting_market_object& blackhawks_win_market2 = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin();
|
||||
const betting_market_id_type blackhawks_win_market2_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id;
|
||||
|
||||
// place bets at 10:1
|
||||
place_bet(ath.paula_id, capitals_win_market2.id, bet_type::back, asset(10000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.petra_id, capitals_win_market2.id, bet_type::lay, asset(100000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.paula_id, capitals_win_market2_id, bet_type::back, asset(10000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.petra_id, capitals_win_market2_id, bet_type::lay, asset(100000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
|
||||
// reverse positions at 1:1
|
||||
place_bet(ath.paula_id, capitals_win_market2.id, bet_type::lay, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.petra_id, capitals_win_market2.id, bet_type::back, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.paula_id, capitals_win_market2_id, bet_type::lay, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
place_bet(ath.petra_id, capitals_win_market2_id, bet_type::back, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
|
||||
update_betting_market_group(moneyline_betting_markets2.id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||
resolve_betting_market_group(moneyline_betting_markets2.id,
|
||||
{{capitals_win_market2.id, betting_market_resolution_type::not_win},
|
||||
{blackhawks_win_market2.id, betting_market_resolution_type::win}});
|
||||
update_betting_market_group(moneyline_betting_markets2_id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||
resolve_betting_market_group(moneyline_betting_markets2_id,
|
||||
{{capitals_win_market2_id, betting_market_resolution_type::not_win},
|
||||
{blackhawks_win_market2_id, betting_market_resolution_type::win}});
|
||||
generate_block();
|
||||
|
||||
rake_value = (-10000 + 0 - 110000 + 220000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100;
|
||||
|
|
|
|||
Loading…
Reference in a new issue