Adds comment signature unit testing
This commit is contained in:
parent
636f36ebad
commit
7fa797712a
2 changed files with 33 additions and 0 deletions
0
tests/unit/comments/__init__.py
Normal file
0
tests/unit/comments/__init__.py
Normal file
33
tests/unit/comments/test_comment_signing.py
Normal file
33
tests/unit/comments/test_comment_signing.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from torba.testcase import AsyncioTestCase
|
||||
|
||||
from lbrynet.extras.daemon.comment_client import sign_comment
|
||||
from lbrynet.extras.daemon.comment_client import is_comment_signed_by_channel
|
||||
|
||||
from tests.unit.wallet.test_schema_signing import get_stream, get_channel
|
||||
|
||||
|
||||
class TestSigningComments(AsyncioTestCase):
|
||||
|
||||
@staticmethod
|
||||
def create_claim_comment_body(comment, claim, channel):
|
||||
return {
|
||||
'claim_id': claim.claim_id,
|
||||
'channel_name': channel.claim_name,
|
||||
'channel_id': channel.claim_id,
|
||||
'comment': comment
|
||||
}
|
||||
|
||||
def test01_successful_create_sign_and_validate_comment(self):
|
||||
channel = get_channel('@BusterBluth')
|
||||
stream = get_stream('pop secret')
|
||||
comment = self.create_claim_comment_body('Cool stream', stream, channel)
|
||||
sign_comment(comment, channel)
|
||||
self.assertTrue(is_comment_signed_by_channel(comment, channel))
|
||||
|
||||
def test02_fail_to_validate_spoofed_channel(self):
|
||||
pdiddy = get_channel('@PDitty')
|
||||
channel2 = get_channel('@TomHaverford')
|
||||
stream = get_stream()
|
||||
comment = self.create_claim_comment_body('Woahh This is Sick!! Shout out 2 my boy Tommy H', stream, pdiddy)
|
||||
sign_comment(comment, channel2)
|
||||
self.assertFalse(is_comment_signed_by_channel(comment, pdiddy))
|
Loading…
Reference in a new issue