lbry-sdk/tests/client_tests/unit/test_bcd_data_stream.py

24 lines
742 B
Python
Raw Normal View History

2018-10-15 04:16:51 +02:00
import unittest
2018-07-15 04:38:18 +02:00
2018-11-04 06:55:50 +01:00
from torba.client.bcd_data_stream import BCDataStream
2018-07-15 04:38:18 +02:00
class TestBCDataStream(unittest.TestCase):
def test_write_read(self):
s = BCDataStream()
s.write_string(b'a'*252)
s.write_string(b'b'*254)
s.write_string(b'c'*(0xFFFF + 1))
# s.write_string(b'd'*(0xFFFFFFFF + 1))
s.write_boolean(True)
s.write_boolean(False)
s.reset()
self.assertEqual(s.read_string(), b'a'*252)
self.assertEqual(s.read_string(), b'b'*254)
self.assertEqual(s.read_string(), b'c'*(0xFFFF + 1))
# self.assertEqual(s.read_string(), b'd'*(0xFFFFFFFF + 1))
self.assertEqual(s.read_boolean(), True)
self.assertEqual(s.read_boolean(), False)