2020-05-01 15:28:51 +02:00
|
|
|
from unittest import TestCase
|
2018-07-15 04:38:18 +02:00
|
|
|
|
2020-05-01 15:28:51 +02:00
|
|
|
from lbry.blockchain.bcd_data_stream import BCDataStream
|
2018-07-15 04:38:18 +02:00
|
|
|
|
|
|
|
|
2020-05-01 15:28:51 +02:00
|
|
|
class TestBCDataStream(TestCase):
|
2018-07-15 04:38:18 +02:00
|
|
|
|
|
|
|
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))
|
2019-10-02 18:58:51 +02:00
|
|
|
self.assertTrue(s.read_boolean())
|
|
|
|
self.assertFalse(s.read_boolean())
|