From abf909803c907a22d2c58c8ab5e16eedb3b2badd Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 18 Apr 2018 17:06:25 +0200 Subject: [PATCH] Refactored betting market macros into common header --- tests/betting/betting_tests.cpp | 38 --------------------------- tests/common/betting_test_markets.hpp | 34 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index 484c4da4..c192701b 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -41,11 +41,7 @@ #include #include -#include -#include -#include #include -#include #include @@ -1381,40 +1377,6 @@ BOOST_AUTO_TEST_CASE( cancel_one_event_in_group ) BOOST_AUTO_TEST_SUITE_END() -// 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 -struct simple_bet_test_fixture : database_fixture { - betting_market_id_type capitals_win_betting_market_id; - betting_market_id_type blackhawks_win_betting_market_id; - betting_market_group_id_type moneyline_betting_markets_id; - - simple_bet_test_fixture() - { - ACTORS( (alice)(bob) ); - CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - - // give alice and bob 10k each - transfer(account_id_type(), alice_id, asset(10000)); - 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); - - // 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); - - 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; - - // close betting to prepare for the next operation which will be grading or cancel - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); - generate_blocks(1); - } -}; - BOOST_FIXTURE_TEST_SUITE( simple_bet_tests, simple_bet_test_fixture ) BOOST_AUTO_TEST_CASE( win ) diff --git a/tests/common/betting_test_markets.hpp b/tests/common/betting_test_markets.hpp index 75363daf..f67dc067 100644 --- a/tests/common/betting_test_markets.hpp +++ b/tests/common/betting_test_markets.hpp @@ -137,3 +137,37 @@ using namespace graphene::chain; generate_blocks(1); \ const betting_market_object& cilic_wins_final_market = *db.get_index_type().indices().get().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; + +// 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 +struct simple_bet_test_fixture : database_fixture { + betting_market_id_type capitals_win_betting_market_id; + betting_market_id_type blackhawks_win_betting_market_id; + betting_market_group_id_type moneyline_betting_markets_id; + + simple_bet_test_fixture() + { + ACTORS( (alice)(bob) ); + CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); + + // give alice and bob 10k each + transfer(account_id_type(), alice_id, asset(10000)); + 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); + + // 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); + + 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; + + // 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); + generate_blocks(1); + } +};