Skip to content

Commit ced48f9

Browse files
romacancazamfir
andauthored
chore(code/test): Move unit tests from malachite-test into their respective crates (#597)
* Disable `unused_crate_dependencies` lint as it is utterly broken See rust-lang/rust#95513 * Move driver tests into the `driver` crate * Move vote keeper tests into the `vote` crate * Move full proposal keeper tests into the `consensus` crate --------- Co-authored-by: Anca Zamfir <[email protected]>
1 parent 28a0c3a commit ced48f9

File tree

26 files changed

+60
-194
lines changed

26 files changed

+60
-194
lines changed

code/Cargo.lock

+15-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ members = [
2424
# Test
2525
"crates/test",
2626
"crates/test/mbt",
27+
"crates/driver/test-utils",
2728

2829
# Starknet
2930
"crates/starknet/*",
@@ -50,7 +51,7 @@ inherits = "release"
5051
debug = true
5152

5253
[workspace.lints.rust]
53-
unused_crate_dependencies = "warn"
54+
# None for now
5455

5556
[workspace.dependencies]
5657
malachite-actors = { version = "0.1.0", path = "crates/actors" }
@@ -67,11 +68,14 @@ malachite-metrics = { version = "0.1.0", path = "crates/metrics" }
6768
malachite-node = { version = "0.1.0", path = "crates/node" }
6869
malachite-proto = { version = "0.1.0", path = "crates/proto" }
6970
malachite-round = { version = "0.1.0", path = "crates/round" }
70-
malachite-test = { version = "0.1.0", path = "crates/test" }
71-
malachite-test-mbt = { version = "0.1.0", path = "crates/test/mbt" }
7271
malachite-vote = { version = "0.1.0", path = "crates/vote" }
7372
malachite-signing-ed25519 = { version = "0.1.0", path = "crates/signing-ed25519" }
7473

74+
# Test
75+
malachite-test = { version = "0.1.0", path = "crates/test" }
76+
malachite-test-mbt = { version = "0.1.0", path = "crates/test/mbt" }
77+
malachite-driver-test-utils = { version = "0.1.0", path = "crates/driver/test-utils" }
78+
7579
# Starknet
7680
malachite-starknet-host = { version = "0.1.0", path = "crates/starknet/host" }
7781
malachite-starknet-app = { version = "0.1.0", path = "crates/starknet/app" }

code/crates/common/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![no_std]
44
#![forbid(unsafe_code)]
5-
#![deny(unused_crate_dependencies, trivial_casts, trivial_numeric_casts)]
5+
#![deny(trivial_casts, trivial_numeric_casts)]
66
#![warn(
77
missing_docs,
88
rustdoc::broken_intra_doc_links,

code/crates/consensus/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ tracing = { workspace = true }
2727

2828
[lints]
2929
workspace = true
30+
31+
[dev-dependencies]
32+
malachite-test = { workspace = true }

code/crates/test/tests/full_proposal_keeper.rs renamed to code/crates/consensus/tests/full_proposal.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use malachite_actors::host::ProposedValue;
21
use malachite_common::{Context, Round, SignedProposal, Validity};
3-
use malachite_consensus::{FullProposal, FullProposalKeeper, Input};
2+
use malachite_consensus::{FullProposal, FullProposalKeeper, Input, ProposedValue};
43
use malachite_test::utils::validators::make_validators;
54
use malachite_test::{Address, Proposal, Value};
65
use malachite_test::{Height, TestContext};

code/crates/driver/Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ debug = ["std", "malachite-round/debug"]
1717
workspace = true
1818

1919
[dependencies]
20-
malachite-common = { version = "0.1.0", path = "../common" }
21-
malachite-round = { version = "0.1.0", path = "../round" }
22-
malachite-vote = { version = "0.1.0", path = "../vote" }
20+
malachite-common = { workspace = true }
21+
malachite-round = { workspace = true }
22+
malachite-vote = { workspace = true }
2323

2424
derive-where = { workspace = true }
2525
thiserror = { workspace = true, default-features = false }
26+
27+
[dev-dependencies]
28+
malachite-test = { workspace = true }
29+
malachite-driver-test-utils = { workspace = true }

code/crates/driver/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Driver for the state machine of the Malachite consensus engine
22
33
#![forbid(unsafe_code)]
4-
#![deny(unused_crate_dependencies, trivial_casts, trivial_numeric_casts)]
4+
#![deny(trivial_casts, trivial_numeric_casts)]
55
#![warn(
66
missing_docs,
77
rustdoc::broken_intra_doc_links,
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "malachite-driver-test-utils"
3+
description = "Test utilities for the `malachite-driver`"
4+
publish = false
5+
6+
version.workspace = true
7+
edition.workspace = true
8+
repository.workspace = true
9+
license.workspace = true
10+
rust-version.workspace = true
11+
12+
13+
[dependencies]
14+
malachite-common = { workspace = true }
15+
malachite-round = { workspace = true }
16+
malachite-vote = { workspace = true }
17+
malachite-test = { workspace = true }
18+
malachite-driver = { workspace = true }

code/crates/test/src/utils/driver.rs renamed to code/crates/driver/test-utils/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use malachite_common::{NilOrVal, Round, SignedProposal, SignedVote, Timeout, Validity};
22
use malachite_driver::{Input, Output};
33
use malachite_round::state::{RoundValue, State, Step};
4-
5-
use crate::{Address, Height, Proposal, Signature, TestContext, Value, Vote};
4+
use malachite_test::{Address, Height, Proposal, Signature, TestContext, Value, Vote};
65

76
pub fn new_round_input(round: Round, proposer: Address) -> Input<TestContext> {
87
Input::NewRound(Height::new(1), round, proposer)
File renamed without changes.

code/crates/test/tests/driver_extra.rs renamed to code/crates/driver/tests/extra.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use malachite_common::{Round, Validity};
22
use malachite_driver::{Driver, Input, Output};
33
use malachite_round::state::State;
44

5-
use malachite_test::utils::driver::*;
5+
use malachite_driver_test_utils::*;
66
use malachite_test::utils::validators::make_validators;
77
use malachite_test::{Height, Proposal, TestContext, ValidatorSet, Value};
88

code/crates/gossip-consensus/test/tests/discovery.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused_crate_dependencies)]
2-
31
use std::{time::Duration, vec};
42

53
use malachite_discovery_test::{Expected, Test, TestNode};

code/crates/round/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Per-round consensus state machine
22
33
#![forbid(unsafe_code)]
4-
#![deny(unused_crate_dependencies, trivial_casts, trivial_numeric_casts)]
4+
#![deny(trivial_casts, trivial_numeric_casts)]
55
#![warn(
66
missing_docs,
77
rustdoc::broken_intra_doc_links,

code/crates/starknet/test/tests/blocksync.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused_crate_dependencies)]
2-
31
use std::time::Duration;
42

