Example #1
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
        )
Example #2
0
    def test_get_rewards_for_cycle_map(self, address, cycle):
        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='https://rpc.tzkt.io/mainnet')
            rpc_rewards = rpc_impl.get_rewards_for_cycle_map(cycle)
            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)

        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)
    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,
        )
Example #4
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='https://rpc.tzkt.io/mainnet')
            rpc_rewards = rpc_impl.get_rewards_for_cycle_map(cycle)
            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)

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