Skip to content

Commit

Permalink
test address conversions, fix tagstore query perf issue
Browse files Browse the repository at this point in the history
  • Loading branch information
soad003 committed Dec 21, 2023
1 parent 2a7ef9d commit e797ad6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gsrest/db/tagstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def list_tags_by_address(self,
t.tagpack=tp.id
and c.id=t.confidence
and t.currency = %s
and t.address ILIKE %s
and t.address = %s
and acm.address=t.address
and acm.currency=t.currency
{hide_private_condition(show_private)}
Expand Down
1 change: 1 addition & 0 deletions gsrest/service/addresses_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async def list_tags_by_address(request,
address,
page=None,
pagesize=None):
address = address_to_user_format(currency, address)
return await common.list_tags_by_address(request,
currency,
address,
Expand Down
22 changes: 22 additions & 0 deletions tests/util/test_address_conversions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from gsrest.util.address import cannonicalize_address, address_to_user_format
from gsrest.errors.errors import BadUserInputException

def test_address_conversions():

addr = "TAzsQ9Gx8eqFNFSKbeXrbi45CuVPHzA8wr"

assert cannonicalize_address("trx", addr).hex() == "0b48984414cc0c6a8e599fb6e3bc11e599de2e24"

assert address_to_user_format("trx", cannonicalize_address("trx", addr)) == addr

assert address_to_user_format("trx", addr) == addr

eaddr = "0x0b48984414cc0c6a8e599fb6e3bc11e599de2e24"

assert address_to_user_format("eth", cannonicalize_address("eth", eaddr)) == eaddr

assert cannonicalize_address("eth", eaddr).hex() == "0b48984414cc0c6a8e599fb6e3bc11e599de2e24"

with pytest.raises(BadUserInputException):
cannonicalize_address("eth", addr).hex()

0 comments on commit e797ad6

Please sign in to comment.