Merge branch 'develop' into GRPH-59-Proposal-failure-handling

This commit is contained in:
Miha Čančula 2019-09-02 11:14:48 +02:00
commit a797787f02
No known key found for this signature in database
GPG key ID: 84D83487B62026E0
9 changed files with 238 additions and 231 deletions

4
.gitignore vendored
View file

@ -12,6 +12,8 @@ hardfork.hpp
build_xc
data
build
libraries/utilities/git_revision.cpp
libraries/wallet/Doxyfile
@ -43,4 +45,4 @@ object_database/*
*.pyo
.vscode
.DS_Store
.idea
.idea

View file

@ -23,8 +23,8 @@ RUN \
libssl-dev \
libtool \
locales \
pkg-config \
ntp \
pkg-config \
wget \
&& \
apt-get clean && \
@ -34,9 +34,6 @@ RUN \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ADD . /peerplays-core
WORKDIR /peerplays-core
# Compile Boost
RUN \
BOOST_ROOT=$HOME/boost_1_67_0 && \
@ -47,6 +44,9 @@ RUN \
./b2 install && \
cd ..
ADD . /peerplays-core
WORKDIR /peerplays-core
# Compile Peerplays
RUN \
BOOST_ROOT=$HOME/boost_1_67_0 && \

View file

@ -204,7 +204,7 @@ block_production_condition::block_production_condition_enum witness_plugin::bloc
break;
case block_production_condition::no_private_key:
ilog("Not producing block because I don't have the private key for ${scheduled_key}",
("n", capture["n"])("t", capture["t"])("c", capture["c"]));
("scheduled_key", capture["scheduled_key"]));
break;
case block_production_condition::low_participation:
elog("Not producing block because node appears to be on a minority fork with only ${pct}% witness participation",

View file

@ -49,11 +49,11 @@
struct enable_betting_logging_config {
enable_betting_logging_config()
{
{
fc::logger::get("betting").add_appender(fc::appender::get("stdout"));
fc::logger::get("betting").set_log_level(fc::log_level::debug);
}
~enable_betting_logging_config() {
~enable_betting_logging_config() {
fc::logger::get("betting").remove_appender(fc::appender::get("stdout"));
}
};
@ -66,8 +66,8 @@ using namespace graphene::chain::keywords;
// While the bets are placed, stored, and sorted using the decimal form of their odds, matching
// uses the ratios to ensure no rounding takes place.
// The allowed odds are defined by rules that can be changed at runtime.
// For reference when designing/debugging tests, here is the list of allowed decimal odds and their
// The allowed odds are defined by rules that can be changed at runtime.
// For reference when designing/debugging tests, here is the list of allowed decimal odds and their
// corresponding ratios as set in the genesis block.
//
// decimal ratio | decimal ratio | decimal ratio | decimal ratio | decimal ratio | decimal ratio
@ -129,7 +129,7 @@ using namespace graphene::chain::keywords;
// 1.55 20:11 | 2.28 25:32 | 4.3 10:33 | 22 1:21 | 400 1:399 | 980 1:979
// 1.56 25:14 | 2.3 10:13 | 4.4 5:17 | 23 1:22 | 410 1:409 | 990 1:989
// 1.57 100:57 | 2.32 25:33 | 4.5 2:7 | 24 1:23 | 420 1:419 | 1000 1:999
// 1.58 50:29 | 2.34 50:67 | 4.6 5:18 | 25 1:24 | 430 1:429 |
// 1.58 50:29 | 2.34 50:67 | 4.6 5:18 | 25 1:24 | 430 1:429 |
// 1.59 100:59 | 2.36 25:34 | 4.7 10:37
#define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(binned_order_books)
const auto& bet_odds_idx = db.get_index_type<bet_object_index>().indices().get<by_odds>();
auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
while (bet_iter != bet_odds_idx.end() &&
while (bet_iter != bet_odds_idx.end() &&
bet_iter->betting_market_id == capitals_win_market.id)
{
idump((*bet_iter));
@ -366,7 +366,7 @@ BOOST_AUTO_TEST_CASE(binned_order_books)
}
bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
while (bet_iter != bet_odds_idx.end() &&
while (bet_iter != bet_odds_idx.end() &&
bet_iter->betting_market_id == capitals_win_market.id)
{
idump((*bet_iter));
@ -382,10 +382,10 @@ BOOST_AUTO_TEST_CASE(binned_order_books)
// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100);
// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100);
// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100);
//
//
// binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1);
// idump((binned_orders_point_one));
//
//
// // the binned orders returned should be chosen so that we if we assume those orders are real and we place
// // matching lay orders, we will completely consume the underlying orders and leave no orders on the books
// //
@ -398,20 +398,20 @@ BOOST_AUTO_TEST_CASE(binned_order_books)
// share_type back_amount = bet_object::get_approximate_matching_amount(binned_order.amount_to_bet, binned_order.backer_multiplier, bet_type::lay, true /* round up */);
// ilog("Alice is backing with ${back_amount} at odds ${odds} to match the binned lay amount ${lay_amount}", ("back_amount", back_amount)("odds", binned_order.backer_multiplier)("lay_amount", binned_order.amount_to_bet));
// place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(back_amount, asset_id_type()), binned_order.backer_multiplier);
//
//
// }
//
//
//
//
// bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
// while (bet_iter != bet_odds_idx.end() &&
// while (bet_iter != bet_odds_idx.end() &&
// bet_iter->betting_market_id == capitals_win_market.id)
// {
// idump((*bet_iter));
// ++bet_iter;
// }
//
//
// BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)) == bet_odds_idx.end());
//
//
} FC_LOG_AND_RETHROW()
}
@ -426,9 +426,9 @@ BOOST_AUTO_TEST_CASE( peerplays_sport_create_test )
transfer(account_id_type(), alice_id, asset(10000000));
transfer(account_id_type(), bob_id, asset(10000000));
// have bob lay a bet for 1M (+20k fees) at 1:1 odds
// have bob lay a bet for 1M (+20k fees) at 1:1 odds
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
// have alice back a matching bet at 1:1 odds (also costing 1.02M)
// have alice back a matching bet at 1:1 odds (also costing 1.02M)
place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000);
@ -522,7 +522,7 @@ ilog("message");
BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value);
// now have bob match it with a back of 300 at 1.5
// This should:
// This should:
// match the full 47 @ 1.94 with 50
// match the full 91 @ 1.91 with 100
// bob's balance goes down by 300 (150 is matched, 150 is still on the books)
@ -560,7 +560,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts2)
BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value);
// now have bob match it with a back of 900 at 1.5
// This should:
// This should:
// match all 500 of bob's bet, and leave 400 @ 1.5 on the books
// bob's balance goes down by the 900 he paid (500 matched, 400 unmatched)
// alice's bet is completely removed from the books.
@ -596,7 +596,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts3)
BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value);
// now have bob match it with a back of 1000 at 1.5
// This should:
// This should:
// match all of the 470 @ 1.94 with 500, and leave 500 left on the books
// bob's balance goes down by the 1000 he paid, 500 matching, 500 unmatching
// alice's bet is removed from the books
@ -638,18 +638,18 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts4)
// put another way, bob wants to buy a payout of up to 1807.2289 if the
// capitals win, and he is willing to pay up to 3000 to do so.
// * The first thing that happens is bob's bet gets rounded down to something
// that can match exactly. 2.66 is 50:83 odds, so bob's bet is
// that can match exactly. 2.66 is 50:83 odds, so bob's bet is
// reduced to 2988, which should match against 1800.
// So bob gets an immediate refund of 12
// * The next thing that happens is a match against the top bet on the order book.
// That's 1000 @ 1.89. We match at those odds (100:89), so bob will fully match
// this bet, paying 890 to get 1000 of his desired win position.
// this bet, paying 890 to get 1000 of his desired win position.
// * this top bet is removed from the order books
// * bob now has 1000 of the 1800 win position he wants. we adjust his bet
// so that what is left will only match 800. This means we will
// so that what is left will only match 800. This means we will
// refund bob 770. His remaining bet is now lay 1328 @ 2.66
// * Now we match the next bet on the order books, which is 1000 @ 1.97 (100:97).
// Bob only wants 800 of 1000 win position being offered, so he will not
// Bob only wants 800 of 1000 win position being offered, so he will not
// completely consume this bet.
// * Bob pays 776 to get his 800 win position.
// * alice's top bet on the books is reduced 200 @ 1.97
@ -688,9 +688,9 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts5)
// put another way, bob wants to buy a payout of up to 1122.4 if the
// capitals win, and he is willing to pay up to 1100 to do so.
// * The first thing that happens is bob's bet gets rounded down to something
// that can match exactly. 1.98 (50:49) odds, so bob's bet is
// that can match exactly. 1.98 (50:49) odds, so bob's bet is
// reduced to 1078, which should match against 1100.
// So bob gets an immediate refund of 22
// So bob gets an immediate refund of 22
// * The next thing that happens is a match against the top bet on the order book.
// That's 1100 @ 1.86, At these odds, bob's 980 can buy all 1100 of bet, he
// pays 1100:946.
@ -777,7 +777,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts6)
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(5000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10);
ilog("Order books after bob's matching lay bet:");
bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
while (bet_iter != bet_odds_idx.end() &&
while (bet_iter != bet_odds_idx.end() &&
bet_iter->betting_market_id == capitals_win_market.id)
{
idump((*bet_iter));
@ -857,7 +857,7 @@ BOOST_AUTO_TEST_CASE(inexact_odds)
BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value);
// now have bob match it with a back of 300 at 1.91
// This should:
// This should:
// match the full 47 @ 1.94 with 50
// match the full 91 @ 1.91 with 100
// leaving 150
@ -907,28 +907,28 @@ BOOST_AUTO_TEST_CASE(bet_reversal_test)
// generate_blocks(1);
// ACTORS( (alice)(bob) );
// CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
//
//
// transfer(account_id_type(), alice_id, asset(10000000));
// transfer(account_id_type(), bob_id, asset(10000000));
// int64_t alice_expected_balance = 10000000;
// BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance);
// int64_t bob_expected_balance = 10000000;
// BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance);
//
//
// // back with alice's entire balance
// place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
// alice_expected_balance -= 10000000;
// BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance);
//
//
// // lay with bob's entire balance, which fully matches bob's bet
// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
// bob_expected_balance -= 10000000;
// BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance);
//
//
// // reverse the bet
// place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
// BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance);
//
//
// // try to re-reverse it, but go too far
// BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception);
// BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance);
@ -952,7 +952,7 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test)
BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value);
BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value);
idump((capitals_win_market.get_status()));
idump((capitals_win_market.get_status()));
// lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's
// nothing for it to match, so it should be canceled
@ -1049,7 +1049,7 @@ BOOST_AUTO_TEST_CASE(test_settled_market_states)
BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value);
BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value);
idump((capitals_win_market.get_status()));
idump((capitals_win_market.get_status()));
BOOST_TEST_MESSAGE("setting the event to in_progress");
update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress);
@ -1091,48 +1091,48 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting
try
{
const auto& bet_odds_idx = db.get_index_type<bet_object_index>().indices().get<by_odds>();
ACTORS( (alice)(bob) );
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
generate_blocks(1);
update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::in_play);
generate_blocks(1);
transfer(account_id_type(), alice_id, asset(10000000));
transfer(account_id_type(), bob_id, asset(10000000));
share_type alice_expected_balance = 10000000;
share_type bob_expected_balance = 10000000;
BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value);
BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value);
generate_blocks(1);
BOOST_TEST_MESSAGE("Testing basic delayed bet mechanics");
// alice backs 100 at odds 2
BOOST_TEST_MESSAGE("Alice places a back bet of 100 at odds 2.0");
bet_id_type delayed_back_bet = place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
generate_blocks(1);
// verify the bet hasn't been placed in the active book
auto first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
BOOST_CHECK(first_bet_in_market == bet_odds_idx.end());
// after 3 blocks, the delay should have expired and it will be promoted to the active book
generate_blocks(2);
first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
auto last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id));
BOOST_CHECK(first_bet_in_market != bet_odds_idx.end());
BOOST_CHECK(std::distance(first_bet_in_market, last_bet_in_market) == 1);
for (const auto& bet : boost::make_iterator_range(first_bet_in_market, last_bet_in_market))
edump((bet));
// bob lays 100 at odds 2 to match alice's bet currently on the books
BOOST_TEST_MESSAGE("Bob places a lay bet of 100 at odds 2.0");
/* bet_id_type delayed_lay_bet = */ place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
edump((db.get_global_properties().parameters.block_interval)(db.head_block_time()));
// the bet should not enter the order books before a block has been generated
first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
@ -1140,7 +1140,7 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting
for (const auto& bet : bet_odds_idx)
edump((bet));
generate_blocks(1);
// bob's bet will still be delayed, so the active order book will only contain alice's bet
first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id));
last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id));
@ -1148,12 +1148,12 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting
BOOST_CHECK(std::distance(first_bet_in_market, last_bet_in_market) == 1);
for (const auto& bet : boost::make_iterator_range(first_bet_in_market, last_bet_in_market))
edump((bet));
// once bob's bet's delay has expired, the two bets will annihilate each other, leaving
// an empty order book
generate_blocks(2);
BOOST_CHECK(bet_odds_idx.empty());
// now test that when we cancel all bets on a market, delayed bets get canceled too
BOOST_TEST_MESSAGE("Alice places a back bet of 100 at odds 2.0");
delayed_back_bet = place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
@ -1178,7 +1178,7 @@ BOOST_AUTO_TEST_CASE( chained_market_create_test )
{
{
const flat_set<witness_id_type>& active_witnesses = db.get_global_properties().active_witnesses;
BOOST_TEST_MESSAGE("Creating a sport and competitors in the same proposal");
{
// operation 0 in the transaction
@ -1239,7 +1239,7 @@ BOOST_AUTO_TEST_CASE( chained_market_create_test )
tx.operations.push_back(proposal_op);
set_expiration(db, tx);
sign(tx, init_account_priv_key);
db.push_transaction(tx);
}
@ -1311,7 +1311,7 @@ BOOST_AUTO_TEST_CASE( testnet_witness_block_production_error )
BOOST_AUTO_TEST_CASE( cancel_one_event_in_group )
{
// test that creates an event group with two events in it. We walk one event through the
// test that creates an event group with two events in it. We walk one event through the
// usual sequence and cancel it, verify that it doesn't alter the other event in the group
try
{
@ -1446,7 +1446,7 @@ BOOST_AUTO_TEST_SUITE_END()
struct simple_bet_test_fixture_2 : database_fixture {
betting_market_id_type capitals_win_betting_market_id;
simple_bet_test_fixture_2()
simple_bet_test_fixture_2()
{
ACTORS( (alice)(bob) );
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
@ -1467,7 +1467,7 @@ struct simple_bet_test_fixture_2 : database_fixture {
// was already "promised" to her lay bet, so the 500 she would have received is placed in her refundable_unmatched_bets)
place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
// match another 500, which will fully cancel bob's lay position and return the other 500 he had locked up in his position.
// match another 500, which will fully cancel bob's lay position and return the other 500 he had locked up in his position.
// alice's back position is now canceled, 1500 remains of her unmatched lay bet, and the 500 from canceling her position has
// been moved to her refundable_unmatched_bets
place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
@ -1499,15 +1499,15 @@ BOOST_AUTO_TEST_CASE(sport_delete_test)
try
{
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
const auto& event_group_1 = create_event_group({{"en", "group1"}}, ice_hockey.id);
const auto& event_group_2 = create_event_group({{"en", "group2"}}, ice_hockey.id);
delete_sport(ice_hockey.id);
const auto& sport_by_id = db.get_index_type<sport_object_index>().indices().get<by_id>();
BOOST_CHECK(sport_by_id.end() == sport_by_id.find(ice_hockey.id));
const auto& event_group_by_id = db.get_index_type<event_group_object_index>().indices().get<by_id>();
BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(event_group_1.id));
BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(event_group_2.id));
@ -1519,10 +1519,10 @@ BOOST_AUTO_TEST_CASE(sport_delete_test_not_proposal)
try
{
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
sport_delete_operation sport_delete_op;
sport_delete_op.sport_id = ice_hockey.id;
BOOST_CHECK_THROW(force_operation_by_witnesses(sport_delete_op), fc::exception);
} FC_LOG_AND_RETHROW()
}
@ -1533,9 +1533,9 @@ BOOST_AUTO_TEST_CASE(sport_delete_test_not_proposal)
// try
// {
// CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
//
//
// delete_sport(ice_hockey.id);
//
//
// BOOST_CHECK_THROW(delete_sport(ice_hockey.id), fc::exception);
// } FC_LOG_AND_RETHROW()
// }
@ -1546,26 +1546,26 @@ BOOST_AUTO_TEST_CASE(event_group_update_test)
{
ACTORS( (alice)(bob) );
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
transfer(account_id_type(), alice_id, asset(10000000));
transfer(account_id_type(), bob_id, asset(10000000));
place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \
fc::optional<object_id_type> sport_id = ice_on_hockey.id;
fc::optional<internationalized_string_type> name = internationalized_string_type({{"en", "IBM"}, {"zh_Hans", "國家冰球聯"}, {"ja", "ナショナルホッケーリー"}});
update_event_group(nhl.id, fc::optional<object_id_type>(), name);
update_event_group(nhl.id, sport_id, fc::optional<internationalized_string_type>());
update_event_group(nhl.id, sport_id, name);
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000);
BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000);
update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed);
// caps win
@ -1573,14 +1573,14 @@ BOOST_AUTO_TEST_CASE(event_group_update_test)
{{capitals_win_market.id, betting_market_resolution_type::win},
{blackhawks_win_market.id, betting_market_resolution_type::not_win}});
generate_blocks(1);
uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage();
uint32_t rake_value = (-1000000 + 2000000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100;
BOOST_TEST_MESSAGE("Rake value " + std::to_string(rake_value));
BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 + 2000000 - rake_value);
BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000);
} FC_LOG_AND_RETHROW()
}
@ -1602,33 +1602,33 @@ struct test_events
{
event.on_in_progress_event(db_fixture.db);
});
event_frozen_upcoming = &db_fixture.create_event({{"en", "event frozen_upcoming"}}, {{"en", "2016-17"}}, event_group_id);
db_fixture.db.modify(*event_frozen_upcoming, [&](event_object& event)
{
event.on_frozen_event(db_fixture.db);
});
event_frozen_in_progress = &db_fixture.create_event({{"en", "event frozen_in_progress"}}, {{"en", "2016-17"}}, event_group_id);
db_fixture.db.modify(*event_frozen_in_progress, [&](event_object& event)
{
event.on_in_progress_event(db_fixture.db);
event.on_frozen_event(db_fixture.db);
});
event_finished = &db_fixture.create_event({{"en", "event finished"}}, {{"en", "2016-17"}}, event_group_id);
db_fixture.db.modify(*event_finished, [&](event_object& event)
{
event.on_frozen_event(db_fixture.db);
event.on_finished_event(db_fixture.db);
});
event_canceled = &db_fixture.create_event({{"en", "event canceled"}}, {{"en", "2016-17"}}, event_group_id);
db_fixture.db.modify(*event_canceled, [&](event_object& event)
{
event.on_canceled_event(db_fixture.db);
});
event_settled = &db_fixture.create_event({{"en", "event settled"}}, {{"en", "2016-17"}}, event_group_id);
db_fixture.db.modify(*event_settled, [&](event_object& event)
{
@ -1648,7 +1648,7 @@ struct test_markets_groups
const betting_market_group_object* market_group_graded = nullptr;
const betting_market_group_object* market_group_canceled = nullptr;
const betting_market_group_object* market_group_settled = nullptr;
test_markets_groups(database_fixture& db_fixture, event_id_type event_id, betting_market_rules_id_type betting_market_rules_id)
{
market_group_upcoming = &db_fixture.create_betting_market_group({{"en", "market group upcoming"}}, event_id, betting_market_rules_id, asset_id_type(), false, 0);
@ -1657,39 +1657,39 @@ struct test_markets_groups
{
market_group.on_frozen_event(db_fixture.db);
});
market_group_in_play = &db_fixture.create_betting_market_group({{"en", "market group in_play"}}, event_id, betting_market_rules_id, asset_id_type(), false, 0);
db_fixture.db.modify(*market_group_in_play, [&](betting_market_group_object& market_group)
{
market_group.on_in_play_event(db_fixture.db);
});
market_group_frozen_in_play = &db_fixture.create_betting_market_group({{"en", "market group frozen_in_play"}}, event_id, betting_market_rules_id, asset_id_type(), false, 0);
db_fixture.db.modify(*market_group_frozen_in_play, [&](betting_market_group_object& market_group)
{
market_group.on_in_play_event(db_fixture.db);
market_group.on_frozen_event(db_fixture.db);
});
market_group_closed = &db_fixture.create_betting_market_group({{"en", "market group closed"}}, event_id, betting_market_rules_id, asset_id_type(), false, 0);
db_fixture.db.modify(*market_group_closed, [&](betting_market_group_object& market_group)
{
market_group.on_closed_event(db_fixture.db, true);
});
market_group_graded = &db_fixture.create_betting_market_group({{"en", "market group graded"}}, event_id, betting_market_rules_id, asset_id_type(), false, 0);
db_fixture.db.modify(*market_group_graded, [&](betting_market_group_object& market_group)
{
market_group.on_closed_event(db_fixture.db, true);
market_group.on_graded_event(db_fixture.db);
});
market_group_canceled = &db_fixture.create_betting_market_group({{"en", "market group canceled"}}, event_id, betting_market_rules_id, asset_id_type(), false, 0);
db_fixture.db.modify(*market_group_canceled, [&](betting_market_group_object& market_group)
{
market_group.on_canceled_event(db_fixture.db, true);
});
market_group_settled = &db_fixture.create_betting_market_group({{"en", "market group settled"}}, event_id, betting_market_rules_id, asset_id_type(), false, 0);
db_fixture.db.modify(*market_group_settled, [&](betting_market_group_object& market_group)
{
@ -1708,7 +1708,7 @@ struct test_markets
const betting_market_object* market_graded = nullptr;
const betting_market_object* market_canceled = nullptr;
const betting_market_object* market_settled = nullptr;
test_markets(database_fixture& db_fixture, betting_market_group_id_type market_group_id)
{
market_unresolved = &db_fixture.create_betting_market(market_group_id, {{"en", "market unresolved"}});
@ -1717,26 +1717,26 @@ struct test_markets
{
market.on_frozen_event(db_fixture.db);
});
market_closed = &db_fixture.create_betting_market(market_group_id, {{"en", "market closed"}});
db_fixture.db.modify(*market_closed, [&](betting_market_object& market)
{
market.on_closed_event(db_fixture.db);
});
market_graded = &db_fixture.create_betting_market(market_group_id, {{"en", "market graded"}});
db_fixture.db.modify(*market_graded, [&](betting_market_object& market)
{
market.on_closed_event(db_fixture.db);
market.on_graded_event(db_fixture.db, betting_market_resolution_type::win);
});
market_canceled = &db_fixture.create_betting_market(market_group_id, {{"en", "market canceled"}});
db_fixture.db.modify(*market_canceled, [&](betting_market_object& market)
{
market.on_canceled_event(db_fixture.db);
});
market_settled = &db_fixture.create_betting_market(market_group_id, {{"en", "market settled"}});
db_fixture.db.modify(*market_settled, [&](betting_market_object& market)
{
@ -1753,15 +1753,15 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test)
{
ACTORS( (alice)(bob) )
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
const int initialAccountAsset = 10000000;
const int betAsset = 1000000;
transfer(account_id_type(), alice_id, asset(initialAccountAsset));
transfer(account_id_type(), bob_id, asset(initialAccountAsset));
const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl.id);
const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules.id, asset_id_type(), false, 0);
//to make bets be not removed immediately
update_betting_market_group_impl(market_group.id,
@ -1769,23 +1769,23 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test)
fc::optional<object_id_type>(),
betting_market_group_status::in_play,
false);
const auto& market = create_betting_market(market_group.id, {{"en", "market"}});
test_events events(*this, nhl.id);
test_markets_groups markets_groups(*this, event.id, betting_market_rules.id);
test_markets markets(*this, market_group.id);
const auto& bet_1_id = place_bet(alice_id, market.id, bet_type::back, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
const auto& bet_2_id = place_bet(bob_id, market.id, bet_type::lay, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
delete_event_group(nhl.id);
const auto& event_group_by_id = db.get_index_type<event_group_object_index>().indices().get<by_id>();
BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(nhl.id));
BOOST_CHECK(event_status::canceled == event.get_status());
BOOST_CHECK(event_status::canceled == events.event_upcoming->get_status());
BOOST_CHECK(event_status::canceled == events.event_in_progress->get_status());
BOOST_CHECK(event_status::canceled == events.event_frozen_in_progress->get_status());
@ -1793,9 +1793,9 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test)
BOOST_CHECK(event_status::canceled == events.event_finished->get_status());
BOOST_CHECK(event_status::canceled == events.event_canceled->get_status());
BOOST_CHECK(event_status::settled == events.event_settled->get_status());
BOOST_CHECK(betting_market_group_status::canceled == market_group.get_status());
BOOST_CHECK(betting_market_group_status::canceled == markets_groups.market_group_upcoming->get_status());
BOOST_CHECK(betting_market_group_status::canceled == markets_groups.market_group_frozen_upcoming->get_status());
BOOST_CHECK(betting_market_group_status::canceled == markets_groups.market_group_in_play->get_status());
@ -1804,21 +1804,21 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test)
BOOST_CHECK(betting_market_group_status::canceled == markets_groups.market_group_graded->get_status());
BOOST_CHECK(betting_market_group_status::canceled == markets_groups.market_group_canceled->get_status());
BOOST_CHECK(betting_market_group_status::settled == markets_groups.market_group_settled->get_status());
BOOST_CHECK(betting_market_status::canceled == market.get_status());
BOOST_CHECK(betting_market_status::canceled == markets.market_unresolved->get_status());
BOOST_CHECK(betting_market_status::canceled == markets.market_frozen->get_status());
BOOST_CHECK(betting_market_status::canceled == markets.market_closed->get_status());
BOOST_CHECK(betting_market_status::canceled == markets.market_graded->get_status());
BOOST_CHECK(betting_market_status::canceled == markets.market_canceled->get_status());
BOOST_CHECK(betting_market_status::settled == markets.market_settled->get_status()); //settled market should not be canceled
//check canceled bets and reverted balance changes
const auto& bet_by_id = db.get_index_type<bet_object_index>().indices().get<by_id>();
BOOST_CHECK(bet_by_id.end() == bet_by_id.find(bet_1_id));
BOOST_CHECK(bet_by_id.end() == bet_by_id.find(bet_2_id));
BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), initialAccountAsset);
BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), initialAccountAsset);
} FC_LOG_AND_RETHROW()
@ -1830,30 +1830,30 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_with_matched_bets)
{
ACTORS( (alice)(bob) )
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
const int initialAccountAsset = 10000000;
const int betAsset = 100000;
transfer(account_id_type(), alice_id, asset(initialAccountAsset));
transfer(account_id_type(), bob_id, asset(initialAccountAsset));
generate_blocks(1);
const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl.id);
generate_blocks(1);
const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules.id, asset_id_type(), false, 0);
generate_blocks(1);
const auto& market = create_betting_market(market_group.id, {{"en", "market"}});
generate_blocks(1);
place_bet(alice_id, market.id, bet_type::back, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
place_bet(bob_id, market.id, bet_type::lay, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
generate_blocks(1);
delete_event_group(nhl.id);
generate_blocks(1);
BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), initialAccountAsset);
BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), initialAccountAsset);
} FC_LOG_AND_RETHROW()
@ -1864,10 +1864,10 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_not_proposal)
try
{
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
event_group_delete_operation event_group_delete_op;
event_group_delete_op.event_group_id = nhl.id;
BOOST_CHECK_THROW(force_operation_by_witnesses(event_group_delete_op), fc::exception);
} FC_LOG_AND_RETHROW()
}
@ -1877,9 +1877,9 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_not_existed_event_group)
try
{
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
delete_event_group(nhl.id);
BOOST_CHECK_THROW(delete_event_group(nhl.id), fc::exception);
} FC_LOG_AND_RETHROW()
}
@ -2132,9 +2132,9 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_1_with_delay)
// as soon as a block is generated, the betting market group will settle, and the market
// and group will cease to exist. The event should transition to "settled", then
// removed.
fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id,
moneyline_betting_markets_id,
capitals_win_market_id,
fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id,
moneyline_betting_markets_id,
capitals_win_market_id,
blackhawks_win_market_id});
idump((objects_from_bookie));
@ -2394,7 +2394,7 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_3)
fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id});
BOOST_CHECK_EQUAL(objects_from_bookie[0]["status"].as<std::string>(), "canceled");
} FC_LOG_AND_RETHROW()
}
@ -2585,7 +2585,7 @@ BOOST_AUTO_TEST_CASE(betting_market_group_driven_standard_progression)
BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen);
BOOST_TEST_MESSAGE("setting the event frozen");
// this should only change the status of the event, just verify that nothing weird happens when
// this should only change the status of the event, just verify that nothing weird happens when
// we try to set the bmg to frozen when it's already frozen
update_event(capitals_vs_blackhawks.id, _status = event_status::frozen);
generate_blocks(1);
@ -2762,53 +2762,53 @@ BOOST_FIXTURE_TEST_CASE( another_event_group_update_test, database_fixture)
{
ACTORS( (alice)(bob) );
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
transfer(account_id_type(), alice_id, asset(10000000));
transfer(account_id_type(), bob_id, asset(10000000));
place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
fc::optional<internationalized_string_type> name = internationalized_string_type({{"en", "IBM"}, {"zh_Hans", "國家冰球聯"}, {"ja", "ナショナルホッケーリー"}});
const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \
fc::optional<object_id_type> sport_id = ice_on_hockey.id;
update_event_group(nhl.id, fc::optional<object_id_type>(), name);
update_event_group(nhl.id, sport_id, fc::optional<internationalized_string_type>());
update_event_group(nhl.id, sport_id, name);
//Disabling the below 4 TRY_EXPECT_THROW lines to not throw anything beacuse functioning as expected
// trx_state->_is_proposed_trx
//GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, fc::optional<object_id_type>(), fc::optional<internationalized_string_type>(), true), fc::exception);
// TRY_EXPECT_THROW(try_update_event_group(nhl.id, fc::optional<object_id_type>(), fc::optional<internationalized_string_type>(), true), fc::exception, "_is_proposed_trx");
// #! nothing to change
//GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, fc::optional<object_id_type>(), fc::optional<internationalized_string_type>()), fc::exception);
//TRY_EXPECT_THROW(try_update_event_group(nhl.id, fc::optional<object_id_type>(), fc::optional<internationalized_string_type>()), fc::exception, "nothing to change");
// #! sport_id must refer to a sport_id_type
sport_id = capitals_win_market.id;
//GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, sport_id, fc::optional<internationalized_string_type>()), fc::exception);
//TRY_EXPECT_THROW(try_update_event_group(nhl.id, sport_id, fc::optional<internationalized_string_type>()), fc::exception, "sport_id must refer to a sport_id_type");
// #! invalid sport specified
sport_id = sport_id_type(13);
//GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, sport_id, fc::optional<internationalized_string_type>()), fc::exception);
//TRY_EXPECT_THROW(try_update_event_group(nhl.id, sport_id, fc::optional<internationalized_string_type>()), fc::exception, "invalid sport specified");
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000);
BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000);
update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed);
// caps win
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_blocks(1);
uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage();
uint32_t rake_value = (-1000000 + 2000000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100;
BOOST_TEST_MESSAGE("Rake value " + std::to_string(rake_value));
@ -2942,9 +2942,9 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test )
// BOOST_AUTO_TEST_CASE( check_transaction_for_duplicate_reworked_test )
// {
// try
// {
// {
// std::vector<internationalized_string_type> names_vec(104);
//
//
// // create 104 pattern for first name
// for( char co = 'A'; co <= 'D'; ++co ) {
// for( char ci = 'A'; ci <= 'Z'; ++ci ) {
@ -2953,46 +2953,46 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test )
// names_vec.push_back( {{ first_name, second_name }} );
// }
// }
//
//
// sport_id_type sport_id = create_sport( {{"SN","SPORT_NAME"}} ).id;
//
//
// event_group_id_type event_group_id = create_event_group( {{"EG", "EVENT_GROUP"}}, sport_id ).id;
//
// betting_market_rules_id_type betting_market_rules_id =
//
// betting_market_rules_id_type betting_market_rules_id =
// create_betting_market_rules( {{"EN", "Rules"}}, {{"EN", "Some rules"}} ).id;
//
//
// for( const auto& name : names_vec )
// {
// proposal_create_operation pcop = proposal_create_operation::committee_proposal(
// proposal_create_operation pcop = proposal_create_operation::committee_proposal(
// db.get_global_properties().parameters,
// db.head_block_time()
// db.head_block_time()
// );
// pcop.review_period_seconds.reset();
// pcop.review_period_seconds = db.get_global_properties().parameters.committee_proposal_review_period * 2;
//
//
// event_create_operation evcop;
// evcop.event_group_id = event_group_id;
// evcop.name = name;
// evcop.season = name;
//
//
// betting_market_group_create_operation bmgcop;
// bmgcop.description = name;
// bmgcop.event_id = object_id_type(relative_protocol_ids, 0, 0);
// bmgcop.rules_id = betting_market_rules_id;
// bmgcop.asset_id = asset_id_type();
//
// bmgcop.asset_id = asset_id_type();
//
// betting_market_create_operation bmcop;
// bmcop.group_id = object_id_type(relative_protocol_ids, 0, 1);
// bmcop.payout_condition.insert( internationalized_string_type::value_type( "CN", "CONDI_NAME" ) );
//
//
// pcop.proposed_ops.emplace_back( evcop );
// pcop.proposed_ops.emplace_back( bmgcop );
// pcop.proposed_ops.emplace_back( bmcop );
//
//
// signed_transaction trx;
// set_expiration( db, trx );
// trx.operations.push_back( pcop );
//
//
// process_operation_by_witnesses( pcop );
// }
// }FC_LOG_AND_RETHROW()

