forked from LBRYCommunity/lbry-sdk
Moves get_channel,get_stream out of Class into their own functions
This commit is contained in:
parent
8e0888b846
commit
636f36ebad
1 changed files with 23 additions and 23 deletions
|
@ -25,47 +25,47 @@ def get_tx():
|
||||||
return Transaction().add_inputs([get_input()])
|
return Transaction().add_inputs([get_input()])
|
||||||
|
|
||||||
|
|
||||||
|
def get_channel(claim_name='@foo'):
|
||||||
|
channel_txo = Output.pay_claim_name_pubkey_hash(CENT, claim_name, Claim(), b'abc')
|
||||||
|
channel_txo.generate_channel_private_key()
|
||||||
|
get_tx().add_outputs([channel_txo])
|
||||||
|
return channel_txo
|
||||||
|
|
||||||
|
|
||||||
|
def get_stream(claim_name='foo'):
|
||||||
|
stream_txo = Output.pay_claim_name_pubkey_hash(CENT, claim_name, Claim(), b'abc')
|
||||||
|
get_tx().add_outputs([stream_txo])
|
||||||
|
return stream_txo
|
||||||
|
|
||||||
|
|
||||||
class TestSigningAndValidatingClaim(AsyncioTestCase):
|
class TestSigningAndValidatingClaim(AsyncioTestCase):
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_channel():
|
|
||||||
channel_txo = Output.pay_claim_name_pubkey_hash(CENT, '@foo', Claim(), b'abc')
|
|
||||||
channel_txo.generate_channel_private_key()
|
|
||||||
get_tx().add_outputs([channel_txo])
|
|
||||||
return channel_txo
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_stream():
|
|
||||||
stream_txo = Output.pay_claim_name_pubkey_hash(CENT, 'foo', Claim(), b'abc')
|
|
||||||
get_tx().add_outputs([stream_txo])
|
|
||||||
return stream_txo
|
|
||||||
|
|
||||||
def test_successful_create_sign_and_validate(self):
|
def test_successful_create_sign_and_validate(self):
|
||||||
channel = self.get_channel()
|
channel = get_channel()
|
||||||
stream = self.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):
|
def test_fail_to_validate_on_wrong_channel(self):
|
||||||
stream = self.get_stream()
|
stream = get_stream()
|
||||||
stream.sign(self.get_channel())
|
stream.sign(get_channel())
|
||||||
self.assertFalse(stream.is_signed_by(self.get_channel()))
|
self.assertFalse(stream.is_signed_by(get_channel()))
|
||||||
|
|
||||||
def test_fail_to_validate_altered_claim(self):
|
def test_fail_to_validate_altered_claim(self):
|
||||||
channel = self.get_channel()
|
channel = get_channel()
|
||||||
stream = self.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):
|
def test_valid_private_key_for_cert(self):
|
||||||
channel = self.get_channel()
|
channel = 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):
|
def test_fail_to_load_wrong_private_key_for_cert(self):
|
||||||
channel = self.get_channel()
|
channel = get_channel()
|
||||||
self.assertFalse(channel.is_channel_private_key(self.get_channel().private_key))
|
self.assertFalse(channel.is_channel_private_key(get_channel().private_key))
|
||||||
|
|
||||||
|
|
||||||
class TestValidatingOldSignatures(AsyncioTestCase):
|
class TestValidatingOldSignatures(AsyncioTestCase):
|
||||||
|
|
Loading…
Reference in a new issue