Exemplo n.º 1
0
    def test_from_stream(self):
        ae = self.assertEqual

        data = bytearray()
        data.extend(bytes([x for x in range(16)]))  # volume
        data.extend(bytes([x for x in range(15, -1, -1)]))  # object
        stream = ByteIStream(data)

        droid1 = DomainRelativeObjId.from_stream(stream)
        droid2 = DomainRelativeObjId.from_stream(stream, 0)

        ae(droid1.volume, UUID(bytes_le=data[:16]))
        ae(droid2.volume, UUID(bytes_le=data[:16]))

        ae(droid1.object, UUID(bytes_le=data[16:]))
        ae(droid2.object, UUID(bytes_le=data[16:]))
Exemplo n.º 2
0
    def test_from_stream(self):
        ae = self.assertEqual

        data = bytearray()
        data.extend(bytes([x for x in range(16)]))  # volume
        data.extend(bytes([x for x in range(15, -1, -1)]))  # object
        stream = ByteIStream(data)

        droid1 = DomainRelativeObjId.from_stream(stream)
        droid2 = DomainRelativeObjId.from_stream(stream, 0)

        ae(droid1.volume, UUID(bytes_le=data[:16]))
        ae(droid2.volume, UUID(bytes_le=data[:16]))

        ae(droid1.object, UUID(bytes_le=data[16:]))
        ae(droid2.object, UUID(bytes_le=data[16:]))
Exemplo n.º 3
0
    def test_from_stream(self):
        ae = self.assertEqual

        data = bytearray()
        data.extend(b"\x00\x01\x02\x03")  # block size
        data.extend(b"\x04\x05\x06\x07")  # block sig
        data.extend(b"\x50\x00\x00\x00")  # length
        data.extend(b"\x0B\x0A\x09\x08")  # version
        data.extend(b"abcdefgh")  # machine_id
        data.extend(bytes([x for x in range(32)]))
        data.extend(bytes([x for x in range(31, -1, -1)]))
        stream = ByteIStream(data)

        tp1 = TrackerProps.from_stream(stream)
        tp2 = TrackerProps.from_stream(stream, 0)

        ae(tp1.size, 0x03020100)
        ae(tp2.size, 0x03020100)

        ae(tp1.sig, 0x07060504)
        ae(tp2.sig, 0x07060504)

        ae(tp1.length, 0x50)
        ae(tp2.length, 0x50)

        ae(tp1.machine_id, b"abcdefgh")
        ae(tp2.machine_id, b"abcdefgh")

        droid_stream = ByteIStream(data[24:56])
        droid = DomainRelativeObjId.from_stream(droid_stream)
        ae(tp1.droid, droid)
        ae(tp2.droid, droid)

        droid_stream = ByteIStream(data[56:])
        droid = DomainRelativeObjId.from_stream(droid_stream)
        ae(tp1.droid_birth, droid)
        ae(tp2.droid_birth, droid)
Exemplo n.º 4
0
    def test_from_stream(self):
        ae = self.assertEqual

        data = bytearray()
        data.extend(b"\x00\x01\x02\x03")  # block size
        data.extend(b"\x04\x05\x06\x07")  # block sig
        data.extend(b"\x50\x00\x00\x00")  # length
        data.extend(b"\x0B\x0A\x09\x08")  # version
        data.extend(b"abcdefgh")  # machine_id
        data.extend(bytes([x for x in range(32)]))
        data.extend(bytes([x for x in range(31, -1, -1)]))
        stream = ByteIStream(data)

        tp1 = TrackerProps.from_stream(stream)
        tp2 = TrackerProps.from_stream(stream, 0)

        ae(tp1.size, 0x03020100)
        ae(tp2.size, 0x03020100)

        ae(tp1.sig, 0x07060504)
        ae(tp2.sig, 0x07060504)

        ae(tp1.length, 0x50)
        ae(tp2.length, 0x50)

        ae(tp1.machine_id, b"abcdefgh")
        ae(tp2.machine_id, b"abcdefgh")

        droid_stream = ByteIStream(data[24:56])
        droid = DomainRelativeObjId.from_stream(droid_stream)
        ae(tp1.droid, droid)
        ae(tp2.droid, droid)

        droid_stream = ByteIStream(data[56:])
        droid = DomainRelativeObjId.from_stream(droid_stream)
        ae(tp1.droid_birth, droid)
        ae(tp2.droid_birth, droid)