Esempio n. 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,
        )
Esempio n. 2
0
    def newRewardApi(
        self,
        network_config,
        baking_address,
        node_url,
        node_url_public="",
        api_base_url=None,
    ):
        if self.provider == "rpc":
            if node_url.find("http") == -1:
                node_url = "http://" + node_url
            return RpcRewardApiImpl(network_config, baking_address, node_url)
        elif self.provider == "prpc":
            if node_url_public == "":
                node_url_public = PUBLIC_NODE_URL[network_config["NAME"]]
            return RpcRewardApiImpl(network_config, baking_address,
                                    node_url_public)
        elif self.provider == "tzstats":
            return TzStatsRewardApiImpl(network_config, baking_address)
        elif self.provider == "tzkt":
            return TzKTRewardApiImpl(network_config,
                                     baking_address,
                                     base_url=api_base_url)

        raise Exception("No supported reward data provider : {}".format(
            self.provider))
    def newRewardApi(self,
                     network_config,
                     baking_address,
                     node_url,
                     node_url_public=''):
        if self.provider == 'rpc':
            if node_url.find("http") == -1:
                node_url = 'http://' + node_url
            return RpcRewardApiImpl(network_config,
                                    baking_address,
                                    node_url,
                                    verbose=self.verbose)
        elif self.provider == 'prpc':
            if node_url_public == '':
                node_url_public = PUBLIC_NODE_URL[network_config['NAME']][0]
            return RpcRewardApiImpl(network_config,
                                    baking_address,
                                    node_url_public,
                                    verbose=self.verbose)
        elif self.provider == 'tzstats':
            return TzStatsRewardApiImpl(network_config,
                                        baking_address,
                                        verbose=self.verbose)

        raise Exception("No supported reward data provider : {}".format(
            self.provider))
Esempio n. 4
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, expected_reward=True)
            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, expected_reward=True)

        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)
Esempio n. 5
0
def address_api():
    return TzStatsRewardApiImpl(
        nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"],
        baking_address=STAKENOW_ADDRESS,
    )