Skip to content

Commit dce26fd

Browse files
committed
Fixed tests
1 parent 4f5829b commit dce26fd

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

extras/test/src/test_command_decode.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ SCENARIO("Test the decoding of command messages") {
123123
REQUIRE(genericMessage->id == (uint32_t)67072);
124124
}
125125

126-
delete msg->fields.params.last_values;
126+
free(msg->fields.params.last_values);
127127
delete msg;
128128
}
129129

@@ -160,6 +160,24 @@ SCENARIO("Test the decoding of command messages") {
160160
REQUIRE(err == MessageDecoder::DecoderState::Success);
161161
REQUIRE(strcmp(msg->fields.params.id, otaIdToMatch) == 0);
162162
REQUIRE(strcmp(msg->fields.params.url, urlToMatch) == 0);
163+
// Initial SHA256 check
164+
REQUIRE(msg->fields.params.initialSha256[0] == (uint8_t)0x33);
165+
REQUIRE(msg->fields.params.initialSha256[1] == (uint8_t)0x30);
166+
REQUIRE(msg->fields.params.initialSha256[2] == (uint8_t)0x30);
167+
REQUIRE(msg->fields.params.initialSha256[3] == (uint8_t)0x34);
168+
REQUIRE(msg->fields.params.initialSha256[4] == (uint8_t)0x61);
169+
REQUIRE(msg->fields.params.initialSha256[5] == (uint8_t)0x61);
170+
REQUIRE(msg->fields.params.initialSha256[6] == (uint8_t)0x62);
171+
REQUIRE(msg->fields.params.initialSha256[7] == (uint8_t)0x32);
172+
173+
// Final SHA256 check
174+
REQUIRE(msg->fields.params.finalSha256[0] == (uint8_t)0x6A);
175+
REQUIRE(msg->fields.params.finalSha256[1] == (uint8_t)0x6B);
176+
REQUIRE(msg->fields.params.finalSha256[2] == (uint8_t)0x61);
177+
REQUIRE(msg->fields.params.finalSha256[3] == (uint8_t)0x73);
178+
REQUIRE(msg->fields.params.finalSha256[4] == (uint8_t)0x64);
179+
REQUIRE(msg->fields.params.finalSha256[5] == (uint8_t)0x6B);
180+
163181
REQUIRE(genericMessage->id == (uint32_t)65792);
164182
}
165183

src/cbor/MessageDecoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ bool copyCBORByteToArray(CborValue * param, uint8_t * dest, size_t dest_size) {
9999
if (val_size > dest_size) {
100100
val_size = dest_size;
101101
}
102-
std::copy(val, val + dest_size, dest);
102+
std::copy(val, val + val_size, dest);
103103
free(val);
104104
return true;
105105
}

0 commit comments

Comments
 (0)