Skip to content

Commit 6e5a9f5

Browse files
authored
Merge pull request #2267 from bitshares/fix-vp-tests
Fix VP tests
2 parents 2061e2b + f863582 commit 6e5a9f5

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

tests/tests/pob_tests.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,11 +1511,12 @@ BOOST_AUTO_TEST_CASE( withdraw_lock_180_ticket )
15111511
set_expiration( db, trx );
15121512

15131513
// no change
1514+
bool has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
15141515
BOOST_CHECK( tick_1_id(db).target_type == liquid );
15151516
BOOST_CHECK( tick_1_id(db).current_type == liquid );
15161517
BOOST_CHECK( tick_1_id(db).status == withdrawing );
15171518
BOOST_CHECK( tick_1_id(db).amount == asset(100) );
1518-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 100 );
1519+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 100 );
15191520
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
15201521

15211522
// 1 day passed
@@ -1569,23 +1570,25 @@ BOOST_AUTO_TEST_CASE( withdraw_lock_360_ticket )
15691570
set_expiration( db, trx );
15701571

15711572
// the ticket should have downgraded
1573+
bool has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
15721574
BOOST_CHECK( tick_1_id(db).target_type == liquid );
15731575
BOOST_CHECK( tick_1_id(db).current_type == liquid );
15741576
BOOST_CHECK( tick_1_id(db).status == withdrawing );
15751577
BOOST_CHECK( tick_1_id(db).amount == asset(100) );
1576-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 100 );
1578+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 100 );
15771579
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
15781580

15791581
// 179 days passed
15801582
generate_blocks( db.head_block_time() + fc::days(179) );
15811583
set_expiration( db, trx );
15821584

15831585
// no change
1586+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
15841587
BOOST_CHECK( tick_1_id(db).target_type == liquid );
15851588
BOOST_CHECK( tick_1_id(db).current_type == liquid );
15861589
BOOST_CHECK( tick_1_id(db).status == withdrawing );
15871590
BOOST_CHECK( tick_1_id(db).amount == asset(100) );
1588-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 100 );
1591+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 100 );
15891592
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
15901593

15911594
// 1 day passed
@@ -1683,11 +1686,12 @@ BOOST_AUTO_TEST_CASE( withdraw_lock_720_ticket )
16831686
set_expiration( db, trx );
16841687

16851688
// the ticket should have downgraded
1689+
bool has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
16861690
BOOST_CHECK( tick_1_id(db).target_type == liquid );
16871691
BOOST_CHECK( tick_1_id(db).current_type == liquid );
16881692
BOOST_CHECK( tick_1_id(db).status == withdrawing );
16891693
BOOST_CHECK( tick_1_id(db).amount == asset(100) );
1690-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 100 );
1694+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 100 );
16911695
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
16921696

16931697
// unable to update ticket if not to change target type
@@ -1700,11 +1704,12 @@ BOOST_AUTO_TEST_CASE( withdraw_lock_720_ticket )
17001704
set_expiration( db, trx );
17011705

17021706
// no change
1707+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
17031708
BOOST_CHECK( tick_1_id(db).target_type == liquid );
17041709
BOOST_CHECK( tick_1_id(db).current_type == liquid );
17051710
BOOST_CHECK( tick_1_id(db).status == withdrawing );
17061711
BOOST_CHECK( tick_1_id(db).amount == asset(100) );
1707-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 100 );
1712+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 100 );
17081713
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
17091714

17101715
// unable to update ticket if not to change target type
@@ -2753,14 +2758,15 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again )
27532758
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
27542759

27552760
// downgrade again
2761+
bool has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
27562762
result = update_ticket( tick_1_id(db), liquid, {} );
27572763
BOOST_CHECK_EQUAL( result.new_objects.size(), 0u );
27582764

27592765
BOOST_CHECK( tick_1_id(db).target_type == liquid );
27602766
BOOST_CHECK( tick_1_id(db).current_type == liquid );
27612767
BOOST_CHECK( tick_1_id(db).status == withdrawing );
27622768
BOOST_CHECK( tick_1_id(db).amount == asset(90) );
2763-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 90 );
2769+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 90 );
27642770
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
27652771

27662772
BOOST_CHECK( tick_1_id(db).next_type_downgrade_time != time_point_sec::maximum() );
@@ -2774,11 +2780,12 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again )
27742780
result = update_ticket( tick_1_id(db), lock_720_days, {} );
27752781
BOOST_CHECK_EQUAL( result.new_objects.size(), 0u );
27762782

2783+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
27772784
BOOST_CHECK( tick_1_id(db).target_type == lock_720_days );
27782785
BOOST_CHECK( tick_1_id(db).current_type == liquid );
27792786
BOOST_CHECK( tick_1_id(db).status == charging );
27802787
BOOST_CHECK( tick_1_id(db).amount == asset(90) );
2781-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 90 );
2788+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 90 );
27822789
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
27832790

27842791
BOOST_CHECK( tick_1_id(db).next_type_downgrade_time == down_time );
@@ -2787,11 +2794,12 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again )
27872794
result = update_ticket( tick_1_id(db), liquid, {} );
27882795
BOOST_CHECK_EQUAL( result.new_objects.size(), 0u );
27892796

