Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests all features #4705

Merged
merged 7 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: nextest
args: run --retries 10 --profile ci
args: run --retries 10 --profile ci --all-features
- uses: actions-rs/cargo@v1
with:
command: clean
Expand Down
5 changes: 5 additions & 0 deletions massa-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ use std::sync::{Arc, Condvar, Mutex};
use tower_http::cors::{Any, CorsLayer};
use tracing::{info, warn};

#[cfg(feature = "test-exports")]
use massa_channel as _;
#[cfg(feature = "test-exports")]
use massa_grpc as _;

mod api;
mod api_trait;
mod private;
Expand Down
2 changes: 1 addition & 1 deletion massa-api/src/tests/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async fn get_status() {
assert_eq!(response.network_stats.out_connection_count, 5);
assert_eq!(response.config.thread_count, 32);
// Chain id == 77 for Node in sandbox mode otherwise it is always greater
assert!(response.chain_id > 77);
assert!(response.chain_id >= 77);

api_public_handle.stop().await;
}
Expand Down
6 changes: 4 additions & 2 deletions massa-bootstrap/src/tests/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,8 +1249,10 @@ pub fn parametric_test<F, T>(
F: Fn(&T, &mut SmallRng),
{
#[cfg(feature = "heavy_testing")]
let duration = duration * 120;

let duration = match std::env::var("NEXTEST") {
Ok(s) if s == String::from("1") => duration,
_ => duration * 120,
};
for reg in regressions {
println!("[*] Regression {reg}");
let mut rng = SmallRng::seed_from_u64(reg);
Expand Down
65 changes: 38 additions & 27 deletions massa-execution-worker/src/tests/scenarios_mandatories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,18 @@ fn send_and_receive_async_message() {
let saved_bytecode = Arc::new(RwLock::new(None));
let saved_bytecode_edit = saved_bytecode.clone();
let finalized_waitpoint_trigger_handle = finalized_waitpoint.get_trigger_handle();

let destination = match *CHAINID {
77 => Address::from_str("AS12jc7fTsSKwQ9hSk97C3iMNgNT1XrrD6MjSJRJZ4NE53YgQ4kFV").unwrap(),
77658366 => {
Address::from_str("AS12DSPbsNvvdP1ScCivmKpbQfcJJ3tCQFkNb8ewkRuNjsgoL2AeQ").unwrap()
}
77658377 => {
Address::from_str("AS127QtY6Hzm6BnJc9wqCBfPNvEH9fKer3LiMNNQmcX3MzLwCL6G6").unwrap()
}
_ => panic!("CHAINID not supported"),
};

// Expected message from SC: send_message.ts (see massa unit tests src repo)
let message = AsyncMessage {
emission_slot: Slot {
Expand All @@ -616,8 +628,7 @@ fn send_and_receive_async_message() {
sender: Address::from_str("AU1TyzwHarZMQSVJgxku8co7xjrRLnH74nFbNpoqNd98YhJkWgi").unwrap(),
// Note: generated address (from send_message.ts createSC call)
// this can changes when modification to the final state are done (see create_new_sc_address function)
destination: Address::from_str("AS127QtY6Hzm6BnJc9wqCBfPNvEH9fKer3LiMNNQmcX3MzLwCL6G6")
.unwrap(),
destination,
function: String::from("receive"),
// value from SC: send_message.ts
max_gas: 3000000,
Expand Down Expand Up @@ -668,15 +679,7 @@ fn send_and_receive_async_message() {
.times(1)
.with(predicate::eq(Slot::new(1, 1)), predicate::always())
.returning(move |_, changes| {
match changes
.ledger_changes
.0
.get(
&Address::from_str("AS127QtY6Hzm6BnJc9wqCBfPNvEH9fKer3LiMNNQmcX3MzLwCL6G6")
.unwrap(),
)
.unwrap()
{
match changes.ledger_changes.0.get(&destination).unwrap() {
// sc has received the coins (0.0000001)
SetUpdateOrDelete::Update(change_sc_update) => {
assert_eq!(
Expand Down Expand Up @@ -2664,16 +2667,15 @@ fn execution_trace() {
finalized_waitpoint.wait();

let mut receiver = universe.broadcast_traces_channel_receiver.take().unwrap();
let join_handle = thread::spawn(move || {
let exec_traces = receiver.blocking_recv();
/*
let exec_traces_2 = receiver.blocking_recv();
return vec![
exec_traces.expect("Execution output"),
exec_traces_2.expect("Final execution output"),
];
*/
return exec_traces;
let join_handle = thread::spawn(move || loop {
if let Ok(exec_traces) = receiver.blocking_recv() {
if exec_traces.1 == true {
return Ok::<
(massa_execution_exports::SlotAbiCallStack, bool),
tokio::sync::broadcast::error::RecvError,
>(exec_traces);
}
}
});
let broadcast_result_ = join_handle.join().expect("Nothing received from thread");
let (broadcast_result, _) = broadcast_result_.unwrap();
Expand Down Expand Up @@ -2784,8 +2786,16 @@ fn execution_trace_nested() {
let mut receiver = universe.broadcast_traces_channel_receiver.take().unwrap();
let join_handle = thread::spawn(move || {
// Execution Output
let exec_traces = receiver.blocking_recv();
return exec_traces;
loop {
if let Ok(exec_traces) = receiver.blocking_recv() {
if exec_traces.1 == true {
return Ok::<
(massa_execution_exports::SlotAbiCallStack, bool),
tokio::sync::broadcast::error::RecvError,
>(exec_traces);
}
}
}
});
let broadcast_result_ = join_handle.join().expect("Nothing received from thread");

Expand Down Expand Up @@ -2834,7 +2844,7 @@ fn execution_trace_nested() {
SCRuntimeAbiTraceValue {
name: "from_address".to_string(),
value: SCRuntimeAbiTraceType::String(
"AS1Bc3kZ6LhPLJvXV4vcVJLFRExRFbkPWD7rCg9aAdQ1NGzRwgnu".to_string()
"AS1aEhosr1ebJJZ7cEMpSVKbY6xp1p4DdXabGb8fdkKKJ6WphGnR".to_string()
)
},
SCRuntimeAbiTraceValue {
Expand Down Expand Up @@ -2941,12 +2951,13 @@ fn test_dump_block() {
drop(universe);

let block_folder = &exec_cfg.block_dump_folder_path;
#[cfg(feature = "file_storage_backend")]
let storage_backend = crate::storage_backend::FileStorageBackend::new(block_folder.to_owned());
#[cfg(all(feature = "file_storage_backend", not(feature = "db_storage_backend")))]
let storage_backend =
crate::storage_backend::FileStorageBackend::new(block_folder.to_owned(), 10);

#[cfg(feature = "db_storage_backend")]
let storage_backend =
crate::storage_backend::RocksDBStorageBackend::new(block_folder.to_owned());
crate::storage_backend::RocksDBStorageBackend::new(block_folder.to_owned(), 10);

let block_content = storage_backend.read(&block_slot).unwrap();
let filled_block = FilledBlock::decode(&mut Cursor::new(block_content)).unwrap();
Expand Down
31 changes: 22 additions & 9 deletions massa-execution-worker/src/tests/universe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ use std::{
sync::Arc,
};

#[cfg(feature = "file_storage_backend")]
#[cfg(all(feature = "file_storage_backend", not(feature = "db_storage_backend")))]
bilboquet marked this conversation as resolved.
Show resolved Hide resolved
use crate::storage_backend::FileStorageBackend;
#[cfg(feature = "db_storage_backend")]
use crate::storage_backend::RocksDBStorageBackend;
use cfg_if::cfg_if;
use massa_db_exports::{MassaDBConfig, MassaDBController, ShareableMassaDBController};
use massa_db_worker::MassaDB;
use massa_execution_exports::{
Expand Down Expand Up @@ -108,6 +109,23 @@ impl TestUniverse for ExecutionTestUniverse {
#[cfg(feature = "execution-trace")]
slot_execution_traces_sender: tx_traces,
};

cfg_if! {
if #[cfg(all(feature = "dump-block", feature = "db_storage_backend"))] {
let block_storage_backend = Arc::new(RwLock::new(RocksDBStorageBackend::new(
config.block_dump_folder_path.clone(),
10
)));
} else if #[cfg(all(feature = "dump-block", feature = "file_storage_backend"))] {
let block_storage_backend = Arc::new(RwLock::new(FileStorageBackend::new(
config.block_dump_folder_path.clone(),
10
)));
} else if #[cfg(feature = "dump-block")] {
compile_error!("feature dump-block require either db_storage_backend or file_storage_backend");
}
}

let (module_manager, module_controller) = start_execution_worker(
config.clone(),
controllers.final_state.clone(),
Expand All @@ -122,15 +140,10 @@ impl TestUniverse for ExecutionTestUniverse {
std::time::Duration::from_secs(5),
)
.0,
#[cfg(feature = "file_storage_backend")]
Arc::new(RwLock::new(FileStorageBackend::new(
config.block_dump_folder_path.clone(),
))),
#[cfg(feature = "db_storage_backend")]
Arc::new(RwLock::new(RocksDBStorageBackend::new(
config.block_dump_folder_path.clone(),
))),
#[cfg(feature = "dump-block")]
block_storage_backend.clone(),
);

init_execution_worker(&config, &storage, module_controller.clone());
let universe = Self {
storage,
Expand Down
2 changes: 1 addition & 1 deletion massa-grpc/src/tests/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn get_status() {
let status = result.status.unwrap();
assert_eq!(status.version, *VERSION.to_string());
// Chain id == 77 for Node in sandbox mode otherwise it is always greater
assert!(status.chain_id > 77);
assert!(status.chain_id >= 77);

stop_handle.stop();
}
Expand Down
6 changes: 5 additions & 1 deletion massa-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ use massa_execution_exports::{
ExecutionChannels, ExecutionConfig, ExecutionManager, GasCosts, StorageCostsConstants,
};
use massa_execution_worker::start_execution_worker;
#[cfg(all(feature = "dump-block", feature = "file_storage_backend"))]
#[cfg(all(
feature = "dump-block",
feature = "file_storage_backend",
not(feature = "db_storage_backend")
))]
use massa_execution_worker::storage_backend::FileStorageBackend;
#[cfg(all(feature = "dump-block", feature = "db_storage_backend"))]
use massa_execution_worker::storage_backend::RocksDBStorageBackend;
Expand Down
Loading