update tests

This commit is contained in:
Lex Berezhny 2020-06-10 15:45:29 -04:00
parent a39f87b3c5
commit 410212c17a
3 changed files with 21 additions and 21 deletions

View file

@ -1,7 +1,7 @@
from unittest import TestCase from unittest import TestCase
from binascii import unhexlify from binascii import unhexlify
from lbry.schema import Claim from lbry.schema.claim import Claim
class TestOldJSONSchemaCompatibility(TestCase): class TestOldJSONSchemaCompatibility(TestCase):

View file

@ -103,19 +103,19 @@ class TestTags(TestCase):
def test_normalize_tags(self): def test_normalize_tags(self):
claim = Claim() claim = Claim()
claim.channel.update(tags=['Anime', 'anime', ' aNiMe', 'maNGA ']) claim.channel.update(tag=['Anime', 'anime', ' aNiMe', 'maNGA '])
self.assertCountEqual(claim.channel.tags, ['anime', 'manga']) self.assertCountEqual(claim.channel.tags, ['anime', 'manga'])
claim.channel.update(tags=['Juri', 'juRi']) claim.channel.update(tag=['Juri', 'juRi'])
self.assertCountEqual(claim.channel.tags, ['anime', 'manga', 'juri']) self.assertCountEqual(claim.channel.tags, ['anime', 'manga', 'juri'])
claim.channel.update(tags='Anime') claim.channel.update(tag='Anime')
self.assertCountEqual(claim.channel.tags, ['anime', 'manga', 'juri']) self.assertCountEqual(claim.channel.tags, ['anime', 'manga', 'juri'])
claim.channel.update(clear_tags=True) claim.channel.update(clear_tags=True)
self.assertEqual(len(claim.channel.tags), 0) self.assertEqual(len(claim.channel.tags), 0)
claim.channel.update(tags='Anime') claim.channel.update(tag='Anime')
self.assertEqual(claim.channel.tags, ['anime']) self.assertEqual(claim.channel.tags, ['anime'])

View file

@ -1,16 +1,16 @@
from unittest import TestCase from unittest import TestCase
from binascii import unhexlify from binascii import unhexlify
from lbry.testcase import get_transaction from lbry.testcase import get_transaction, AsyncioTestCase
from lbry.blockchain.ledger import Ledger from lbry.blockchain.ledger import Ledger
from lbry.blockchain.transaction import Transaction, Output from lbry.blockchain.transaction import Transaction, Output
from lbry.constants import CENT from lbry.constants import CENT
from lbry.schema.claim import Claim from lbry.schema.claim import Claim
def get_channel(claim_name='@foo'): async def get_channel(claim_name='@foo'):
channel_txo = Output.pay_claim_name_pubkey_hash(CENT, claim_name, Claim(), b'abc') channel_txo = Output.pay_claim_name_pubkey_hash(CENT, claim_name, Claim(), b'abc')
channel_txo.generate_channel_private_key() await channel_txo.generate_channel_private_key()
return get_transaction(channel_txo).outputs[0] return get_transaction(channel_txo).outputs[0]
@ -19,34 +19,34 @@ def get_stream(claim_name='foo'):
return get_transaction(stream_txo).outputs[0] return get_transaction(stream_txo).outputs[0]
class TestSigningAndValidatingClaim(TestCase): class TestSigningAndValidatingClaim(AsyncioTestCase):
def test_successful_create_sign_and_validate(self): async def test_successful_create_sign_and_validate(self):
channel = get_channel() channel = await get_channel()
stream = get_stream() stream = get_stream()
stream.sign(channel) stream.sign(channel)
self.assertTrue(stream.is_signed_by(channel)) self.assertTrue(stream.is_signed_by(channel))
def test_fail_to_validate_on_wrong_channel(self): async def test_fail_to_validate_on_wrong_channel(self):
stream = get_stream() stream = get_stream()
stream.sign(get_channel()) stream.sign(await get_channel())
self.assertFalse(stream.is_signed_by(get_channel())) self.assertFalse(stream.is_signed_by(await get_channel()))
def test_fail_to_validate_altered_claim(self): async def test_fail_to_validate_altered_claim(self):
channel = get_channel() channel = await get_channel()
stream = get_stream() stream = get_stream()
stream.sign(channel) stream.sign(channel)
self.assertTrue(stream.is_signed_by(channel)) self.assertTrue(stream.is_signed_by(channel))
stream.claim.stream.title = 'hello' stream.claim.stream.title = 'hello'
self.assertFalse(stream.is_signed_by(channel)) self.assertFalse(stream.is_signed_by(channel))
def test_valid_private_key_for_cert(self): async def test_valid_private_key_for_cert(self):
channel = get_channel() channel = await get_channel()
self.assertTrue(channel.is_channel_private_key(channel.private_key)) self.assertTrue(channel.is_channel_private_key(channel.private_key))
def test_fail_to_load_wrong_private_key_for_cert(self): async def test_fail_to_load_wrong_private_key_for_cert(self):
channel = get_channel() channel = await get_channel()
self.assertFalse(channel.is_channel_private_key(get_channel().private_key)) self.assertFalse(channel.is_channel_private_key((await get_channel()).private_key))
class TestValidatingOldSignatures(TestCase): class TestValidatingOldSignatures(TestCase):