diff --git a/nodes/mockpool-node/src/tx.rs b/nodes/mockpool-node/src/tx.rs index 664c5106..887776d0 100644 --- a/nodes/mockpool-node/src/tx.rs +++ b/nodes/mockpool-node/src/tx.rs @@ -1,4 +1,4 @@ -use blake2::{Blake2b512, Digest}; +use blake2::{Blake2s256, Digest}; use serde::{Deserialize, Serialize}; use std::hash::Hash; @@ -10,10 +10,28 @@ pub struct TxId([u8; 32]); impl From<&Tx> for TxId { fn from(tx: &Tx) -> Self { - let mut hasher = Blake2b512::new(); + let mut hasher = Blake2s256::new(); hasher.update(bincode::serde::encode_to_vec(tx, bincode::config::standard()).unwrap()); let mut id = [0u8; 32]; id.copy_from_slice(hasher.finalize().as_slice()); Self(id) } } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_txid() { + let tx = Tx("test".to_string()); + let txid = TxId::from(&tx); + assert_eq!( + txid.0, + [ + 26, 113, 217, 35, 178, 18, 65, 215, 30, 117, 195, 9, 189, 146, 124, 78, 66, 91, 97, + 21, 254, 51, 156, 155, 144, 52, 135, 125, 51, 128, 186, 244 + ] + ); + } +} diff --git a/nomos-services/http/src/http.rs b/nomos-services/http/src/http.rs index 1a44364c..f2619350 100644 --- a/nomos-services/http/src/http.rs +++ b/nomos-services/http/src/http.rs @@ -5,9 +5,8 @@ use std::{ fmt::{self, Debug}, sync::Arc, }; - -use bytes::Bytes; // crates +use bytes::Bytes; use overwatch_rs::services::{ handle::ServiceStateHandle, relay::{InboundRelay, OutboundRelay, RelayMessage},