View file

@ -73,7 +73,7 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture )
// and assert that all four cases were tested at least once
//
account_object sam_account_object = create_account( "sam", sam_key );
upgrade_to_lifetime_member(sam_account_object.id);
//Get a sane head block time
generate_block( skip_flags );

View file

@ -613,20 +613,20 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling )
// try
// {
// ACTORS((alice)(bob)(izzy));
//
//
// int64_t alice_b0 = 1000000, bob_b0 = 1000000;
//
//
// transfer( account_id_type(), alice_id, asset(alice_b0) );
// transfer( account_id_type(), bob_id, asset(bob_b0) );
//
//
// asset_id_type core_id = asset_id_type();
// asset_id_type usd_id = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee ).id;
// issue_uia( alice_id, asset( alice_b0, usd_id ) );
// issue_uia( bob_id, asset( bob_b0, usd_id ) );
//
//
// int64_t order_create_fee = 537;
// int64_t order_cancel_fee = 129;
//
//
// uint32_t skip = database::skip_witness_signature
// | database::skip_transaction_signatures
// | database::skip_transaction_dupe_check
@ -635,9 +635,9 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling )
// | database::skip_authority_check
// | database::skip_merkle_check
// ;
//
//
// generate_block( skip );
//
//
// for( int i=0; i<2; i++ )
// {
// if( i == 1 )
@ -645,7 +645,7 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling )
// generate_blocks( HARDFORK_445_TIME, true, skip );
// generate_block( skip );
// }
//
//
// // enable_fees() and change_fees() modifies DB directly, and results will be overwritten by block generation
// // so we have to do it every time we stop generating/popping blocks and start doing tx's
// enable_fees();
@ -671,69 +671,69 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling )
// }
// change_fees( new_fees );
// }
//
//
// // Alice creates order
// // Bob creates order which doesn't match
//
//
// // AAAAGGHH create_sell_order reads trx.expiration #469
// set_expiration( db, trx );
//
//
// // Check non-overlapping
//
//
// limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(1000, usd_id) )->id;
// limit_order_id_type bo1_id = create_sell_order( bob_id, asset(500, usd_id), asset(1000) )->id;
//
//
// BOOST_CHECK_EQUAL( get_balance( alice_id, core_id ), alice_b0 - 1000 - order_create_fee );
// BOOST_CHECK_EQUAL( get_balance( alice_id, usd_id ), alice_b0 );
// BOOST_CHECK_EQUAL( get_balance( bob_id, core_id ), bob_b0 - order_create_fee );
// BOOST_CHECK_EQUAL( get_balance( bob_id, usd_id ), bob_b0 - 500 );
//
//
// // Bob cancels order
// cancel_limit_order( bo1_id(db) );
//
//
// int64_t cancel_net_fee;
// if( db.head_block_time() >= HARDFORK_445_TIME )
// cancel_net_fee = order_cancel_fee;
// else
// cancel_net_fee = order_create_fee + order_cancel_fee;
//
//
// BOOST_CHECK_EQUAL( get_balance( alice_id, core_id ), alice_b0 - 1000 - order_create_fee );
// BOOST_CHECK_EQUAL( get_balance( alice_id, usd_id ), alice_b0 );
// BOOST_CHECK_EQUAL( get_balance( bob_id, core_id ), bob_b0 - cancel_net_fee );
// BOOST_CHECK_EQUAL( get_balance( bob_id, usd_id ), bob_b0 );
//
//
// // Alice cancels order
// cancel_limit_order( ao1_id(db) );
//
//
// BOOST_CHECK_EQUAL( get_balance( alice_id, core_id ), alice_b0 - cancel_net_fee );
// BOOST_CHECK_EQUAL( get_balance( alice_id, usd_id ), alice_b0 );
// BOOST_CHECK_EQUAL( get_balance( bob_id, core_id ), bob_b0 - cancel_net_fee );
// BOOST_CHECK_EQUAL( get_balance( bob_id, usd_id ), bob_b0 );
//
//
// // Check partial fill
// const limit_order_object* ao2 = create_sell_order( alice_id, asset(1000), asset(200, usd_id) );
// const limit_order_object* bo2 = create_sell_order( bob_id, asset(100, usd_id), asset(500) );
//
//
// BOOST_CHECK( ao2 != nullptr );
// BOOST_CHECK( bo2 == nullptr );
//
//
// BOOST_CHECK_EQUAL( get_balance( alice_id, core_id ), alice_b0 - cancel_net_fee - order_create_fee - 1000 );
// BOOST_CHECK_EQUAL( get_balance( alice_id, usd_id ), alice_b0 + 100 );
// BOOST_CHECK_EQUAL( get_balance( bob_id, core_id ), bob_b0 - cancel_net_fee - order_create_fee + 500 );
// BOOST_CHECK_EQUAL( get_balance( bob_id, usd_id ), bob_b0 - 100 );
//
//
// // cancel Alice order, show that entire deferred_fee was consumed by partial match
// cancel_limit_order( *ao2 );
//
//
// BOOST_CHECK_EQUAL( get_balance( alice_id, core_id ), alice_b0 - cancel_net_fee - order_create_fee - 500 - order_cancel_fee );
// BOOST_CHECK_EQUAL( get_balance( alice_id, usd_id ), alice_b0 + 100 );
// BOOST_CHECK_EQUAL( get_balance( bob_id, core_id ), bob_b0 - cancel_net_fee - order_create_fee + 500 );
// BOOST_CHECK_EQUAL( get_balance( bob_id, usd_id ), bob_b0 - 100 );
//
//
// // TODO: Check multiple fill
// // there really should be a test case involving Alice creating multiple orders matched by single Bob order
// // but we'll save that for future cleanup
//
//
// // undo above tx's and reset
// generate_block( skip );
// db.pop_block();
@ -966,7 +966,7 @@ BOOST_AUTO_TEST_CASE( defaults_test )
fee = schedule.calculate_fee( limit_order_create_operation() );
BOOST_CHECK_EQUAL( new_order_fee.fee, fee.amount.value );
// NO bid_collateral_operation in this version
// NO bid_collateral_operation in this version
// bid_collateral fee defaults to call_order_update fee
// call_order_update fee is unset -> default

