From 623566886d2f3c65060caaae747c9ef619232adc Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 6 Nov 2023 11:35:37 +0100 Subject: [PATCH 1/4] Port back direct comparison enum --- .github/workflows/ci.yml | 2 +- src/config/yaml_baking_conf_parser.py | 2 +- src/model/baking_conf.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1df88b9a..d944c025 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: - name: Test with pytest env: - TZPRO_API_KEY: ${{ secrets.TZPRO_API_KEY }} + TZ_PRO_API_KEY: ${{ secrets.TZ_PRO_API_KEY }} run: pytest tests/ build-documentation: diff --git a/src/config/yaml_baking_conf_parser.py b/src/config/yaml_baking_conf_parser.py index ee3f8150..ec70c233 100644 --- a/src/config/yaml_baking_conf_parser.py +++ b/src/config/yaml_baking_conf_parser.py @@ -351,7 +351,7 @@ def validate_rewards_type(self, conf_obj): "Defaults to 'actual' rewards payout type.".format(REWARDS_TYPE) ) - if conf_obj[REWARDS_TYPE].isEstimated(): + if conf_obj[REWARDS_TYPE] == RewardsType.ESTIMATED: raise ConfigurationException( "Setting 'rewards_type' to 'estimated' is no longer supported.\n" "Please see https://tezos-reward-distributor-organization.github.io/tezos-reward-distributor/payouttiming.html\n" diff --git a/src/model/baking_conf.py b/src/model/baking_conf.py index 15b689ad..56c319fb 100644 --- a/src/model/baking_conf.py +++ b/src/model/baking_conf.py @@ -20,7 +20,7 @@ REWARDS_TYPE = "rewards_type" PAY_DENUNCIATION_REWARDS = "pay_denunciation_rewards" MIN_PAYMENT_AMT = "min_payment_amt" -TZPRO_API_KEY = "tzpro_api_key" +TZ_PRO_API_KEY = "tzpro_api_key" # extensions FULL_SUPPORTERS_SET = "__full_supporters_set" @@ -121,4 +121,4 @@ def get_min_payment_amount(self): return self.get_attribute(MIN_PAYMENT_AMT) def get_tzpro_api_key(self): - return self.get_attribute(TZPRO_API_KEY) + return self.get_attribute(TZ_PRO_API_KEY) From 8541592c5c82b1c3be54ce22988adeba784f0677 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 6 Nov 2023 11:51:51 +0100 Subject: [PATCH 2/4] Fix redefinment --- src/config/addr_type.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/addr_type.py b/src/config/addr_type.py index 39702596..f771b58a 100644 --- a/src/config/addr_type.py +++ b/src/config/addr_type.py @@ -16,7 +16,7 @@ def is_tz(self): def is_ktals(self): return self.value == 3 - def is_tz(self): + def is_tzals(self): return self.value == 4 @staticmethod From fdda6bcec6485cfd7145ed759e576bf11d5ba9d5 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 6 Nov 2023 17:47:00 +0100 Subject: [PATCH 3/4] Update tzpro api key --- .github/workflows/ci.yml | 2 +- src/model/baking_conf.py | 4 ++-- tests/integration/test_api_consistency.py | 10 +++++----- tests/integration/test_tzkt_reward_api.py | 2 +- tests/integration/test_tzpro_block_api.py | 4 ++-- tests/integration/test_tzpro_reward_api.py | 2 +- tests/regression/test_baker_validation.py | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d944c025..1df88b9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: - name: Test with pytest env: - TZ_PRO_API_KEY: ${{ secrets.TZ_PRO_API_KEY }} + TZPRO_API_KEY: ${{ secrets.TZPRO_API_KEY }} run: pytest tests/ build-documentation: diff --git a/src/model/baking_conf.py b/src/model/baking_conf.py index 56c319fb..15b689ad 100644 --- a/src/model/baking_conf.py +++ b/src/model/baking_conf.py @@ -20,7 +20,7 @@ REWARDS_TYPE = "rewards_type" PAY_DENUNCIATION_REWARDS = "pay_denunciation_rewards" MIN_PAYMENT_AMT = "min_payment_amt" -TZ_PRO_API_KEY = "tzpro_api_key" +TZPRO_API_KEY = "tzpro_api_key" # extensions FULL_SUPPORTERS_SET = "__full_supporters_set" @@ -121,4 +121,4 @@ def get_min_payment_amount(self): return self.get_attribute(MIN_PAYMENT_AMT) def get_tzpro_api_key(self): - return self.get_attribute(TZ_PRO_API_KEY) + return self.get_attribute(TZPRO_API_KEY) diff --git a/tests/integration/test_api_consistency.py b/tests/integration/test_api_consistency.py index 0096033b..b1bc8188 100644 --- a/tests/integration/test_api_consistency.py +++ b/tests/integration/test_api_consistency.py @@ -19,7 +19,7 @@ GHOSTNET_ADDRESS_STAKENOW_BAKER = Constants.GHOSTNET_ADDRESS_STAKENOW_BAKER MAINNET_ADDRESS_BAKEXTZ4ME_PAYOUT = Constants.MAINNET_ADDRESS_BAKEXTZ4ME_PAYOUT -TZ_PRO_API_KEY = os.environ.get("TZ_PRO_API_KEY") +TZPRO_API_KEY = os.environ.get("TZPRO_API_KEY") # These tests should not be mocked but test the overall consistency # accross all tezos APIs which are available in TRD @@ -32,7 +32,7 @@ def address_block_api_tzkt(): @pytest.fixture def address_block_api_tzpro(): - return TzProBlockApiImpl(DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], TZ_PRO_API_KEY) + return TzProBlockApiImpl(DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], TZPRO_API_KEY) @pytest.fixture @@ -45,7 +45,7 @@ def address_block_api_rpc(): @pytest.fixture def current_cycle(): tip = "https://api.tzpro.io/explorer/tip" - resp = requests.get(tip, timeout=5, headers={"X-API-Key": TZ_PRO_API_KEY}) + resp = requests.get(tip, timeout=5, headers={"X-API-Key": TZPRO_API_KEY}) return int(resp.json()["cycle"]) @@ -110,14 +110,14 @@ def address_reward_api_tzpro(): return TzProRewardApiImpl( DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], MAINNET_ADDRESS_BAKEXTZ4ME_BAKER, - TZ_PRO_API_KEY, + TZPRO_API_KEY, ) @pytest.fixture def current_cycle_ghostnet(): tip = "https://api.ghost.tzpro.io/explorer/tip" - resp = requests.get(tip, timeout=5, headers={"X-API-Key": TZ_PRO_API_KEY}) + resp = requests.get(tip, timeout=5, headers={"X-API-Key": TZPRO_API_KEY}) return int(resp.json()["cycle"]) diff --git a/tests/integration/test_tzkt_reward_api.py b/tests/integration/test_tzkt_reward_api.py index 7f634c59..40b1223a 100644 --- a/tests/integration/test_tzkt_reward_api.py +++ b/tests/integration/test_tzkt_reward_api.py @@ -128,7 +128,7 @@ def test_expected_rewards(self, address, cycle): tzpro_impl = TzProRewardApiImpl( nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], baking_address=address, - tzpro_api_key=os.environ.get("TZ_PRO_API_KEY"), + tzpro_api_key=os.environ.get("TZPRO_API_KEY"), ) tzpro_rewards = tzpro_impl.get_rewards_for_cycle_map( cycle, RewardsType.ACTUAL diff --git a/tests/integration/test_tzpro_block_api.py b/tests/integration/test_tzpro_block_api.py index 8edbc62b..fcd16270 100644 --- a/tests/integration/test_tzpro_block_api.py +++ b/tests/integration/test_tzpro_block_api.py @@ -7,7 +7,7 @@ MAINNET_ADDRESS_DELEGATOR = Constants.MAINNET_ADDRESS_DELEGATOR MAINNET_ADDRESS_STAKENOW_BAKER = Constants.MAINNET_ADDRESS_STAKENOW_BAKER -TZ_PRO_API_KEY = os.environ.get("TZ_PRO_API_KEY") +TZPRO_API_KEY = os.environ.get("TZPRO_API_KEY") class MockResponse: @@ -21,7 +21,7 @@ def status_code(self): @pytest.fixture def address_api(): - return TzProBlockApiImpl(DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], TZ_PRO_API_KEY) + return TzProBlockApiImpl(DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], TZPRO_API_KEY) def test_get_revelation(address_api): diff --git a/tests/integration/test_tzpro_reward_api.py b/tests/integration/test_tzpro_reward_api.py index 060acaba..420da611 100644 --- a/tests/integration/test_tzpro_reward_api.py +++ b/tests/integration/test_tzpro_reward_api.py @@ -15,7 +15,7 @@ def address_api(): return TzProRewardApiImpl( nw=DEFAULT_NETWORK_CONFIG_MAP["MAINNET"], baking_address=MAINNET_ADDRESS_STAKENOW_BAKER, - tzpro_api_key=os.environ.get("TZ_PRO_API_KEY"), + tzpro_api_key=os.environ.get("TZPRO_API_KEY"), ) diff --git a/tests/regression/test_baker_validation.py b/tests/regression/test_baker_validation.py index 8d5508c3..e3db6d17 100644 --- a/tests/regression/test_baker_validation.py +++ b/tests/regression/test_baker_validation.py @@ -9,7 +9,7 @@ from src.blockwatch.tzpro_block_api import TzProBlockApiImpl from tests.utils import Constants -TZ_PRO_API_KEY = os.environ.get("TZ_PRO_API_KEY") +TZPRO_API_KEY = os.environ.get("TZPRO_API_KEY") node_endpoint = PUBLIC_NODE_URL["MAINNET"] network = {"NAME": "MAINNET"} @@ -20,7 +20,7 @@ pytest.param(RpcBlockApiImpl(network, node_endpoint), id="RpcBlockApiImpl"), pytest.param(TzKTBlockApiImpl(network), id="TzKTBlockApiImpl"), pytest.param( - TzProBlockApiImpl(network, TZ_PRO_API_KEY), id="TzProBlockApiImpl" + TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl" ), ], ) @@ -52,7 +52,7 @@ def test_address_is_baker_address(block_api): pytest.param(RpcBlockApiImpl(network, node_endpoint), id="RpcBlockApiImpl"), pytest.param(TzKTBlockApiImpl(network), id="TzKTBlockApiImpl"), pytest.param( - TzProBlockApiImpl(network, TZ_PRO_API_KEY), id="TzProBlockApiImpl" + TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl" ), ], ) @@ -86,7 +86,7 @@ def test_address_is_not_baker_address(block_api): pytest.param(RpcBlockApiImpl(network, node_endpoint), id="RpcBlockApiImpl"), pytest.param(TzKTBlockApiImpl(network), id="TzKTBlockApiImpl"), pytest.param( - TzProBlockApiImpl(network, TZ_PRO_API_KEY), id="TzProBlockApiImpl" + TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl" ), ], ) From 1907fbb43f7bac7d1e1dfc81bcdc8f12f7eebc88 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 6 Nov 2023 17:49:10 +0100 Subject: [PATCH 4/4] Fix black format --- tests/regression/test_baker_validation.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/regression/test_baker_validation.py b/tests/regression/test_baker_validation.py index e3db6d17..a1c47f3f 100644 --- a/tests/regression/test_baker_validation.py +++ b/tests/regression/test_baker_validation.py @@ -19,9 +19,7 @@ [ pytest.param(RpcBlockApiImpl(network, node_endpoint), id="RpcBlockApiImpl"), pytest.param(TzKTBlockApiImpl(network), id="TzKTBlockApiImpl"), - pytest.param( - TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl" - ), + pytest.param(TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl"), ], ) def test_address_is_baker_address(block_api): @@ -51,9 +49,7 @@ def test_address_is_baker_address(block_api): [ pytest.param(RpcBlockApiImpl(network, node_endpoint), id="RpcBlockApiImpl"), pytest.param(TzKTBlockApiImpl(network), id="TzKTBlockApiImpl"), - pytest.param( - TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl" - ), + pytest.param(TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl"), ], ) def test_address_is_not_baker_address(block_api): @@ -85,9 +81,7 @@ def test_address_is_not_baker_address(block_api): [ pytest.param(RpcBlockApiImpl(network, node_endpoint), id="RpcBlockApiImpl"), pytest.param(TzKTBlockApiImpl(network), id="TzKTBlockApiImpl"), - pytest.param( - TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl" - ), + pytest.param(TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl"), ], ) def test_invalid_baking_address(block_api):