Skip to content

Commit

Permalink
Merge #4500
Browse files Browse the repository at this point in the history
4500: Update all protocol tests r=AurelienFT a=AurelienFT

While updating the tests I spot problems that I have fixed in this PR : 

- Multiple tests couldn't be launched at the same time because of the logs registry that was instantiates too much time
- Remove the gauge registry to protocol that was failing because all tests was runs in the same time
- Add an opti in block retrieval to exit early if nothing to do.
- Improve the utils available in the test universe
- Fix all the errors logs output


Co-authored-by: AurelienFT <[email protected]>
  • Loading branch information
bors[bot] and AurelienFT authored Oct 30, 2023
2 parents 7847535 + bf1fb88 commit 5fb0d6b
Show file tree
Hide file tree
Showing 22 changed files with 2,308 additions and 3,116 deletions.
34 changes: 31 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions massa-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "massa_channel"
version = "0.26.1"
edition = "2021"

[features]
test-exports = []

[dependencies]
prometheus = {workspace = true}
crossbeam = {workspace = true} # BOM UPGRADE Revert to "0.8.0" if problem
Expand Down
16 changes: 10 additions & 6 deletions massa-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::sync::Arc;

use receiver::MassaReceiver;
use sender::MassaSender;
use tracing::debug;

pub mod receiver;
pub mod sender;
Expand Down Expand Up @@ -54,12 +53,17 @@ impl MassaChannel {

// Register metrics in prometheus
// error here if metrics already registered (ex : ProtocolController>::get_stats )
if let Err(e) = prometheus::register(Box::new(actual_len.clone())) {
debug!("Failed to register actual_len gauge for {} : {}", name, e);
}

if let Err(e) = prometheus::register(Box::new(received.clone())) {
debug!("Failed to register received counter for {} : {}", name, e);
#[cfg(not(feature = "test-exports"))]
{
use tracing::debug;
if let Err(e) = prometheus::register(Box::new(actual_len.clone())) {
debug!("Failed to register actual_len gauge for {} : {}", name, e);
}

if let Err(e) = prometheus::register(Box::new(received.clone())) {
debug!("Failed to register received counter for {} : {}", name, e);
}
}

let sender = MassaSender {
Expand Down
3 changes: 0 additions & 3 deletions massa-models/src/block_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ impl BlockHeader {
// assert that the endorsement indexes are all unique...
let mut set = HashSet::new();
for endo in self.endorsements.iter() {
// ...and check signatures + invariants while at it
endo.check_invariants()?;

if !set.insert(endo.content.index) {
return Err("Endorsement duplicate index found".into());
}
Expand Down
4 changes: 2 additions & 2 deletions massa-node/src/survey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl MassaSurvey {
config: (u8, MassaTime, MassaTime, u64, u64),
) -> MassaSurveyStopper {
if massa_metrics.is_enabled() {
#[cfg(not(feature = "sandbox"))]
#[cfg(all(not(feature = "sandbox"), not(test)))]
{
let mut data_sent = 0;
let mut data_received = 0;
Expand Down Expand Up @@ -141,7 +141,7 @@ impl MassaSurvey {
}
}

#[cfg(feature = "sandbox")]
#[cfg(any(feature = "sandbox", test))]
{
MassaSurveyStopper {
handle: None,
Expand Down
2 changes: 1 addition & 1 deletion massa-protocol-exports/src/test_exports/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Default for ProtocolConfig {
.expect("cannot create temp file")
.path()
.to_path_buf(),
ask_block_timeout: MassaTime::from_millis(500),
ask_block_timeout: MassaTime::from_millis(10000),
max_blocks_kept_for_propagation: 300,
max_block_propagation_time: MassaTime::from_millis(40000),
block_propagation_tick: MassaTime::from_millis(1000),
Expand Down
1 change: 1 addition & 0 deletions massa-protocol-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ massa_test_framework = {workspace = true}
mockall = {workspace = true}
mockall_wrap = {workspace = true}
num = {workspace = true}
massa_channel = {workspace = true, features = ["test-exports"]}
peernet = {workspace = true, features = ["testing"]}
12 changes: 6 additions & 6 deletions massa-protocol-worker/src/connectivity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,17 @@ pub(crate) fn start_connectivity_thread(
protocol_channels.connectivity_thread.1.update_metrics();
match msg {
Ok(ConnectivityCommand::Stop) => {
println!("Stopping protocol");
debug!("Stopping protocol");
drop(network_controller);
println!("Stopped network controller");
debug!("Stopped network controller");
operation_handler.stop();
println!("Stopped operation handler");
debug!("Stopped operation handler");
endorsement_handler.stop();
println!("Stopped endorsement handler");
debug!("Stopped endorsement handler");
block_handler.stop();
println!("Stopped block handler");
debug!("Stopped block handler");
peer_management_handler.stop();
println!("Stopped peer handler");
debug!("Stopped peer handler");
break;
},
Ok(ConnectivityCommand::GetStats { responder }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,11 @@ impl RetrievalThread {
.ok_or(TimeError::TimeOverflowError)
.expect("could not compute next block retrieval timer tick");

// Get conencted peer list
if self.asked_blocks.is_empty() && self.block_wishlist.is_empty() {
return;
}

// Get connected peer list
let connected_peers = self.active_connections.get_peer_ids_connected();

// Update cache
Expand Down
Loading

0 comments on commit 5fb0d6b

Please sign in to comment.