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

Small fixes #95

Merged
merged 1 commit into from
Oct 28, 2022
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
16 changes: 14 additions & 2 deletions open_rarity/resolver/opensea_api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,22 @@ def read_collection_data_from_file(expected_supply: int, slug: str) -> list[Toke
len(tokens_data),
expected_supply,
)
non_null_tokens = 0
if len(tokens_data) > 0:
for token_data in tokens_data:
assert token_data["metadata_dict"]
tokens.append(Token.from_dict(token_data))
if token_data["metadata_dict"]:
non_null_tokens += 1
tokens.append(Token.from_dict(token_data))
null_tokens = len(tokens_data) - non_null_tokens
if null_tokens:
msg = (
f"Warning: Data cache file had empty metadata for {null_tokens} "
"tokens. This is expected if those tokens are burned or "
"unrevealed. However, they are not taken into account into "
"rarity. Please check the cache file for errors."
)
logger.warning(msg)
print(msg)
logger.debug(f"Read {len(tokens)} tokens from cache file: {cache_filename}")
except FileNotFoundError:
logger.warning(f"No opensea cache file found for {slug}: {cache_filename}")
Expand Down
6 changes: 6 additions & 0 deletions tests/resolver/test_rarity_sniffer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import pytest

from open_rarity.resolver.rarity_providers.rank_resolver import RankResolver
from open_rarity.resolver.rarity_providers.rarity_sniffer import RaritySnifferResolver


class TestRaritySnifferResolver:
BORED_APE_COLLECTION_ADDRESS = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"

@pytest.mark.skipif(
"not config.getoption('--run-resolvers')",
reason="This just verifies external APIs but should not block main library",
)
def test_get_all_ranks(self):
token_id_to_ranks = RaritySnifferResolver.get_all_ranks(
contract_address=self.BORED_APE_COLLECTION_ADDRESS
Expand Down