def test_correct_issue_amount_on_calc_period_prev_icx_is_less_than_prev_i_score_additional_issuing( self): # success case: when need additional issuing prev_calc_period_issued_icx = 9_000 prev_calc_period_issued_iscore = 10_000_325 icx_issue_amount = 2_000 over_issued_i_score = 100_321 prev_block_cumulative_fee = 0 covered_icx_by_fee, covered_icx_by_remain, remain_over_issued_iscore, corrected_icx_issue_amount = \ Regulator._correct_issue_amount_on_calc_period(prev_calc_period_issued_icx, prev_calc_period_issued_iscore, over_issued_i_score, icx_issue_amount, prev_block_cumulative_fee) expected_diff_without_fee = prev_calc_period_issued_icx * ISCORE_EXCHANGE_RATE - prev_calc_period_issued_iscore \ + over_issued_i_score expected_covered_by_remain = -(expected_diff_without_fee // -ISCORE_EXCHANGE_RATE) assert covered_icx_by_fee == prev_block_cumulative_fee assert covered_icx_by_remain == expected_covered_by_remain assert corrected_icx_issue_amount == icx_issue_amount + ( -expected_covered_by_remain) assert remain_over_issued_iscore == expected_diff_without_fee % -ISCORE_EXCHANGE_RATE
def test_correct_issue_amount_on_calc_period_prev_icx_is_less_than_prev_i_score( self): # success case: when remain over issued icx overwhelm additional issuing amount. prev_calc_period_issued_icx = 9_000 prev_calc_period_issued_iscore = 10_000_325 icx_issue_amount = 2_000 over_issued_i_score = 5_000_321 prev_block_cumulative_fee = 0 covered_icx_by_fee, covered_icx_by_remain, remain_over_issued_iscore, corrected_icx_issue_amount = \ Regulator._correct_issue_amount_on_calc_period(prev_calc_period_issued_icx, prev_calc_period_issued_iscore, over_issued_i_score, icx_issue_amount, prev_block_cumulative_fee) expected_diff_without_fee = prev_calc_period_issued_icx * ISCORE_EXCHANGE_RATE - prev_calc_period_issued_iscore \ + over_issued_i_score assert covered_icx_by_remain == icx_issue_amount assert covered_icx_by_fee == prev_block_cumulative_fee assert corrected_icx_issue_amount == 0 assert remain_over_issued_iscore == expected_diff_without_fee - ( icx_issue_amount * ISCORE_EXCHANGE_RATE)
def test_correct_issue_amount_on_calc_period_when_first_calc_period(self): # success case: when prev issued i score and prev issued icx data is zero, should return below # covered_by_fee = 0 # covered_by_remain = 0 # remain_over_issued_icx = 0 # corrected_icx_issue_amount = icx_issue_amount icx_issue_amount = 1000 over_issued_i_score = 0 prev_block_cumulative_fee = 0 prev_calc_period_issued_icx = 0 prev_calc_period_issued_iscore = 0 covered_icx_by_fee, covered_icx_by_remain, remain_over_issued_iscore, corrected_icx_issue_amount = \ Regulator._correct_issue_amount_on_calc_period(prev_calc_period_issued_icx, prev_calc_period_issued_iscore, over_issued_i_score, icx_issue_amount, prev_block_cumulative_fee) assert remain_over_issued_iscore == 0 assert covered_icx_by_remain == 0 assert covered_icx_by_fee == 0 assert corrected_icx_issue_amount == icx_issue_amount
def test_correct_issue_amount_on_calc_period_prev_icx_is_more_than_prev_i_score( self): # success case: when remain over issued icx + prev calc over issued icx < icx_issue amount # fee is excluded (i.e. set to zero) as tested before prev_calc_period_issued_icx = 10_000 prev_calc_period_issued_iscore = 9_000_325 over_issued_i_score = 500_400 icx_issue_amount = 2_000 prev_block_cumulative_fee = 0 covered_icx_by_fee, covered_icx_by_remain, remain_over_issued_iscore, corrected_icx_issue_amount = \ Regulator._correct_issue_amount_on_calc_period(prev_calc_period_issued_icx, prev_calc_period_issued_iscore, over_issued_i_score, icx_issue_amount, prev_block_cumulative_fee) expected_diff_without_fee = prev_calc_period_issued_icx * ISCORE_EXCHANGE_RATE - prev_calc_period_issued_iscore \ + over_issued_i_score expected_covered_by_remain = (expected_diff_without_fee // ISCORE_EXCHANGE_RATE) assert covered_icx_by_fee == prev_block_cumulative_fee assert covered_icx_by_remain == expected_covered_by_remain assert corrected_icx_issue_amount == icx_issue_amount - expected_covered_by_remain - prev_block_cumulative_fee assert remain_over_issued_iscore == expected_diff_without_fee - expected_covered_by_remain * ISCORE_EXCHANGE_RATE # success case: when remain over issued icx + prev calc over issued icx > icx_issue amount over_issued_i_score = 5_000_300 icx_issue_amount = 1_000 prev_block_cumulative_fee = 0 covered_icx_by_fee, covered_icx_by_remain, remain_over_issued_iscore, corrected_icx_issue_amount = \ Regulator._correct_issue_amount_on_calc_period(prev_calc_period_issued_icx, prev_calc_period_issued_iscore, over_issued_i_score, icx_issue_amount, prev_block_cumulative_fee) expected_diff_without_fee = prev_calc_period_issued_icx * ISCORE_EXCHANGE_RATE - prev_calc_period_issued_iscore \ + over_issued_i_score assert covered_icx_by_fee == prev_block_cumulative_fee assert covered_icx_by_remain == icx_issue_amount assert corrected_icx_issue_amount == 0 assert remain_over_issued_iscore == expected_diff_without_fee - covered_icx_by_remain * ISCORE_EXCHANGE_RATE
def test_correct_issue_amount_on_calc_period_prev_icx_and_prev_i_score_is_same( self): # success case: when need additional issuing prev_calc_period_issued_icx = 10_000 prev_calc_period_issued_iscore = 10_000_000 icx_issue_amount = 0 over_issued_i_score = 0 prev_block_cumulative_fee = 0 covered_icx_by_fee, covered_icx_by_remain, remain_over_issued_iscore, corrected_icx_issue_amount = \ Regulator._correct_issue_amount_on_calc_period(prev_calc_period_issued_icx, prev_calc_period_issued_iscore, over_issued_i_score, icx_issue_amount, prev_block_cumulative_fee) assert covered_icx_by_remain == 0 assert covered_icx_by_fee == 0 assert corrected_icx_issue_amount == icx_issue_amount assert remain_over_issued_iscore == 0