def test_calculate(self): nw = { 'NAME': 'MAINNET', 'NB_FREEZE_CYCLE': 5, 'BLOCK_TIME_IN_SEC': 60, 'BLOCKS_PER_CYCLE': 4096, 'BLOCKS_PER_ROLL_SNAPSHOT': 256 } api = ProviderFactory(provider='prpc').newRewardApi(nw, BAKING_ADDRESS, '') model = api.get_rewards_for_cycle_map(153) phase0 = CalculatePhase0(model) reward_data, total_rewards = phase0.calculate() delegate_staking_balance = int(model.delegate_staking_balance) # total reward ratio is 1 self.assertTrue(1.0, sum(r.ratio0 for r in reward_data)) # check that ratio calculations are correct delegators_balances_dict = model.delegator_balance_dict # check ratios for (address, delegator_info), reward in zip(delegators_balances_dict.items(), reward_data): # ratio must be equal to stake/total staking balance delegator_staking_balance = int(delegator_info["staking_balance"]) self.assertEqual(delegator_staking_balance / delegate_staking_balance, reward.ratio0) # last one is owners record self.assertTrue(reward_data[-1].type == reward_log.TYPE_OWNERS_PARENT)
def test_calculate(self): nw = DEFAULT_NETWORK_CONFIG_MAP["MAINNET"] api = ProviderFactory(provider="tzkt").newRewardApi( nw, BAKING_ADDRESS, "") model = api.get_rewards_for_cycle_map(CYCLE, REWARDS_TYPE) phase0 = CalculatePhase0(model) reward_data = phase0.calculate() delegate_staking_balance = int(model.delegate_staking_balance) # total reward ratio is 1 self.assertEqual(1.0, sum(r.ratio0 for r in reward_data)) # check that ratio calculations are correct delegators_balances_dict = model.delegator_balance_dict # check ratios for (address, delegator_info), reward in zip(delegators_balances_dict.items(), reward_data): # ratio must be equal to stake/total staking balance delegator_staking_balance = int(delegator_info["staking_balance"]) self.assertEqual( delegator_staking_balance / delegate_staking_balance, reward.ratio0) # last one is owners record self.assertTrue(reward_data[-1].type == TYPE_OWNERS_PARENT)