LONGBOW_TEST_CASE(Global, ccnxInterest_Equals) { CCNxName *nameA = ccnxName_CreateFromURI("lci:/name"); PARCBuffer *keyA = parcBuffer_Allocate(8); parcBuffer_PutUint64(keyA, 1234L); CCNxInterest *interestA = ccnxInterest_Create(nameA, 1000, /* lifetime */ keyA, /* KeyId */ NULL /* ContentObjectHash */ ); CCNxName *nameB = ccnxName_CreateFromURI("lci:/name"); PARCBuffer *keyB = parcBuffer_Allocate(8); parcBuffer_PutUint64(keyB, 1234L); CCNxInterest *interestB = ccnxInterest_Create(nameB, 1000, /* lifetime */ keyB, /* KeyId */ NULL /* ContentObjectHash */ ); assertTrue(ccnxInterest_Equals(interestA, interestB), "Expected equivalent interests to be equal."); ccnxName_Release(&nameA); ccnxName_Release(&nameB); parcBuffer_Release(&keyA); parcBuffer_Release(&keyB); ccnxInterest_Release(&interestA); ccnxInterest_Release(&interestB); }
LONGBOW_TEST_CASE(Global, ccnxPortal_Receive_ImmediateTimeout) { TestData *data = longBowTestCase_GetClipBoardData(testCase); CCNxPortal *portalOut = ccnxPortalFactory_CreatePortal(data->factory, TEST_STACK); CCNxPortal *portalIn = ccnxPortalFactory_CreatePortal(data->factory, TEST_STACK); CCNxName *name = ccnxName_CreateFromCString("lci:/Hello/World"); CCNxInterest *interest = ccnxInterest_CreateSimple(name); ccnxName_Release(&name); CCNxMetaMessage *interestMessage = ccnxMetaMessage_CreateFromInterest(interest); if (ccnxPortal_Send(portalOut, interestMessage, CCNxStackTimeout_Never)) { sleep(2); ccnxMetaMessage_Release(&interestMessage); CCNxMetaMessage *message = ccnxPortal_Receive(portalIn, CCNxStackTimeout_Immediate); assertTrue(ccnxInterest_Equals(interest, ccnxMetaMessage_GetInterest(message)), "Expected Interest to be received."); ccnxMetaMessage_Release(&message); } ccnxInterest_Release(&interest); ccnxPortal_Release(&portalIn); ccnxPortal_Release(&portalOut); }
LONGBOW_TEST_CASE(Global, ccnxInterest_Equals_Same) { CCNxName *nameA = ccnxName_CreateFromURI("lci:/name"); PARCBuffer *key = parcBuffer_Allocate(8); parcBuffer_PutUint64(key, 1234L); CCNxInterest *interestA = ccnxInterest_Create(nameA, CCNxInterestDefault_LifetimeMilliseconds, /* lifetime */ key, /* KeyId */ NULL /* ContentObjectHash */ ); assertTrue(ccnxInterest_Equals(interestA, interestA), "Expected the same interest to be equal."); assertFalse(ccnxInterest_Equals(interestA, NULL), "Did not expect NULL to equal an Interest"); ccnxName_Release(&nameA); parcBuffer_Release(&key); ccnxInterest_Release(&interestA); }
LONGBOW_TEST_CASE(Global, ccnxMetaMessage_GetInterest) { CCNxName *name = ccnxName_CreateFromCString("lci:/foo/bar"); CCNxInterest *interest = ccnxInterest_CreateSimple(name); CCNxMetaMessage *portalMessage = ccnxMetaMessage_CreateFromInterest(interest); CCNxInterest *reference = ccnxMetaMessage_GetInterest(portalMessage); assertTrue(ccnxInterest_Equals(interest, reference), "Expected reference to equal original interest"); ccnxInterest_AssertValid(reference); ccnxInterest_Release(&reference); ccnxMetaMessage_Release(&portalMessage); ccnxName_Release(&name); }
LONGBOW_TEST_CASE(Global, ccnxMetaMessage_EncodeDecode) { CCNxName *name = ccnxName_CreateFromCString("lci:/foo/bar"); CCNxInterest *interest = ccnxInterest_CreateSimple(name); ccnxName_Release(&name); PARCSigner *signer = ccnxValidationCRC32C_CreateSigner(); // Would really be SHA256 or something. // Encode it to wire format. PARCBuffer *wireFormatBuffer = ccnxMetaMessage_CreateWireFormatBuffer(interest, signer); // Now decode it from wireformat. CCNxMetaMessage *decodedMessage = ccnxMetaMessage_CreateFromWireFormatBuffer(wireFormatBuffer); // At this point, the unpacked dictionary should be equivalent to the original interest. assertTrue(ccnxInterest_Equals(interest, decodedMessage), "Expected an equivalent interest to be unpacked"); parcBuffer_Release(&wireFormatBuffer); ccnxInterest_Release(&interest); ccnxMetaMessage_Release(&decodedMessage); parcSigner_Release(&signer); }