forked from LBRYCommunity/lbry-sdk
make short_url and canonical_url match old SDK
This commit is contained in:
parent
18b25f5146
commit
0a2c161ace
2 changed files with 15 additions and 1 deletions
|
@ -16,7 +16,8 @@ FILES = [
|
|||
|
||||
def make_short_url(r):
|
||||
try:
|
||||
return f'{normalize_name(r["name"].decode())}#{r["shortestID"] or r["claimID"][::-1].hex()[0]}'
|
||||
# fixme: we describe it as normalized but the old SDK didnt do that
|
||||
return f'{r["name"].decode()}#{r["shortestID"] or r["claimID"][::-1].hex()[0]}'
|
||||
except UnicodeDecodeError:
|
||||
# print(f'failed making short url due to name parse error for claim_id: {r["claimID"][::-1].hex()}')
|
||||
return "INVALID NAME"
|
||||
|
|
|
@ -947,6 +947,19 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase):
|
|||
self.assertEqual(claim.take_over_height, 103)
|
||||
self.assertTrue(claim.is_controlling)
|
||||
|
||||
async def test_uris_and_uppercase(self):
|
||||
# fixme: this is a bug but its how the old SDK expects it (non-normalized URIs)
|
||||
# to be decided if we are going to ignore it or how its used today
|
||||
chan_ab = await self.get_claim(
|
||||
await self.create_claim(claim_id_startswith='ab', is_channel=True, name="@Chá"))
|
||||
await self.create_claim(claim_id_startswith='cd', sign=chan_ab, name="Hortelã")
|
||||
await self.generate(1)
|
||||
|
||||
resolutions = Outputs.from_base64(await self.db.protobuf_resolve(["Hortelã"]))
|
||||
self.assertEqual(1, len(resolutions.txos))
|
||||
claim = resolutions.txos[0].claim
|
||||
self.assertEqual("@Chá#a/Hortelã#c", claim.canonical_url)
|
||||
self.assertEqual("Hortelã#c", claim.short_url)
|
||||
|
||||
|
||||
class TestClaimtrieSync(SyncingBlockchainTestCase):
|
||||
|
|
Loading…
Reference in a new issue