mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-22 19:49:28 +00:00
test-utils: enable workspace lints (#283)
* test-utils: enable workspace lints + fix * `allow` -> `expect` * fixes
This commit is contained in:
parent
b9842fcb18
commit
2afc0e8373
8 changed files with 25 additions and 45 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -840,7 +840,6 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"borsh",
|
"borsh",
|
||||||
"bytes",
|
|
||||||
"cuprate-helper",
|
"cuprate-helper",
|
||||||
"cuprate-p2p-core",
|
"cuprate-p2p-core",
|
||||||
"cuprate-types",
|
"cuprate-types",
|
||||||
|
|
|
@ -22,7 +22,6 @@ tokio = { workspace = true, features = ["full"] }
|
||||||
tokio-util = { workspace = true }
|
tokio-util = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
bytes = { workspace = true, features = ["std"] }
|
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
paste = { workspace = true }
|
paste = { workspace = true }
|
||||||
borsh = { workspace = true, features = ["derive"]}
|
borsh = { workspace = true, features = ["derive"]}
|
||||||
|
@ -30,3 +29,6 @@ borsh = { workspace = true, features = ["derive"]}
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex = { workspace = true }
|
hex = { workspace = true }
|
||||||
pretty_assertions = { workspace = true }
|
pretty_assertions = { workspace = true }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
|
@ -148,8 +148,8 @@ pub fn tx_fee(tx: &Transaction) -> u64 {
|
||||||
///
|
///
|
||||||
/// This requires some static block/tx input (from data) and some fields.
|
/// This requires some static block/tx input (from data) and some fields.
|
||||||
/// This data can be accessed more easily via:
|
/// This data can be accessed more easily via:
|
||||||
/// - A block explorer (https://xmrchain.net)
|
/// - A block explorer (<https://xmrchain.net>)
|
||||||
/// - Monero RPC (see cuprate_test_utils::rpc for this)
|
/// - Monero RPC (see `cuprate_test_utils::rpc` for this)
|
||||||
///
|
///
|
||||||
/// See below for actual usage.
|
/// See below for actual usage.
|
||||||
macro_rules! verified_block_information {
|
macro_rules! verified_block_information {
|
||||||
|
|
|
@ -178,6 +178,7 @@ impl Drop for SpawnedMoneroD {
|
||||||
println!("------END-MONEROD-LOGS------");
|
println!("------END-MONEROD-LOGS------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[expect(clippy::manual_assert, reason = "`if` is more clear")]
|
||||||
if error && !panicking() {
|
if error && !panicking() {
|
||||||
// `println` only outputs in a test when panicking so if there is an error while
|
// `println` only outputs in a test when panicking so if there is an error while
|
||||||
// dropping monerod but not an error in the test then we need to panic to make sure
|
// dropping monerod but not an error in the test then we need to panic to make sure
|
||||||
|
|
|
@ -47,13 +47,13 @@ impl HttpRpcClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The address used for this [`HttpRpcClient`].
|
/// The address used for this [`HttpRpcClient`].
|
||||||
#[allow(dead_code)]
|
#[allow(clippy::allow_attributes, dead_code, reason = "expect doesn't work")]
|
||||||
const fn address(&self) -> &String {
|
const fn address(&self) -> &String {
|
||||||
&self.address
|
&self.address
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Access to the inner RPC client for other usage.
|
/// Access to the inner RPC client for other usage.
|
||||||
#[allow(dead_code)]
|
#[expect(dead_code)]
|
||||||
const fn rpc(&self) -> &SimpleRequestRpc {
|
const fn rpc(&self) -> &SimpleRequestRpc {
|
||||||
&self.rpc
|
&self.rpc
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ mod tests {
|
||||||
#[ignore] // FIXME: doesn't work in CI, we need a real unrestricted node
|
#[ignore] // FIXME: doesn't work in CI, we need a real unrestricted node
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn get() {
|
async fn get() {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[expect(clippy::too_many_arguments)]
|
||||||
async fn assert_eq(
|
async fn assert_eq(
|
||||||
rpc: &HttpRpcClient,
|
rpc: &HttpRpcClient,
|
||||||
height: usize,
|
height: usize,
|
||||||
|
|
|
@ -156,13 +156,5 @@ macro_rules! define_request_and_response_doc_test {
|
||||||
"```\n",
|
"```\n",
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
// No doc test.
|
|
||||||
(
|
|
||||||
$name:ident,
|
|
||||||
$test:ident,
|
|
||||||
) => {
|
|
||||||
""
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
pub(super) use define_request_and_response_doc_test;
|
pub(super) use define_request_and_response_doc_test;
|
||||||
|
|
|
@ -8,8 +8,7 @@ define_request_and_response! {
|
||||||
// `(other)` adds a JSON sanity-check test.
|
// `(other)` adds a JSON sanity-check test.
|
||||||
get_height (other),
|
get_height (other),
|
||||||
GET_HEIGHT: &str,
|
GET_HEIGHT: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"hash": "68bb1a1cff8e2a44c3221e8e1aff80bc6ca45d06fa8eff4d2a3a7ac31d4efe3f",
|
"hash": "68bb1a1cff8e2a44c3221e8e1aff80bc6ca45d06fa8eff4d2a3a7ac31d4efe3f",
|
||||||
|
@ -53,8 +52,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
get_alt_blocks_hashes (other),
|
get_alt_blocks_hashes (other),
|
||||||
GET_ALT_BLOCKS_HASHES: &str,
|
GET_ALT_BLOCKS_HASHES: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"blks_hashes": ["8ee10db35b1baf943f201b303890a29e7d45437bd76c2bd4df0d2f2ee34be109"],
|
"blks_hashes": ["8ee10db35b1baf943f201b303890a29e7d45437bd76c2bd4df0d2f2ee34be109"],
|
||||||
|
@ -134,8 +132,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
stop_mining (other),
|
stop_mining (other),
|
||||||
STOP_MINING: &str,
|
STOP_MINING: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"status": "OK",
|
"status": "OK",
|
||||||
|
@ -146,8 +143,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
mining_status (other),
|
mining_status (other),
|
||||||
MINING_STATUS: &str,
|
MINING_STATUS: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"active": false,
|
"active": false,
|
||||||
|
@ -173,8 +169,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
save_bc (other),
|
save_bc (other),
|
||||||
SAVE_BC: &str,
|
SAVE_BC: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"status": "OK",
|
"status": "OK",
|
||||||
|
@ -185,8 +180,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
get_peer_list (other),
|
get_peer_list (other),
|
||||||
GET_PEER_LIST: &str,
|
GET_PEER_LIST: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"gray_list": [{
|
"gray_list": [{
|
||||||
|
@ -291,8 +285,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
get_transaction_pool (other),
|
get_transaction_pool (other),
|
||||||
GET_TRANSACTION_POOL: &str,
|
GET_TRANSACTION_POOL: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"credits": 0,
|
"credits": 0,
|
||||||
|
@ -598,8 +591,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
get_transaction_pool_stats (other),
|
get_transaction_pool_stats (other),
|
||||||
GET_TRANSACTION_POOL_STATS: &str,
|
GET_TRANSACTION_POOL_STATS: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"credits": 0,
|
"credits": 0,
|
||||||
|
@ -657,8 +649,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
stop_daemon (other),
|
stop_daemon (other),
|
||||||
STOP_DAEMON: &str,
|
STOP_DAEMON: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"status": "OK"
|
"status": "OK"
|
||||||
|
@ -668,8 +659,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
get_limit (other),
|
get_limit (other),
|
||||||
GET_LIMIT: &str,
|
GET_LIMIT: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"limit_down": 1280000,
|
"limit_down": 1280000,
|
||||||
|
@ -713,8 +703,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
get_net_stats (other),
|
get_net_stats (other),
|
||||||
GET_NET_STATS: &str,
|
GET_NET_STATS: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"start_time": 1721251858,
|
"start_time": 1721251858,
|
||||||
|
@ -801,8 +790,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
UNDOCUMENTED_ENDPOINT (other),
|
UNDOCUMENTED_ENDPOINT (other),
|
||||||
GET_TRANSACTION_POOL_HASHES: &str,
|
GET_TRANSACTION_POOL_HASHES: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"credits": 0,
|
"credits": 0,
|
||||||
|
@ -835,8 +823,7 @@ r#"{
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
UNDOCUMENTED_ENDPOINT (other),
|
UNDOCUMENTED_ENDPOINT (other),
|
||||||
GET_PUBLIC_NODES: &str,
|
GET_PUBLIC_NODES: &str,
|
||||||
Request =
|
Request = "{}";
|
||||||
r#"{}"#;
|
|
||||||
Response =
|
Response =
|
||||||
r#"{
|
r#"{
|
||||||
"status": "OK",
|
"status": "OK",
|
||||||
|
|
|
@ -86,9 +86,8 @@ impl<const ALLOW_SYNC: bool, const DANDELION_PP: bool, const CHECK_NODE_ID: bool
|
||||||
type Sink = FramedWrite<WriteHalf<DuplexStream>, MoneroWireCodec>;
|
type Sink = FramedWrite<WriteHalf<DuplexStream>, MoneroWireCodec>;
|
||||||
type Listener = Pin<
|
type Listener = Pin<
|
||||||
Box<
|
Box<
|
||||||
dyn Stream<
|
dyn Stream<Item = Result<(Option<Self::Addr>, Self::Stream, Self::Sink), Error>>
|
||||||
Item = Result<(Option<Self::Addr>, Self::Stream, Self::Sink), std::io::Error>,
|
+ Send
|
||||||
> + Send
|
|
||||||
+ 'static,
|
+ 'static,
|
||||||
>,
|
>,
|
||||||
>;
|
>;
|
||||||
|
|
Loading…
Reference in a new issue