Skip to content

Commit 9b114d1

Browse files
committed
fix handler tests
1 parent 27c3ace commit 9b114d1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

consensus/src/marshal/ingress/handler.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,31 @@ mod tests {
314314
assert_eq!(decoded, Request::Block(commitment));
315315
}
316316

317+
#[test]
318+
fn test_subject_coding_commitment_encoding() {
319+
let digest = Sha256::hash(b"test");
320+
let request = Request::<B>::CodingCommitment { digest, height: 1 };
321+
322+
// Test encoding
323+
let encoded = request.encode();
324+
assert_eq!(encoded.len(), 41); // 1 byte for enum variant + 32 bytes for digest + 8 bytes for height
325+
assert_eq!(encoded[0], 1);
326+
327+
// Test decoding
328+
let mut buf = encoded.as_ref();
329+
let decoded = Request::<B>::read(&mut buf).unwrap();
330+
assert_eq!(request, decoded);
331+
assert_eq!(decoded, Request::CodingCommitment { digest, height: 1 });
332+
}
333+
317334
#[test]
318335
fn test_subject_finalized_encoding() {
319336
let height = 12345u64;
320337
let request = Request::<B>::Finalized { height };
321338

322339
// Test encoding
323340
let encoded = request.encode();
324-
assert_eq!(encoded[0], 1); // Finalized variant
341+
assert_eq!(encoded[0], 2); // Finalized variant
325342

326343
// Test decoding
327344
let mut buf = encoded.as_ref();
@@ -337,7 +354,7 @@ mod tests {
337354

338355
// Test encoding
339356
let encoded = request.encode();
340-
assert_eq!(encoded[0], 2); // Notarized variant
357+
assert_eq!(encoded[0], 3); // Notarized variant
341358

342359
// Test decoding
343360
let mut buf = encoded.as_ref();

0 commit comments

Comments
 (0)