Skip to content

Commit acf7e52

Browse files
committed
feat: extend ProtocolMessagePartKey with CardanoDatabaseMerkleRoot
1 parent e2e2b0e commit acf7e52

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mithril-common/src/entities/protocol_message.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ pub enum ProtocolMessagePartKey {
4646
/// The ProtocolMessage part key associated to the Cardano stake distribution Merkle root
4747
#[serde(rename = "cardano_stake_distribution_merkle_root")]
4848
CardanoStakeDistributionMerkleRoot,
49+
50+
/// The ProtocolMessage part key associated to the Cardano database Merkle root
51+
#[serde(rename = "cardano_database_merkle_root")]
52+
CardanoDatabaseMerkleRoot,
4953
}
5054

5155
impl Display for ProtocolMessagePartKey {
@@ -61,6 +65,7 @@ impl Display for ProtocolMessagePartKey {
6165
Self::CardanoStakeDistributionMerkleRoot => {
6266
write!(f, "cardano_stake_distribution_merkle_root")
6367
}
68+
Self::CardanoDatabaseMerkleRoot => write!(f, "cardano_database_merkle_root"),
6469
}
6570
}
6671
}
@@ -207,6 +212,20 @@ mod tests {
207212
assert_ne!(hash_expected, protocol_message_modified.compute_hash());
208213
}
209214

215+
#[test]
216+
fn test_protocol_message_compute_hash_include_cardano_database_merkle_root() {
217+
let protocol_message = build_protocol_message_reference();
218+
let hash_expected = protocol_message.compute_hash();
219+
220+
let mut protocol_message_modified = protocol_message.clone();
221+
protocol_message_modified.set_message_part(
222+
ProtocolMessagePartKey::CardanoDatabaseMerkleRoot,
223+
"cardano-database-merkle-root-456".to_string(),
224+
);
225+
226+
assert_ne!(hash_expected, protocol_message_modified.compute_hash());
227+
}
228+
210229
#[test]
211230
fn test_protocol_message_compute_hash_include_next_protocol_parameters() {
212231
let protocol_message = build_protocol_message_reference();
@@ -259,6 +278,10 @@ mod tests {
259278
ProtocolMessagePartKey::CardanoStakeDistributionMerkleRoot,
260279
"cardano-stake-distribution-merkle-root-123".to_string(),
261280
);
281+
protocol_message.set_message_part(
282+
ProtocolMessagePartKey::CardanoDatabaseMerkleRoot,
283+
"cardano-database-merkle-root-123".to_string(),
284+
);
262285

263286
protocol_message
264287
}

0 commit comments

Comments
 (0)