Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lidofinance/scripts into vote_202…
Browse files Browse the repository at this point in the history
…3_12_18
  • Loading branch information
Psirex committed Dec 18, 2023
2 parents fc1ee64 + 3042828 commit 98f8431
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
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

0 comments on commit 98f8431

Please sign in to comment.