View file

@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE( test_exception_throwing_for_the_same_operation_proposed_tw
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
}
catch( const fc::exception& e )
{
@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_duplicated_operation_in_existed_proposal_w
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
}
catch( const fc::exception& e )
{
@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_same_member_create_operations )
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
}
catch( const fc::exception& e )
{
@ -367,9 +367,9 @@ BOOST_AUTO_TEST_CASE( check_passes_for_duplicated_betting_market_or_group )
{
const sport_id_type sport_id = create_sport( {{"SN","SPORT_NAME"}} ).id;
const event_group_id_type event_group_id = create_event_group( {{"EG", "EVENT_GROUP"}}, sport_id ).id;
const betting_market_rules_id_type betting_market_rules_id =
const betting_market_rules_id_type betting_market_rules_id =
create_betting_market_rules( {{"EN", "Rules"}}, {{"EN", "Some rules"}} ).id;
event_create_operation evcop1;
evcop1.event_group_id = event_group_id;
evcop1.name = {{"NO", "NAME_ONE"}};
@ -384,15 +384,15 @@ BOOST_AUTO_TEST_CASE( check_passes_for_duplicated_betting_market_or_group )
bmgcop.description = {{"NN", "NO_NAME"}};
bmgcop.event_id = object_id_type(relative_protocol_ids, 0, 0);
bmgcop.rules_id = betting_market_rules_id;
bmgcop.asset_id = asset_id_type();
bmgcop.asset_id = asset_id_type();
betting_market_create_operation bmcop;
bmcop.group_id = object_id_type(relative_protocol_ids, 0, 1);
bmcop.payout_condition.insert( internationalized_string_type::value_type( "CN", "CONDI_NAME" ) );
proposal_create_operation pcop1 = proposal_create_operation::committee_proposal(
proposal_create_operation pcop1 = proposal_create_operation::committee_proposal(
db.get_global_properties().parameters,
db.head_block_time()
db.head_block_time()
);
pcop1.review_period_seconds.reset();

View file

@ -1561,6 +1561,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_create_test )
op.amount = test_asset.amount( 100 );
//op.vesting_seconds = 60*60*24;
op.policy = cdd_vesting_policy_initializer{ 60*60*24 };
//op.balance_type == vesting_balance_type::unspecified;
// Fee must be non-negative
REQUIRE_OP_VALIDATION_SUCCESS( op, fee, core.amount(1) );
@ -1580,6 +1581,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_create_test )
op.creator = alice_account.get_id();
op.owner = alice_account.get_id();
//op.balance_type = vesting_balance_type::unspecified;
account_id_type nobody = account_id_type(1234);
@ -1650,6 +1652,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test )
create_op.owner = owner;
create_op.amount = amount;
create_op.policy = cdd_vesting_policy_initializer(vesting_seconds);
//create_op.balance_type = vesting_balance_type::unspecified;
tx.operations.push_back( create_op );
set_expiration( db, tx );

