Skip to content

Commit

Permalink
Merge #4491
Browse files Browse the repository at this point in the history
4491: Create test framework r=AurelienFT a=AurelienFT

- Be able to launch the tests without testing feature 

Things to do : 
- https://github.com/massalabs/massa/discussions/4486
- Rename testing to test_exports

Co-authored-by: AurelienFT <[email protected]>
Co-authored-by: AurelienFT <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2023
2 parents b7b10eb + 7d0fd79 commit 99ccf9a
Show file tree
Hide file tree
Showing 139 changed files with 1,536 additions and 885 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- -A clippy::uninlined-format-args
args: --no-deps --all-targets

security:
if: github.ref != 'refs/heads/staging'
Expand Down Expand Up @@ -206,14 +206,14 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: nextest
args: run --features testing --retries 10
args: run --retries 10
- uses: actions-rs/cargo@v1
with:
command: clean
- uses: actions-rs/cargo@v1
with:
command: test
args: --features testing --doc
args: --doc

build: # quick hack because bors wrongly detect matrix jobs status
needs: full
Expand Down
27 changes: 27 additions & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ members = [
"massa-module-cache",
"massa-serialization",
"massa-signature",
"massa-test-framework",
"massa-time",
"massa-wallet",
"massa-ledger-worker",
Expand All @@ -51,8 +52,8 @@ opt-level = 3 # Speed-up the CI

# # Features
#
# * testing: enable some tests specific exports.
# Usage: add testing = ["massa_crate/testing", ...] to dev-dependencies to use test specific functions avaible in massa-crate.
# * test-exports: enable some tests specific exports.
# Usage: add test-exports = ["massa_crate/test-exports", ...] to dev-dependencies to use test specific functions avaible in massa-crate.
# Do not add as a regular dependency. Never.
#
# * sandbox: for testing purpose, genesis timestamps is set as now + 9 seconds.
Expand Down Expand Up @@ -93,6 +94,7 @@ massa_sdk = { path = "./massa-sdk" }
massa_serialization = { path = "./massa-serialization" }
massa_signature = { path = "./massa-signature" }
massa_storage = { path = "./massa-storage" }
massa_test_framework = { path = "./massa-test-framework" }
massa_time = { path = "./massa-time" }
massa_versioning = { path = "./massa-versioning" }
massa_wallet = { path = "./massa-wallet" }
Expand Down Expand Up @@ -142,6 +144,7 @@ lazy_static = "1.4"
libsecp256k1 = "=0.7"
mio = "0.8"
mockall = "0.11"
mockall_wrap = { git = "https://github.com/AurelienFT/mockall-wrap", rev = "18f88253a000df96cf407dfe4b9158c69c0aeb96" }
more-asserts = "0.3"
nom = "=7.1"
num = "=0.4"
Expand Down
2 changes: 1 addition & 1 deletion massa-api-exports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"

[features]
sandbox = []
testing = []
test-exports = []

[dependencies]
paginate = {workspace = true}
Expand Down
7 changes: 4 additions & 3 deletions massa-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ version = "0.26.1"
edition = "2021"

[features]
testing = ["dep:massa_channel", "dep:massa_grpc", "massa_grpc/testing"]
test-exports = ["dep:massa_channel", "dep:massa_grpc", "massa_grpc/test-exports"]

[dependencies]
massa_api_exports = { workspace = true }
massa_channel = { workspace = true, optional = true}
massa_consensus_exports = { workspace = true }
massa_execution_exports = { workspace = true }
massa_grpc = { workspace = true, "features" = ["testing"], optional = true}
massa_grpc = { workspace = true, "features" = ["test-exports"], optional = true}
massa_hash = { workspace = true }
massa_models = { workspace = true }
massa_pool_exports = { workspace = true }
Expand Down Expand Up @@ -39,7 +39,8 @@ tower-http = { workspace = true, "features" = ["cors"] }
tracing = { workspace = true }

[dev-dependencies]
massa_consensus_exports = { workspace = true, "features" = ["testing"] }
jsonrpsee = { workspace = true, "features" = ["full"] }
massa_consensus_exports = { workspace = true, "features" = ["test-exports"] }
tempfile = { workspace = true }
num = { workspace = true }
massa_final_state = { workspace = true }
14 changes: 7 additions & 7 deletions massa-api/src/tests/apiv2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn get_version() {

let uri = Url::parse(&format!(
"ws://localhost:{}",
addr.to_string().split(':').into_iter().last().unwrap()
addr.to_string().split(':').last().unwrap()
))
.unwrap();

Expand Down Expand Up @@ -79,7 +79,7 @@ async fn get_next_block_best_parents() {

let uri = Url::parse(&format!(
"ws://localhost:{}",
addr.to_string().split(':').into_iter().last().unwrap()
addr.to_string().split(':').last().unwrap()
))
.unwrap();

Expand Down Expand Up @@ -123,7 +123,7 @@ async fn get_largest_stakers() {

let uri = Url::parse(&format!(
"ws://localhost:{}",
addr.to_string().split(':').into_iter().last().unwrap()
addr.to_string().split(':').last().unwrap()
))
.unwrap();

Expand Down Expand Up @@ -160,7 +160,7 @@ async fn subscribe_new_blocks() {

let uri = Url::parse(&format!(
"ws://localhost:{}",
addr.to_string().split(':').into_iter().last().unwrap()
addr.to_string().split(':').last().unwrap()
))
.unwrap();

Expand Down Expand Up @@ -193,7 +193,7 @@ async fn subscribe_new_blocks_headers() {

let uri = Url::parse(&format!(
"ws://localhost:{}",
addr.to_string().split(':').into_iter().last().unwrap()
addr.to_string().split(':').last().unwrap()
))
.unwrap();
let (tx, _rx) = tokio::sync::broadcast::channel::<SecureShare<BlockHeader, BlockId>>(10);
Expand Down Expand Up @@ -240,7 +240,7 @@ async fn subscribe_new_filled_blocks() {

let uri = Url::parse(&format!(
"ws://localhost:{}",
addr.to_string().split(':').into_iter().last().unwrap()
addr.to_string().split(':').last().unwrap()
))
.unwrap();
let (tx, _rx) = tokio::sync::broadcast::channel::<FilledBlock>(10);
Expand Down Expand Up @@ -294,7 +294,7 @@ async fn subscribe_new_operations() {

let uri = Url::parse(&format!(
"ws://localhost:{}",
addr.to_string().split(':').into_iter().last().unwrap()
addr.to_string().split(':').last().unwrap()
))
.unwrap();
let (tx, _rx) = tokio::sync::broadcast::channel::<SecureShareOperation>(10);
Expand Down
2 changes: 1 addition & 1 deletion massa-api/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) fn get_apiv2_server(addr: &SocketAddr) -> (API<ApiV2>, APIConfig) {
let api_config: APIConfig = APIConfig {
bind_private: "[::]:0".parse().unwrap(),
bind_public: "[::]:0".parse().unwrap(),
bind_api: addr.clone(),
bind_api: *addr,
draw_lookahead_period_count: 10,
max_arguments: 128,
openrpc_spec_path: "base_config/openrpc.json".parse().unwrap(),
Expand Down
Loading

0 comments on commit 99ccf9a

Please sign in to comment.