2797+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
27902798
BOOST_CHECK( tick_1_id(db).target_type == liquid );
27912799
BOOST_CHECK( tick_1_id(db).current_type == liquid );
27922800
BOOST_CHECK( tick_1_id(db).status == withdrawing );
27932801
BOOST_CHECK( tick_1_id(db).amount == asset(90) );
2794-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 90 );
2802+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 90 );
27952803
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
27962804

27972805
BOOST_CHECK( tick_1_id(db).next_type_downgrade_time == down_time );
@@ -2804,11 +2812,12 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again )
28042812
result = update_ticket( tick_1_id(db), lock_720_days, {} );
28052813
BOOST_CHECK_EQUAL( result.new_objects.size(), 0u );
28062814

2815+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
28072816
BOOST_CHECK( tick_1_id(db).target_type == lock_720_days );
28082817
BOOST_CHECK( tick_1_id(db).current_type == liquid );
28092818
BOOST_CHECK( tick_1_id(db).status == charging );
28102819
BOOST_CHECK( tick_1_id(db).amount == asset(90) );
2811-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 90 );
2820+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 90 );
28122821
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
28132822

28142823
BOOST_CHECK( tick_1_id(db).next_type_downgrade_time == down_time );
@@ -2818,11 +2827,12 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again )
28182827
set_expiration( db, trx );
28192828

28202829
// no change
2830+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
28212831
BOOST_CHECK( tick_1_id(db).target_type == lock_720_days );
28222832
BOOST_CHECK( tick_1_id(db).current_type == liquid );
28232833
BOOST_CHECK( tick_1_id(db).status == charging );
28242834
BOOST_CHECK( tick_1_id(db).amount == asset(90) );
2825-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 90 );
2835+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 90 );
28262836
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance );
28272837

28282838
BOOST_CHECK( tick_1_id(db).next_type_downgrade_time == down_time );
@@ -2842,11 +2852,12 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again )
28422852
BOOST_CHECK( !db.find( tick_3_id ) );
28432853

28442854
// check the remainder
2855+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
28452856
BOOST_CHECK( tick_1_id(db).target_type == lock_720_days );
28462857
BOOST_CHECK( tick_1_id(db).current_type == liquid );
28472858
BOOST_CHECK( tick_1_id(db).status == charging );
28482859
BOOST_CHECK( tick_1_id(db).amount == asset(75) );
2849-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 75 );
2860+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 75 );
28502861
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance + 15 );
28512862

28522863
BOOST_CHECK( tick_1_id(db).next_type_downgrade_time == down_time );
@@ -2857,11 +2868,12 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again )
28572868
generate_block();
28582869

28592870
// no change
2871+
has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
28602872
BOOST_CHECK( tick_1_id(db).target_type == lock_720_days );
28612873
BOOST_CHECK( tick_1_id(db).current_type == liquid );
28622874
BOOST_CHECK( tick_1_id(db).status == charging );
28632875
BOOST_CHECK( tick_1_id(db).amount == asset(75) );
2864-
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, 75 );
2876+
BOOST_CHECK_EQUAL( tick_1_id(db).value.value, has_hf_2262 ? 0 : 75 );
28652877
BOOST_CHECK_EQUAL( db.get_balance( sam_id, asset_id_type() ).amount.value, sam_balance + 15 );
28662878

28672879
BOOST_CHECK( tick_1_id(db).next_type_downgrade_time == down_time );

tests/tests/voting_tests.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,10 @@ BOOST_AUTO_TEST_CASE( witness_votes_calculation )
817817
generate_blocks( tick_start_time + fc::days(60+180) );
818818
generate_blocks( db.get_dynamic_global_properties().next_maintenance_time );
819819

820+
bool has_hf_2262 = ( HARDFORK_CORE_2262_PASSED( db.get_dynamic_global_properties().next_maintenance_time ) );
820821
// check votes
821822
base4 = 40 * 6 + (114 - 40) - 40;
822-
expected_votes[4] = base4 - base4 * 6 / 8; // 585 days
823+
expected_votes[4] = ( has_hf_2262 ? 0 : (base4 - base4 * 6 / 8) ); // 585 days
823824
base7 = 20 * 8 * 6 + (30 - 20) * 6 + (117 - 30 - 20) - (30 - 20);
824825
expected_votes[7] = 0; // 720 days
825826

@@ -829,8 +830,11 @@ BOOST_AUTO_TEST_CASE( witness_votes_calculation )
829830
}
830831

831832
expected_active_witnesses = original_wits;
832-
expected_active_witnesses.erase( *expected_active_witnesses.rbegin() );
833-
expected_active_witnesses.insert( wit_ids[4] );
833+
if( !has_hf_2262 )
834+
{
835+
expected_active_witnesses.erase( *expected_active_witnesses.rbegin() );
836+
expected_active_witnesses.insert( wit_ids[4] );
837+
}
834838
BOOST_CHECK( db.get_global_properties().active_witnesses == expected_active_witnesses );
835839

836840
} FC_LOG_AND_RETHROW()

0 commit comments

Comments
 (0)