Ejemplo n.º 1
0
    def test_default():
        name = Name.from_str('/local/ndn/prefix')
        data = make_data(name, MetaInfo(), signer=DigestSha256Signer())
        assert (data ==
                b"\x06\x42\x07\x14\x08\x05local\x08\x03ndn\x08\x06prefix"
                b"\x14\x03\x18\x01\x00"
                b"\x16\x03\x1b\x01\x00"
                b"\x17 \x7f1\xe4\t\xc5z/\x1d\r\xdaVh8\xfd\xd9\x94"
                b"\xd8\'S\x13[\xd7\x15\xa5\x9d%^\x80\xf2\xab\xf0\xb5")

        name = Name.encode(name)
        data = make_data(name, MetaInfo(), b'01020304', signer=DigestSha256Signer())
        assert (data ==
                b'\x06L\x07\x14\x08\x05local\x08\x03ndn\x08\x06prefix'
                b'\x14\x03\x18\x01\x00'
                b'\x15\x0801020304'
                b'\x16\x03\x1b\x01\x00'
                b'\x17 \x94\xe9\xda\x91\x1a\x11\xfft\x02i:G\x0cO\xdd!'
                b'\xe0\xc7\xb6\xfd\x8f\x9cn\xc5\x93{\x93\x04\xe0\xdf\xa6S')

        name = '/local/ndn/prefix'
        meta_info = MetaInfo()
        data = make_data(name, meta_info)
        assert (data ==
                b"\x06\x1b\x07\x14\x08\x05local\x08\x03ndn\x08\x06prefix"
                b"\x14\x03\x18\x01\x00")

        name = '/E'
        meta_info = MetaInfo()
        meta_info.content_type = None
        data = make_data(name, meta_info, b'', signer=DigestSha256Signer())
        assert data == bytes.fromhex("0630 0703080145"
                                     "1400 1500 16031b0100"
                                     "1720f965ee682c6973c3cbaa7b69e4c7063680f83be93a46be2ccc98686134354b66")
Ejemplo n.º 2
0
 def test_meta_info():
     name = '/local/ndn/prefix/37=%00'
     meta_info = MetaInfo()
     meta_info.content_type = ContentType.BLOB
     meta_info.freshness_period = 1000
     meta_info.final_block_id = Component.from_sequence_num(2)
     data = make_data(name, meta_info, signer=DigestSha256Signer())
     assert (data ==
             b"\x06\x4e\x07\x17\x08\x05local\x08\x03ndn\x08\x06prefix\x25\x01\x00"
             b"\x14\x0c\x18\x01\x00\x19\x02\x03\xe8\x1a\x03\x25\x01\x02"
             b"\x16\x03\x1b\x01\x00"
             b"\x17 \x03\xb8,\x18\xffMw\x84\x86\xa5a\x94e\xcc\xdaQ\x15\xb7\xfb\x19\xab\x9d1lw\'\xdf\xac\x03#\xcad")
Ejemplo n.º 3
0
 def test_meta_info():
     name = '/local/ndn/prefix/37=%00'
     meta_info = MetaInfo()
     meta_info.content_type = ContentType.BLOB
     meta_info.freshness_period = 1000
     meta_info.final_block_id = Component.from_sequence_num(2)
     data = make_data(name, meta_info, signer=DigestSha256Signer())
     assert (
         data ==
         b"\x06\x4e\x07\x17\x08\x05local\x08\x03ndn\x08\x06prefix\x25\x01\x00"
         b"\x14\x0c\x18\x01\x00\x19\x02\x03\xe8\x1a\x03\x3a\x01\x02"
         b"\x16\x03\x1b\x01\x00"
         b"\x17 \x0f^\xa1\x0c\xa7\xf5Fb\xf0\x9cOT\xe0FeC\x8f92\x04\x9d\xabP\x80o\'\x94\xaa={hQ"
     )