53
use malachite_starknet_test::{Test, TestNode, TestParams};

code/crates/starknet/test/tests/n2f0_consensus_mode.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused_crate_dependencies)]
2-
31
use std::time::Duration;
42

53
use malachite_config::ValuePayload;

code/crates/starknet/test/tests/n2f0_pubsub_protocol.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused_crate_dependencies)]
2-
31
use std::time::Duration;
42

53
use bytesize::ByteSize;

code/crates/starknet/test/tests/n3f0.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused_crate_dependencies)]
2-
31
use std::time::Duration;
42

53
use malachite_starknet_test::{Test, TestNode};

code/crates/starknet/test/tests/n3f1.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused_crate_dependencies)]
2-
31
use std::time::Duration;
42

53
use malachite_starknet_test::{Test, TestNode};

code/crates/test/Cargo.toml

-11
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[dependencies]
13-
malachite-actors = { workspace = true }
1413
malachite-common = { workspace = true }
15-
malachite-consensus = { workspace = true }
16-
malachite-driver = { workspace = true }
17-
malachite-config = { workspace = true }
18-
malachite-round = { workspace = true }
19-
malachite-vote = { workspace = true }
2014
malachite-proto = { workspace = true }
2115
malachite-signing-ed25519 = { workspace = true, features = ["rand", "serde"] }
2216

23-
async-trait = { workspace = true }
2417
base64 = { workspace = true }
25-
bytesize = { workspace = true }
2618
bytes = { workspace = true }
2719
ed25519-consensus = { workspace = true }
2820
hex = { workspace = true }
@@ -32,9 +24,6 @@ rand = { workspace = true }
3224
serde = { workspace = true, features = ["derive"] }
3325
sha3 = { workspace = true }
3426
signature = { workspace = true }
35-
tokio = { workspace = true }
36-
tracing = { workspace = true }
37-
tracing-subscriber = { workspace = true, features = ["fmt", "env-filter"] }
3827

3928
[build-dependencies]
4029
prost-build = { workspace = true }

code/crates/test/src/utils/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
pub mod driver;
21
pub mod validators;

0 commit comments

Comments
 (0)