void test_KineticPDU_Init_should_set_the_exchange_fields_in_the_embedded_protobuf_header(void) { LOG_LOCATION; KINETIC_CONNECTION_INIT(&Connection); Connection.sequence = 24; Connection.connectionID = 8765432; Session = (KineticSession) { .clusterVersion = 1122334455667788, .identity = 37, }; Connection.session = Session; KINETIC_PDU_INIT(&PDU, &Connection); TEST_ASSERT_TRUE(PDU.protoData.message.header.has_clusterVersion); TEST_ASSERT_EQUAL_INT64(1122334455667788, PDU.protoData.message.header.clusterVersion); TEST_ASSERT_TRUE(PDU.protoData.message.header.has_identity); TEST_ASSERT_EQUAL_INT64(37, PDU.protoData.message.header.identity); TEST_ASSERT_TRUE(PDU.protoData.message.header.has_connectionID); TEST_ASSERT_EQUAL_INT64(8765432, PDU.protoData.message.header.connectionID); TEST_ASSERT_TRUE(PDU.protoData.message.header.has_sequence); TEST_ASSERT_EQUAL_INT64(24, PDU.protoData.message.header.sequence); } void test_KineticPDU_AttachEntry_should_attach_specified_KineticEntry(void) { LOG_LOCATION; KineticPDU_Init(&PDU, &Connection); uint8_t data[5]; ByteArray value = {.data = data, .len = sizeof(data)}; ByteBuffer valueBuffer = ByteBuffer_CreateWithArray(value); KineticEntry entry = {.value = valueBuffer}; entry.value.bytesUsed = 3; KineticPDU_AttachEntry(&PDU, &entry); TEST_ASSERT_EQUAL_PTR(entry.value.array.data, PDU.entry.value.array.data); TEST_ASSERT_EQUAL(3, PDU.entry.value.bytesUsed); TEST_ASSERT_EQUAL(3, entry.value.bytesUsed); TEST_ASSERT_EQUAL(sizeof(data), entry.value.array.len); } void test_KINETIC_PDU_INIT_WITH_MESSAGE_should_initialize_PDU_and_protobuf_message(void) { LOG_LOCATION; memset(&PDU, 0, sizeof(KineticPDU)); KINETIC_PDU_INIT_WITH_MESSAGE(&PDU, &Connection); PDU.protoData.message.status.code = KINETIC_PROTO_STATUS_STATUS_CODE_SERVICE_BUSY; PDU.protoData.message.command.status = &PDU.protoData.message.status; TEST_ASSERT_EQUAL( KINETIC_PROTO_STATUS_STATUS_CODE_SERVICE_BUSY, PDU.proto->command->status->code); }
void setUp(void) { // Create and configure a new Kinetic protocol instance Key = ByteArray_CreateWithCString("some valid HMAC key..."); Session = (KineticSession) { .nonBlocking = false, .port = 1234, .host = "valid-host.com", .hmacKey = (ByteArray) {.data = &Session.keyData[0], .len = Key.len}, }; memcpy(Session.hmacKey.data, Key.data, Key.len); KINETIC_CONNECTION_INIT(&Connection); Connection.connected = true; Connection.socket = 456; Connection.session = Session; KINETIC_PDU_INIT(&PDU, &Connection); ByteArray_FillWithDummyData(Value); KineticLogger_Init(NULL); }
void KineticPDU_Init(KineticPDU* const pdu, KineticConnection* const connection) { KINETIC_PDU_INIT(pdu, connection); }