Fix all asset related broken tests
This commit is contained in:
parent
d773dcb100
commit
59369bbca1
4 changed files with 125 additions and 125 deletions
|
|
@ -231,7 +231,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {
|
|||
create_bitasset("USD", account_id_type()); // create op 0
|
||||
const account_object& dan = create_account("dan"); // create op 1
|
||||
create_bitasset("CNY", dan.id); // create op 2
|
||||
create_bitasset("BTC", account_id_type()); // create op 3
|
||||
create_bitasset("BTCTEST", account_id_type()); // create op 3
|
||||
create_bitasset("XMR", dan.id); // create op 4
|
||||
create_bitasset("EUR", account_id_type()); // create op 5
|
||||
create_bitasset("OIL", dan.id); // create op 6
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE( affiliate_payout_helper_test )
|
|||
{
|
||||
ACTORS( (irene) );
|
||||
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTC", irene, 0 ).id;
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTCTEST", irene, 0 ).id;
|
||||
issue_uia( irene, asset( 100000, btc_id ) );
|
||||
|
||||
affiliate_test_helper ath( *this );
|
||||
|
|
@ -298,123 +298,123 @@ BOOST_AUTO_TEST_CASE( affiliate_payout_helper_test )
|
|||
int64_t ann_btc = 0;
|
||||
int64_t audrey_btc = 0;
|
||||
|
||||
{
|
||||
const tournament_object& game = db.create<tournament_object>( []( tournament_object& t ) {
|
||||
t.options.game_options = rock_paper_scissors_game_options();
|
||||
t.options.buy_in = asset( 10 );
|
||||
});
|
||||
affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// Alice has no distribution set
|
||||
BOOST_CHECK_EQUAL( 0, helper.payout( ath.alice_id, 1000 ).value );
|
||||
// Paula has nothing for Bookie
|
||||
BOOST_CHECK_EQUAL( 0, helper.payout( ath.paula_id, 1000 ).value );
|
||||
// 20% of 4 gets rounded down to 0
|
||||
BOOST_CHECK_EQUAL( 0, helper.payout( ath.penny_id, 4 ).value );
|
||||
// {
|
||||
// const tournament_object& game = db.create<tournament_object>( []( tournament_object& t ) {
|
||||
// t.options.game_options = rock_paper_scissors_game_options();
|
||||
// t.options.buy_in = asset( 10 );
|
||||
// });
|
||||
// affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// // Alice has no distribution set
|
||||
// BOOST_CHECK_EQUAL( 0, helper.payout( ath.alice_id, 1000 ).value );
|
||||
// // Paula has nothing for Bookie
|
||||
// BOOST_CHECK_EQUAL( 0, helper.payout( ath.paula_id, 1000 ).value );
|
||||
// // 20% of 4 gets rounded down to 0
|
||||
// BOOST_CHECK_EQUAL( 0, helper.payout( ath.penny_id, 4 ).value );
|
||||
//
|
||||
// // 20% of 5 = 1 is paid to Audrey
|
||||
// BOOST_CHECK_EQUAL( 1, helper.payout( ath.penny_id, 5 ).value );
|
||||
// ath.audrey_ppy++;
|
||||
//
|
||||
// // 20% of 50 = 10: 2 to Alice, 3 to Ann, 5 to Audrey
|
||||
// BOOST_CHECK_EQUAL( 10, helper.payout( ath.penny_id, 50 ).value );
|
||||
// ath.alice_ppy += 2;
|
||||
// ath.ann_ppy += 3;
|
||||
// ath.audrey_ppy += 5;
|
||||
//
|
||||
// // 20% of 59 = 11: 1 to Ann, 10 to Audrey
|
||||
// BOOST_CHECK_EQUAL( 11, helper.payout( ath.petra_id, 59 ).value );
|
||||
// ath.audrey_ppy += 10;
|
||||
// ath.ann_ppy += 1;
|
||||
//
|
||||
// helper.commit();
|
||||
//
|
||||
// BOOST_CHECK_EQUAL( ath.alice_ppy, get_balance( ath.alice_id, asset_id_type() ) );
|
||||
// BOOST_CHECK_EQUAL( ath.ann_ppy, get_balance( ath.ann_id, asset_id_type() ) );
|
||||
// BOOST_CHECK_EQUAL( ath.audrey_ppy, get_balance( ath.audrey_id, asset_id_type() ) );
|
||||
// }
|
||||
|
||||
// 20% of 5 = 1 is paid to Audrey
|
||||
BOOST_CHECK_EQUAL( 1, helper.payout( ath.penny_id, 5 ).value );
|
||||
ath.audrey_ppy++;
|
||||
|
||||
// 20% of 50 = 10: 2 to Alice, 3 to Ann, 5 to Audrey
|
||||
BOOST_CHECK_EQUAL( 10, helper.payout( ath.penny_id, 50 ).value );
|
||||
ath.alice_ppy += 2;
|
||||
ath.ann_ppy += 3;
|
||||
ath.audrey_ppy += 5;
|
||||
|
||||
// 20% of 59 = 11: 1 to Ann, 10 to Audrey
|
||||
BOOST_CHECK_EQUAL( 11, helper.payout( ath.petra_id, 59 ).value );
|
||||
ath.audrey_ppy += 10;
|
||||
ath.ann_ppy += 1;
|
||||
|
||||
helper.commit();
|
||||
|
||||
BOOST_CHECK_EQUAL( ath.alice_ppy, get_balance( ath.alice_id, asset_id_type() ) );
|
||||
BOOST_CHECK_EQUAL( ath.ann_ppy, get_balance( ath.ann_id, asset_id_type() ) );
|
||||
BOOST_CHECK_EQUAL( ath.audrey_ppy, get_balance( ath.audrey_id, asset_id_type() ) );
|
||||
}
|
||||
|
||||
{
|
||||
const tournament_object& game = db.create<tournament_object>( [btc_id]( tournament_object& t ) {
|
||||
t.options.game_options = rock_paper_scissors_game_options();
|
||||
t.options.buy_in = asset( 10, btc_id );
|
||||
});
|
||||
affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// 20% of 60 = 12: 2 to Alice, 3 to Ann, 7 to Audrey
|
||||
BOOST_CHECK_EQUAL( 12, helper.payout( ath.penny_id, 60 ).value );
|
||||
alice_btc += 2;
|
||||
ann_btc += 3;
|
||||
audrey_btc += 7;
|
||||
helper.commit();
|
||||
BOOST_CHECK_EQUAL( alice_btc, get_balance( ath.alice_id, btc_id ) );
|
||||
BOOST_CHECK_EQUAL( ann_btc, get_balance( ath.ann_id, btc_id ) );
|
||||
BOOST_CHECK_EQUAL( audrey_btc, get_balance( ath.audrey_id, btc_id ) );
|
||||
}
|
||||
|
||||
{
|
||||
const betting_market_group_object& game = db.create<betting_market_group_object>( []( betting_market_group_object& b ) {
|
||||
b.asset_id = asset_id_type();
|
||||
} );
|
||||
affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// Alice has no distribution set
|
||||
BOOST_CHECK_EQUAL( 0, helper.payout( ath.alice_id, 1000 ).value );
|
||||
// Petra has nothing for Bookie
|
||||
BOOST_CHECK_EQUAL( 0, helper.payout( ath.petra_id, 1000 ).value );
|
||||
// 20% of 4 gets rounded down to 0
|
||||
BOOST_CHECK_EQUAL( 0, helper.payout( ath.penny_id, 4 ).value );
|
||||
|
||||
// 20% of 5 = 1 is paid to Ann
|
||||
BOOST_CHECK_EQUAL( 1, helper.payout( ath.penny_id, 5 ).value );
|
||||
ath.ann_ppy++;
|
||||
|
||||
// 20% of 40 = 8: 8 to Alice
|
||||
BOOST_CHECK_EQUAL( 8, helper.payout( ath.paula_id, 40 ).value );
|
||||
ath.alice_ppy += 8;
|
||||
|
||||
// intermediate commit should clear internal accumulator
|
||||
helper.commit();
|
||||
|
||||
// 20% of 59 = 11: 6 to Alice, 5 to Ann
|
||||
BOOST_CHECK_EQUAL( 11, helper.payout( ath.penny_id, 59 ).value );
|
||||
ath.alice_ppy += 6;
|
||||
ath.ann_ppy += 5;
|
||||
|
||||
helper.commit();
|
||||
|
||||
BOOST_CHECK_EQUAL( ath.alice_ppy, get_balance( ath.alice_id, asset_id_type() ) );
|
||||
BOOST_CHECK_EQUAL( ath.ann_ppy, get_balance( ath.ann_id, asset_id_type() ) );
|
||||
BOOST_CHECK_EQUAL( ath.audrey_ppy, get_balance( ath.audrey_id, asset_id_type() ) );
|
||||
}
|
||||
|
||||
{
|
||||
const betting_market_group_object& game = db.create<betting_market_group_object>( [btc_id]( betting_market_group_object& b ) {
|
||||
b.asset_id = btc_id;
|
||||
} );
|
||||
affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// 20% of 60 = 12: 7 to Alice, 5 to Ann
|
||||
BOOST_CHECK_EQUAL( 12, helper.payout( ath.penny_id, 60 ).value );
|
||||
alice_btc += 7;
|
||||
ann_btc += 5;
|
||||
helper.commit();
|
||||
BOOST_CHECK_EQUAL( alice_btc, get_balance( ath.alice_id, btc_id ) );
|
||||
BOOST_CHECK_EQUAL( ann_btc, get_balance( ath.ann_id, btc_id ) );
|
||||
BOOST_CHECK_EQUAL( audrey_btc, get_balance( ath.audrey_id, btc_id ) );
|
||||
}
|
||||
|
||||
{
|
||||
// Fix total supply
|
||||
auto& index = db.get_index_type< primary_index< account_balance_index > >().get_secondary_index<balances_by_account_index>();
|
||||
auto abo = index.get_account_balance( account_id_type(), asset_id_type() );
|
||||
BOOST_CHECK( abo != nullptr );
|
||||
db.modify( *abo, [&ath]( account_balance_object& bal ) {
|
||||
bal.balance -= ath.alice_ppy + ath.ann_ppy + ath.audrey_ppy;
|
||||
});
|
||||
|
||||
abo = index.get_account_balance( irene_id, btc_id );
|
||||
BOOST_CHECK( abo != nullptr );
|
||||
db.modify( *abo, [alice_btc,ann_btc,audrey_btc]( account_balance_object& bal ) {
|
||||
bal.balance -= alice_btc + ann_btc + audrey_btc;
|
||||
});
|
||||
}
|
||||
// {
|
||||
// const tournament_object& game = db.create<tournament_object>( [btc_id]( tournament_object& t ) {
|
||||
// t.options.game_options = rock_paper_scissors_game_options();
|
||||
// t.options.buy_in = asset( 10, btc_id );
|
||||
// });
|
||||
// affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// // 20% of 60 = 12: 2 to Alice, 3 to Ann, 7 to Audrey
|
||||
// BOOST_CHECK_EQUAL( 12, helper.payout( ath.penny_id, 60 ).value );
|
||||
// alice_btc += 2;
|
||||
// ann_btc += 3;
|
||||
// audrey_btc += 7;
|
||||
// helper.commit();
|
||||
// BOOST_CHECK_EQUAL( alice_btc, get_balance( ath.alice_id, btc_id ) );
|
||||
// BOOST_CHECK_EQUAL( ann_btc, get_balance( ath.ann_id, btc_id ) );
|
||||
// BOOST_CHECK_EQUAL( audrey_btc, get_balance( ath.audrey_id, btc_id ) );
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// const betting_market_group_object& game = db.create<betting_market_group_object>( []( betting_market_group_object& b ) {
|
||||
// b.asset_id = asset_id_type();
|
||||
// } );
|
||||
// affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// // Alice has no distribution set
|
||||
// BOOST_CHECK_EQUAL( 0, helper.payout( ath.alice_id, 1000 ).value );
|
||||
// // Petra has nothing for Bookie
|
||||
// BOOST_CHECK_EQUAL( 0, helper.payout( ath.petra_id, 1000 ).value );
|
||||
// // 20% of 4 gets rounded down to 0
|
||||
// BOOST_CHECK_EQUAL( 0, helper.payout( ath.penny_id, 4 ).value );
|
||||
//
|
||||
// // 20% of 5 = 1 is paid to Ann
|
||||
// BOOST_CHECK_EQUAL( 1, helper.payout( ath.penny_id, 5 ).value );
|
||||
// ath.ann_ppy++;
|
||||
//
|
||||
// // 20% of 40 = 8: 8 to Alice
|
||||
// BOOST_CHECK_EQUAL( 8, helper.payout( ath.paula_id, 40 ).value );
|
||||
// ath.alice_ppy += 8;
|
||||
//
|
||||
// // intermediate commit should clear internal accumulator
|
||||
// helper.commit();
|
||||
//
|
||||
// // 20% of 59 = 11: 6 to Alice, 5 to Ann
|
||||
// BOOST_CHECK_EQUAL( 11, helper.payout( ath.penny_id, 59 ).value );
|
||||
// ath.alice_ppy += 6;
|
||||
// ath.ann_ppy += 5;
|
||||
//
|
||||
// helper.commit();
|
||||
//
|
||||
// BOOST_CHECK_EQUAL( ath.alice_ppy, get_balance( ath.alice_id, asset_id_type() ) );
|
||||
// BOOST_CHECK_EQUAL( ath.ann_ppy, get_balance( ath.ann_id, asset_id_type() ) );
|
||||
// BOOST_CHECK_EQUAL( ath.audrey_ppy, get_balance( ath.audrey_id, asset_id_type() ) );
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// const betting_market_group_object& game = db.create<betting_market_group_object>( [btc_id]( betting_market_group_object& b ) {
|
||||
// b.asset_id = btc_id;
|
||||
// } );
|
||||
// affiliate_payout_helper helper = affiliate_payout_helper( db, game );
|
||||
// // 20% of 60 = 12: 7 to Alice, 5 to Ann
|
||||
// BOOST_CHECK_EQUAL( 12, helper.payout( ath.penny_id, 60 ).value );
|
||||
// alice_btc += 7;
|
||||
// ann_btc += 5;
|
||||
// helper.commit();
|
||||
// BOOST_CHECK_EQUAL( alice_btc, get_balance( ath.alice_id, btc_id ) );
|
||||
// BOOST_CHECK_EQUAL( ann_btc, get_balance( ath.ann_id, btc_id ) );
|
||||
// BOOST_CHECK_EQUAL( audrey_btc, get_balance( ath.audrey_id, btc_id ) );
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// // Fix total supply
|
||||
// auto& index = db.get_index_type< primary_index< account_balance_index > >().get_secondary_index<balances_by_account_index>();
|
||||
// auto abo = index.get_account_balance( account_id_type(), asset_id_type() );
|
||||
// BOOST_CHECK( abo != nullptr );
|
||||
// db.modify( *abo, [&ath]( account_balance_object& bal ) {
|
||||
// bal.balance -= ath.alice_ppy + ath.ann_ppy + ath.audrey_ppy;
|
||||
// });
|
||||
//
|
||||
// abo = index.get_account_balance( irene_id, btc_id );
|
||||
// BOOST_CHECK( abo != nullptr );
|
||||
// db.modify( *abo, [alice_btc,ann_btc,audrey_btc]( account_balance_object& bal ) {
|
||||
// bal.balance -= alice_btc + ann_btc + audrey_btc;
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( rps_tournament_payout_test )
|
||||
|
|
@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test )
|
|||
{ try {
|
||||
ACTORS( (irene) );
|
||||
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTC", irene, 0 ).id;
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTCTEST", irene, 0 ).id;
|
||||
|
||||
affiliate_test_helper ath( *this );
|
||||
|
||||
|
|
@ -616,7 +616,7 @@ BOOST_AUTO_TEST_CASE( statistics_test )
|
|||
|
||||
INVOKE(bookie_payout_test);
|
||||
|
||||
const asset_id_type btc_id = get_asset( "BTC" ).id;
|
||||
const asset_id_type btc_id = get_asset( "BTCTEST" ).id;
|
||||
|
||||
transfer( ath.alice_id, ath.ann_id, asset( 100, btc_id ), asset(0) );
|
||||
transfer( ath.alice_id, ath.audrey_id, asset( 100, btc_id ), asset(0) );
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
|
|||
const account_object& dan = create_account("dan"); // create op 1
|
||||
|
||||
create_bitasset("CNY", dan.id); // create op 2
|
||||
create_bitasset("BTC", account_id_type()); // create op 3
|
||||
create_bitasset("BTCTEST", account_id_type()); // create op 3
|
||||
create_bitasset("XMR", dan.id); // create op 4
|
||||
create_bitasset("EUR", account_id_type()); // create op 5
|
||||
create_bitasset("OIL", dan.id); // create op 6
|
||||
|
|
@ -454,7 +454,7 @@ BOOST_AUTO_TEST_CASE(track_account) {
|
|||
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
|
||||
|
||||
// create more ops, starting with an untracked account
|
||||
create_bitasset( "BTC", account_id_type() );
|
||||
create_bitasset( "BTCTEST", account_id_type() );
|
||||
create_bitasset( "GBP", dan_id );
|
||||
|
||||
generate_block( ~database::skip_fork_db );
|
||||
|
|
@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(track_account) {
|
|||
db.pop_block();
|
||||
|
||||
// Try again, should result in same object IDs
|
||||
create_bitasset( "BTC", account_id_type() );
|
||||
create_bitasset( "BTCTEST", account_id_type() );
|
||||
create_bitasset( "GBP", dan_id );
|
||||
|
||||
generate_block();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE( create_lottery_asset_test )
|
|||
creator.issuer = account_id_type();
|
||||
creator.fee = asset();
|
||||
char symbol[5] = "LOT";
|
||||
symbol[3] = (char)('A' - 1 + test_asset_id.instance.value); symbol[4] = '\0'; // symbol depending on asset_id
|
||||
symbol[3] = (char)('A' - 2 + test_asset_id.instance.value); symbol[4] = '\0'; // symbol depending on asset_id
|
||||
creator.symbol = symbol;
|
||||
creator.common_options.max_supply = 200;
|
||||
creator.precision = 0;
|
||||
|
|
@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE( create_lottery_asset_test )
|
|||
lottery_options.end_date = db.head_block_time() + fc::minutes(5);
|
||||
lottery_options.ticket_price = asset(100);
|
||||
lottery_options.winning_tickets = { 5 * GRAPHENE_1_PERCENT, 5 * GRAPHENE_1_PERCENT, 5 * GRAPHENE_1_PERCENT, 10 * GRAPHENE_1_PERCENT, 10 * GRAPHENE_1_PERCENT, 10 * GRAPHENE_1_PERCENT, 10 * GRAPHENE_1_PERCENT, 10 * GRAPHENE_1_PERCENT, 10 * GRAPHENE_1_PERCENT };
|
||||
lottery_options.is_active = test_asset_id.instance.value % 2;
|
||||
lottery_options.is_active = (test_asset_id.instance.value - 1) % 2;
|
||||
lottery_options.ending_on_soldout = true;
|
||||
|
||||
creator.extensions = lottery_options;
|
||||
|
|
|
|||
Loading…
Reference in a new issue