예제 #1
0
    def test_set_application_parameters(self):
        interest = Interest("/ndn")
        self.assertTrue(not interest.hasApplicationParameters())
        applicationParameters = Blob(bytearray([ 0x23, 0x00 ]))
        interest.setApplicationParameters(applicationParameters)
        self.assertTrue(interest.hasApplicationParameters())
        self.assertTrue(interest.getApplicationParameters().equals
                        (applicationParameters))

        decodedInterest = Interest()
        decodedInterest.wireDecode(interest.wireEncode())
        self.assertTrue(decodedInterest.getApplicationParameters().equals
                        (applicationParameters))

        interest.setApplicationParameters(Blob())
        self.assertTrue(not interest.hasApplicationParameters())
예제 #2
0
    def test_append_parameters_digest(self):
        name = Name("/local/ndn/prefix")
        interest = Interest(name)

        self.assertTrue(not interest.hasApplicationParameters())
        # No parameters yet, so it should do nothing.
        interest.appendParametersDigestToName()
        self.assertEqual("/local/ndn/prefix", interest.getName().toUri())

        applicationParameters = Blob(bytearray([ 0x23, 0x01, 0xC0 ]))
        interest.setApplicationParameters(applicationParameters)
        self.assertTrue(interest.hasApplicationParameters())
        interest.appendParametersDigestToName()
        self.assertEqual(name.size() + 1, interest.getName().size())
        self.assertTrue(interest.getName().getPrefix(-1).equals(name))
        SHA256_LENGTH = 32
        self.assertEqual(SHA256_LENGTH, interest.getName().get(-1).getValue().size())
        
        self.assertEqual(interest.getName().toUri(), "/local/ndn/prefix/" +
          "params-sha256=a16cc669b4c9ef6801e1569488513f9523ffb28a39e53aa6e11add8d00a413fc")