Example #1
0
    def test_expected_rewards(self, address, cycle):
        tzstats_rewards = load_reward_model(address, cycle, "expected")
        if tzstats_rewards is None:
            tzstats_impl = TzStatsRewardApiImpl(
                nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], baking_address=address
            )
            tzstats_rewards = tzstats_impl.get_rewards_for_cycle_map(
                cycle, RewardsType.ESTIMATED
            )
            store_reward_model(address, cycle, "expected", tzstats_rewards)

        tzkt_impl = TzKTRewardApiImpl(
            nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], baking_address=address
        )
        tzkt_rewards = tzkt_impl.get_rewards_for_cycle_map(cycle, RewardsType.ESTIMATED)

        self.assertAlmostEqual(
            tzstats_rewards.delegate_staking_balance,
            tzkt_rewards.delegate_staking_balance,
            delta=1,
        )
        self.assertAlmostEqual(
            tzstats_rewards.total_reward_amount,
            tzkt_rewards.total_reward_amount,
            delta=1,
        )
        self.assertBalancesAlmostEqual(
            tzstats_rewards.delegator_balance_dict,
            tzkt_rewards.delegator_balance_dict,
            delta=1,
        )
Example #2
0
    def test_staking_balance_issue(self):
        address = "tz1V4qCyvPKZ5UeqdH14HN42rxvNPQfc9UZg"
        cycle = 220  # snapshot index == 15

        rpc_rewards = load_reward_model(address, cycle, "actual")
        if rpc_rewards is None:
            rpc_impl = RpcRewardApiImpl(
                nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"],
                baking_address=address,
                node_url=RPC_PUBLIC_API_URL["MAINNET"],
            )
            rpc_rewards = rpc_impl.get_rewards_for_cycle_map(cycle, RewardsType.ACTUAL)
            store_reward_model(address, cycle, "actual", rpc_rewards)

        tzkt_impl = TzKTRewardApiImpl(
            nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], baking_address=address
        )
        tzkt_rewards = tzkt_impl.get_rewards_for_cycle_map(cycle, RewardsType.ACTUAL)

        self.assertAlmostEqual(
            rpc_rewards.delegate_staking_balance, tzkt_rewards.delegate_staking_balance
        )
        self.assertAlmostEqual(
            rpc_rewards.total_reward_amount, tzkt_rewards.total_reward_amount, delta=1
        )
def test_get_rewards_for_cycle_map(address_api):
    rewards = load_reward_model(
        STAKENOW_ADDRESS, CYCLE, RewardsType.ACTUAL, dir_name="rpc_data"
    )
    if rewards is None:
        rewards = address_api.get_rewards_for_cycle_map(
            cycle=CYCLE, rewards_type=RewardsType.ACTUAL
        )
        store_reward_model(
            STAKENOW_ADDRESS, CYCLE, RewardsType.ACTUAL, rewards, dir_name="rpc_data"
        )
    assert rewards.delegate_staking_balance == 162719327201
    assert rewards.total_reward_amount == 123000000
    assert len(rewards.delegator_balance_dict) == 19
    def test_get_rewards_for_cycle_map(self, address, cycle):
        """
        This test compares the total rewards and balance according to tzkt,
        to the total rewards according to rpc.

        It also compares the balances per delegator.
        """
        rpc_rewards = load_reward_model(address,
                                        cycle,
                                        RewardsType.ACTUAL,
                                        dir_name="tzkt_data")
        if rpc_rewards is None:
            rpc_impl = RpcRewardApiImpl(
                nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"],
                baking_address=address,
                node_url=PUBLIC_NODE_URL["MAINNET"],
            )
            rpc_rewards = rpc_impl.get_rewards_for_cycle_map(
                cycle, RewardsType.ACTUAL)
            store_reward_model(address,
                               cycle,
                               RewardsType.ACTUAL,
                               rpc_rewards,
                               dir_name="tzkt_data")

        tzkt_impl = TzKTRewardApiImpl(nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"],
                                      baking_address=address)
        tzkt_rewards = tzkt_impl.get_rewards_for_cycle_map(
            cycle, RewardsType.ACTUAL)

        self.assertAlmostEqual(
            rpc_rewards.delegate_staking_balance,
            tzkt_rewards.delegate_staking_balance,
            delta=1,
        )
        self.assertAlmostEqual(rpc_rewards.total_reward_amount,
                               tzkt_rewards.total_reward_amount,
                               delta=1)
        self.assertBalancesAlmostEqual(
            rpc_rewards.delegator_balance_dict,
            tzkt_rewards.delegator_balance_dict,
            delta=1,
        )