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

fix: error message condition #189

Merged
merged 2 commits into from
Dec 18, 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
6 changes: 6 additions & 0 deletions tests/internal/test_ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def test_verify_ipfs_description_empty():
"and take fixed space in the script regardless of text length."
)

def test_verify_ipfs_description_good_address():
result = verify_ipfs_description(
f" `0xDfe76d11b365f5e0023343A367f0b311701B3bc1` "
)
assert len(result) == 0


def test_verify_ipfs_description_ugly_addresses():
tail = "1234567890abcdefABCDEF00000000000000000"
Expand Down
17 changes: 9 additions & 8 deletions utils/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,17 @@ def verify_ipfs_description(text: str) -> list[Tuple[str, str]]:

if all_address_raw_groups:
wrong_address_raw = list(filter(lambda address: not checksum_verify(address), all_address_raw_groups))
messages.append(
(
"error",
if wrong_address_raw:
messages.append(
(
"You have wallet addresses in description which has wrong hash sum. "
"Here is the list of addresses:\n"
f"{linesep.join(wrong_address_raw)}"
),
"error",
(
"You have wallet addresses in description which has wrong hash sum. "
"Here is the list of addresses:\n"
f"{linesep.join(wrong_address_raw)}"
),
)
)
)
ugly_cid_raw_groups = re.findall(rf"([^`]{REG_CID_DEFAULT}|{REG_CID_DEFAULT}[^`])", f" {text} ")
if ugly_cid_raw_groups:
cid_raw = list(map(lambda x: x[1] or x[2], ugly_cid_raw_groups))
Expand Down