From de4cddf40c32fb49d36f8201a8571ab514722ec2 Mon Sep 17 00:00:00 2001
From: Guy Nir <guy.n@starkware.co>
Date: Sun, 8 Dec 2024 14:56:25 +0200
Subject: [PATCH] chore(sequencing): remove ConsensusMessage from converter
 test

---
 crates/papyrus_protobuf/src/consensus.rs               |  1 +
 crates/papyrus_protobuf/src/converters/consensus.rs    |  1 +
 .../papyrus_protobuf/src/converters/consensus_test.rs  | 10 +++++-----
 .../papyrus_protobuf/src/converters/test_instances.rs  |  7 +++++--
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/crates/papyrus_protobuf/src/consensus.rs b/crates/papyrus_protobuf/src/consensus.rs
index 2a092e6fed4..dbcfcc17356 100644
--- a/crates/papyrus_protobuf/src/consensus.rs
+++ b/crates/papyrus_protobuf/src/consensus.rs
@@ -31,6 +31,7 @@ pub struct Vote {
     pub voter: ContractAddress,
 }
 
+// TODO: remove this once we are sure everything works using just Vote.
 #[derive(Debug, Clone, Hash, Eq, PartialEq)]
 pub enum ConsensusMessage {
     Proposal(Proposal), // To be deprecated
diff --git a/crates/papyrus_protobuf/src/converters/consensus.rs b/crates/papyrus_protobuf/src/converters/consensus.rs
index 708a9ee3b99..093dd8c153c 100644
--- a/crates/papyrus_protobuf/src/converters/consensus.rs
+++ b/crates/papyrus_protobuf/src/converters/consensus.rs
@@ -24,6 +24,7 @@ use crate::consensus::{
 use crate::converters::ProtobufConversionError;
 use crate::{auto_impl_into_and_try_from_vec_u8, protobuf};
 
+// TODO(guyn): remove this once we integrate ProposalPart everywhere.
 impl TryFrom<protobuf::Proposal> for Proposal {
     type Error = ProtobufConversionError;
 
diff --git a/crates/papyrus_protobuf/src/converters/consensus_test.rs b/crates/papyrus_protobuf/src/converters/consensus_test.rs
index 57e328a7fac..9bb15dd176a 100644
--- a/crates/papyrus_protobuf/src/converters/consensus_test.rs
+++ b/crates/papyrus_protobuf/src/converters/consensus_test.rs
@@ -12,8 +12,8 @@ use starknet_api::transaction::{
 };
 
 use crate::consensus::{
-    ConsensusMessage,
-    Proposal,
+    ConsensusMessage, // TODO: remove this
+    Proposal,         // TODO: remove this
     ProposalFin,
     ProposalInit,
     ProposalPart,
@@ -51,11 +51,11 @@ fn add_gas_values_to_transaction(transactions: &mut [Transaction]) {
 fn convert_stream_message_to_vec_u8_and_back() {
     let mut rng = get_rng();
 
-    // Test that we can convert a StreamMessage with a ConsensusMessage message to bytes and back.
-    let mut stream_message: StreamMessage<ConsensusMessage> =
+    // Test that we can convert a StreamMessage with a ProposalPart message to bytes and back.
+    let mut stream_message: StreamMessage<ProposalPart> =
         StreamMessage::get_test_instance(&mut rng);
 
-    if let StreamMessageBody::Content(ConsensusMessage::Proposal(proposal)) =
+    if let StreamMessageBody::Content(ProposalPart::Transactions(proposal)) =
         &mut stream_message.message
     {
         add_gas_values_to_transaction(&mut proposal.transactions);
diff --git a/crates/papyrus_protobuf/src/converters/test_instances.rs b/crates/papyrus_protobuf/src/converters/test_instances.rs
index 01c9c1903aa..6f0940b3168 100644
--- a/crates/papyrus_protobuf/src/converters/test_instances.rs
+++ b/crates/papyrus_protobuf/src/converters/test_instances.rs
@@ -64,10 +64,13 @@ auto_impl_get_test_instance! {
 
 // The auto_impl_get_test_instance macro does not work for StreamMessage because it has
 // a generic type. TODO(guyn): try to make the macro work with generic types.
-impl GetTestInstance for StreamMessage<ConsensusMessage> {
+impl GetTestInstance for StreamMessage<ProposalPart> {
     fn get_test_instance(rng: &mut rand_chacha::ChaCha8Rng) -> Self {
         let message = if rng.gen_bool(0.5) {
-            StreamMessageBody::Content(ConsensusMessage::Proposal(Proposal::get_test_instance(rng)))
+            StreamMessageBody::Content(ProposalPart::Transactions(TransactionBatch {
+                transactions: vec![Transaction::get_test_instance(rng)],
+                tx_hashes: vec![TransactionHash::get_test_instance(rng)],
+            }))
         } else {
             StreamMessageBody::Fin
         };