Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port back direct comparison enum and fix API key #688

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/addr_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/config/yaml_baking_conf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange that conf_obj[REWARDS_TYPE] can be a string which needs further investigations why this is happening. For now I just port back as a quick hotfix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you test for a string and make a case handling here? Maybe there is no proper cast in die config loader?

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"
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/test_api_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"])


Expand Down Expand Up @@ -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"])


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_tzkt_reward_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_tzpro_block_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_tzpro_reward_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)


Expand Down
14 changes: 4 additions & 10 deletions tests/regression/test_baker_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand All @@ -19,9 +19,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"
),
pytest.param(TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl"),
],
)
def test_address_is_baker_address(block_api):
Expand Down Expand Up @@ -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, TZ_PRO_API_KEY), id="TzProBlockApiImpl"
),
pytest.param(TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl"),
],
)
def test_address_is_not_baker_address(block_api):
Expand Down Expand Up @@ -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, TZ_PRO_API_KEY), id="TzProBlockApiImpl"
),
pytest.param(TzProBlockApiImpl(network, TZPRO_API_KEY), id="TzProBlockApiImpl"),
],
)
def test_invalid_baking_address(block_api):
Expand Down
Loading