View file

@ -869,24 +869,24 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
// try
// {
// ACTORS( (nathan)(shorter1)(shorter2)(shorter3)(shorter4)(shorter5) );
//
//
// int64_t initial_balance = 100000000;
//
//
// transfer(account_id_type()(db), shorter1_id(db), asset(initial_balance));
// transfer(account_id_type()(db), shorter2_id(db), asset(initial_balance));
// transfer(account_id_type()(db), shorter3_id(db), asset(initial_balance));
// transfer(account_id_type()(db), shorter4_id(db), asset(initial_balance));
// transfer(account_id_type()(db), shorter5_id(db), asset(initial_balance));
//
//
// asset_id_type bitusd_id = create_bitasset(
// "USDBIT",
// nathan_id,
// 100,
// disable_force_settle
// ).id;
//
//
// asset_id_type core_id = asset_id_type();
//
//
// auto update_bitasset_options = [&]( asset_id_type asset_id,
// std::function< void(bitasset_options&) > update_function )
// {
@ -901,7 +901,7 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
// set_expiration( db, tx );
// PUSH_TX( db, tx, ~0 );
// } ;
//
//
// auto update_asset_options = [&]( asset_id_type asset_id,
// std::function< void(asset_options&) > update_function )
// {
@ -916,36 +916,36 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
// set_expiration( db, tx );
// PUSH_TX( db, tx, ~0 );
// } ;
//
//
// BOOST_TEST_MESSAGE( "Update maximum_force_settlement_volume = 9000" );
//
//
// BOOST_CHECK( bitusd_id(db).is_market_issued() );
// update_bitasset_options( bitusd_id, [&]( bitasset_options& new_options )
// { new_options.maximum_force_settlement_volume = 9000; } );
//
//
// BOOST_TEST_MESSAGE( "Publish price feed" );
//
//
// update_feed_producers( bitusd_id, { nathan_id } );
// {
// price_feed feed;
// feed.settlement_price = price( asset( 1, bitusd_id ), asset( 1, core_id ) );
// publish_feed( bitusd_id, nathan_id, feed );
// }
//
//
// BOOST_TEST_MESSAGE( "First short batch" );
//
//
// call_order_id_type call1_id = borrow( shorter1_id, asset(1000, bitusd_id), asset(2*1000, core_id) )->id; // 2.0000
// call_order_id_type call2_id = borrow( shorter2_id, asset(2000, bitusd_id), asset(2*1999, core_id) )->id; // 1.9990
// call_order_id_type call3_id = borrow( shorter3_id, asset(3000, bitusd_id), asset(2*2890, core_id) )->id; // 1.9267
// call_order_id_type call4_id = borrow( shorter4_id, asset(4000, bitusd_id), asset(2*3950, core_id) )->id; // 1.9750
// call_order_id_type call5_id = borrow( shorter5_id, asset(5000, bitusd_id), asset(2*4900, core_id) )->id; // 1.9600
//
//
// transfer( shorter1_id, nathan_id, asset(1000, bitusd_id) );
// transfer( shorter2_id, nathan_id, asset(2000, bitusd_id) );
// transfer( shorter3_id, nathan_id, asset(3000, bitusd_id) );
// transfer( shorter4_id, nathan_id, asset(4000, bitusd_id) );
// transfer( shorter5_id, nathan_id, asset(5000, bitusd_id) );
//
//
// BOOST_CHECK_EQUAL( get_balance(nathan_id, bitusd_id), 15000);
// BOOST_CHECK_EQUAL( get_balance(nathan_id, core_id), 0);
// BOOST_CHECK_EQUAL( get_balance(shorter1_id, core_id), initial_balance-2000 );
@ -953,37 +953,37 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
// BOOST_CHECK_EQUAL( get_balance(shorter3_id, core_id), initial_balance-5780 );
// BOOST_CHECK_EQUAL( get_balance(shorter4_id, core_id), initial_balance-7900 );
// BOOST_CHECK_EQUAL( get_balance(shorter5_id, core_id), initial_balance-9800 );
//
//
// BOOST_TEST_MESSAGE( "Update force_settlement_delay_sec = 100, force_settlement_offset_percent = 1%" );
//
//
// update_bitasset_options( bitusd_id, [&]( bitasset_options& new_options )
// { new_options.force_settlement_delay_sec = 100;
// new_options.force_settlement_offset_percent = GRAPHENE_1_PERCENT; } );
//
//
// // Force settlement is disabled; check that it fails
// GRAPHENE_REQUIRE_THROW( force_settle( nathan_id, asset( 50, bitusd_id ) ), fc::exception );
//
//
// update_asset_options( bitusd_id, [&]( asset_options& new_options )
// { new_options.flags &= ~disable_force_settle; } );
//
//
// // Can't settle more BitUSD than you own
// GRAPHENE_REQUIRE_THROW( force_settle( nathan_id, asset( 999999, bitusd_id ) ), fc::exception );
//
//
// // settle3 should be least collateralized order according to index
// BOOST_CHECK( db.get_index_type<call_order_index>().indices().get<by_collateral>().begin()->id == call3_id );
// BOOST_CHECK_EQUAL( call3_id(db).debt.value, 3000 );
//
//
// BOOST_TEST_MESSAGE( "Verify partial settlement of call" );
// // Partially settle a call
// force_settlement_id_type settle_id = force_settle( nathan_id, asset( 50, bitusd_id ) ).get< object_id_type >();
//
//
// // Call does not take effect immediately
// BOOST_CHECK_EQUAL( get_balance(nathan_id, bitusd_id), 14950);
// BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 50);
// BOOST_CHECK_EQUAL( call3_id(db).debt.value, 3000 );
// BOOST_CHECK_EQUAL( call3_id(db).collateral.value, 5780 );
// BOOST_CHECK( settle_id(db).owner == nathan_id );
//
//
// // Wait for settlement to take effect
// generate_blocks(settle_id(db).settlement_date);
// BOOST_CHECK(db.find(settle_id) == nullptr);
@ -992,56 +992,56 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
// BOOST_CHECK_EQUAL( get_balance(nathan_id, core_id), 49 ); // 1% force_settlement_offset_percent (rounded unfavorably)
// BOOST_CHECK_EQUAL( call3_id(db).debt.value, 2950 );
// BOOST_CHECK_EQUAL( call3_id(db).collateral.value, 5731 ); // 5731 == 5780-49
//
//
// BOOST_CHECK( db.get_index_type<call_order_index>().indices().get<by_collateral>().begin()->id == call3_id );
//
//
// BOOST_TEST_MESSAGE( "Verify pending settlement is cancelled when asset's force_settle is disabled" );
// // Ensure pending settlement is cancelled when force settle is disabled
// settle_id = force_settle( nathan_id, asset( 50, bitusd_id ) ).get< object_id_type >();
//
//
// BOOST_CHECK( !db.get_index_type<force_settlement_index>().indices().empty() );
// update_asset_options( bitusd_id, [&]( asset_options& new_options )
// { new_options.flags |= disable_force_settle; } );
// BOOST_CHECK( db.get_index_type<force_settlement_index>().indices().empty() );
// update_asset_options( bitusd_id, [&]( asset_options& new_options )
// { new_options.flags &= ~disable_force_settle; } );
//
//
// BOOST_TEST_MESSAGE( "Perform iterative settlement" );
// settle_id = force_settle( nathan_id, asset( 12500, bitusd_id ) ).get< object_id_type >();
//
//
// // c3 2950 : 5731 1.9427 fully settled
// // c5 5000 : 9800 1.9600 fully settled
// // c4 4000 : 7900 1.9750 fully settled
// // c2 2000 : 3998 1.9990 550 settled
// // c1 1000 : 2000 2.0000
//
//
// generate_blocks( settle_id(db).settlement_date );
//
//
// int64_t call1_payout = 0;
// int64_t call2_payout = 550*99/100;
// int64_t call3_payout = 49 + 2950*99/100;
// int64_t call4_payout = 4000*99/100;
// int64_t call5_payout = 5000*99/100;
//
//
// BOOST_CHECK_EQUAL( get_balance(shorter1_id, core_id), initial_balance-2*1000 ); // full collat still tied up
// BOOST_CHECK_EQUAL( get_balance(shorter2_id, core_id), initial_balance-2*1999 ); // full collat still tied up
// BOOST_CHECK_EQUAL( get_balance(shorter3_id, core_id), initial_balance-call3_payout ); // initial balance minus transfer to Nathan (as BitUSD)
// BOOST_CHECK_EQUAL( get_balance(shorter4_id, core_id), initial_balance-call4_payout ); // initial balance minus transfer to Nathan (as BitUSD)
// BOOST_CHECK_EQUAL( get_balance(shorter5_id, core_id), initial_balance-call5_payout ); // initial balance minus transfer to Nathan (as BitUSD)
//
//
// BOOST_CHECK_EQUAL( get_balance(nathan_id, core_id),
// call1_payout + call2_payout + call3_payout + call4_payout + call5_payout );
//
//
// BOOST_CHECK( db.find(call3_id) == nullptr );
// BOOST_CHECK( db.find(call4_id) == nullptr );
// BOOST_CHECK( db.find(call5_id) == nullptr );
//
//
// BOOST_REQUIRE( db.find(call1_id) != nullptr );
// BOOST_REQUIRE( db.find(call2_id) != nullptr );
//
//
// BOOST_CHECK_EQUAL( call1_id(db).debt.value, 1000 );
// BOOST_CHECK_EQUAL( call1_id(db).collateral.value, 2000 );
//
//
// BOOST_CHECK_EQUAL( call2_id(db).debt.value, 2000-550 );
// BOOST_CHECK_EQUAL( call2_id(db).collateral.value, 3998-call2_payout );
// }
@ -1051,7 +1051,7 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
// throw;
// }
// }
//
//
BOOST_AUTO_TEST_CASE( assert_op_test )
{
try {
@ -1316,6 +1316,7 @@ BOOST_AUTO_TEST_CASE(zero_second_vbo)
create_op.owner = alice_id;
create_op.amount = asset(500);
create_op.policy = pinit;
//create_op.balance_type = vesting_balance_type::unspecified;
signed_transaction create_tx;
create_tx.operations.push_back( create_op );
@ -1399,6 +1400,7 @@ BOOST_AUTO_TEST_CASE( vbo_withdraw_different )
create_op.owner = alice_id;
create_op.amount = asset(100, stuff_id);
create_op.policy = pinit;
//create_op.balance_type = vesting_balance_type::unspecified;
signed_transaction create_tx;
create_tx.operations.push_back( create_op );