From 5fad1ad5f7e76681e6fd22d1a898e3c89a193e82 Mon Sep 17 00:00:00 2001 From: Guy Nir 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 dc34a536eb..6558392654 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 708a9ee3b9..093dd8c153 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 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 422c6a9810..76dd19c0bd 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 = + // Test that we can convert a StreamMessage with a ProposalPart message to bytes and back. + let mut stream_message: StreamMessage = 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 01c9c1903a..6f0940b316 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 { +impl GetTestInstance for StreamMessage { 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 };