From e1c56f766a02f09923390d58372811630f8956c8 Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Thu, 14 Dec 2023 15:28:48 +1100 Subject: [PATCH] chore: Remove superfluous pub modifiers in test code --- coordinator/src/collaborative_revert.rs | 6 +-- coordinator/src/node/rollover.rs | 2 +- coordinator/src/orderbook/trading.rs | 8 ++-- coordinator/src/position/models.rs | 25 +++---------- crates/ln-dlc-node/src/ldk_node_wallet.rs | 2 +- .../src/ln/coordinator_event_handler.rs | 2 +- crates/payout_curve/src/lib.rs | 37 ++++++++++--------- crates/trade/src/cfd.rs | 2 +- crates/trade/src/lib.rs | 4 +- mobile/native/src/db/custom_types.rs | 14 +++---- mobile/native/src/db/models.rs | 12 +++--- mobile/native/src/ln_dlc/node.rs | 6 +-- 12 files changed, 54 insertions(+), 66 deletions(-) diff --git a/coordinator/src/collaborative_revert.rs b/coordinator/src/collaborative_revert.rs index 7ccaa7c27..61a6ef6b7 100644 --- a/coordinator/src/collaborative_revert.rs +++ b/coordinator/src/collaborative_revert.rs @@ -485,11 +485,11 @@ fn estimate_subchannel_reserved_tx_fees( } #[cfg(test)] -pub mod tests { +mod tests { use super::*; #[test] - pub fn estimate_subchannel_reserved_tx_fees_test() { + fn estimate_subchannel_reserved_tx_fees_test() { let total_fee = estimate_subchannel_reserved_tx_fees(200_000, 65_450, 85_673, 1_000, 18_690, 18_690) .unwrap(); @@ -497,7 +497,7 @@ pub mod tests { } #[test] - pub fn estimate_subchannel_reserved_tx_fees_cannot_overflow() { + fn estimate_subchannel_reserved_tx_fees_cannot_overflow() { assert!(estimate_subchannel_reserved_tx_fees( 200_000, 84_140, 104_363, 1_000, 18_690, 18_690, ) diff --git a/coordinator/src/node/rollover.rs b/coordinator/src/node/rollover.rs index f4ceabef2..15d1d0030 100644 --- a/coordinator/src/node/rollover.rs +++ b/coordinator/src/node/rollover.rs @@ -317,7 +317,7 @@ impl From for ContractInput { } #[cfg(test)] -pub mod tests { +mod tests { use super::*; use bitcoin::secp256k1; use bitcoin::secp256k1::ecdsa::Signature; diff --git a/coordinator/src/orderbook/trading.rs b/coordinator/src/orderbook/trading.rs index d243cb77f..33fe4562c 100644 --- a/coordinator/src/orderbook/trading.rs +++ b/coordinator/src/orderbook/trading.rs @@ -423,7 +423,7 @@ impl From<&TradeParams> for TraderMatchParams { } #[cfg(test)] -pub mod tests { +mod tests { use super::*; use rust_decimal_macros::dec; use std::str::FromStr; @@ -431,7 +431,7 @@ pub mod tests { use trade::ContractSymbol; #[test] - pub fn when_short_then_sort_desc() { + fn when_short_then_sort_desc() { let order1 = dummy_long_order( dec!(20_000), Uuid::new_v4(), @@ -460,7 +460,7 @@ pub mod tests { } #[test] - pub fn when_long_then_sort_asc() { + fn when_long_then_sort_asc() { let order1 = dummy_long_order( dec!(20_000), Uuid::new_v4(), @@ -489,7 +489,7 @@ pub mod tests { } #[test] - pub fn when_all_same_price_sort_by_id() { + fn when_all_same_price_sort_by_id() { let order1 = dummy_long_order( dec!(20_000), Uuid::new_v4(), diff --git a/coordinator/src/position/models.rs b/coordinator/src/position/models.rs index 14f387ba2..435545522 100644 --- a/coordinator/src/position/models.rs +++ b/coordinator/src/position/models.rs @@ -427,7 +427,7 @@ impl std::fmt::Debug for Position { } #[cfg(test)] -pub mod tests { +mod tests { use super::*; use rust_decimal_macros::dec; use std::str::FromStr; @@ -801,7 +801,7 @@ pub mod tests { } impl Position { - pub(crate) fn dummy() -> Self { + fn dummy() -> Self { Position { id: 0, contract_symbol: ContractSymbol::BtcUsd, @@ -827,37 +827,24 @@ pub mod tests { } } - pub(crate) fn with_quantity(mut self, quantity: f32) -> Self { + fn with_quantity(mut self, quantity: f32) -> Self { self.quantity = quantity; self } - pub(crate) fn with_average_entry_price(mut self, average_entry_price: f32) -> Self { + fn with_average_entry_price(mut self, average_entry_price: f32) -> Self { self.average_entry_price = average_entry_price; self } - pub(crate) fn with_leverage(mut self, leverage: f32) -> Self { + fn with_leverage(mut self, leverage: f32) -> Self { self.trader_leverage = leverage; self } - pub(crate) fn with_direction(mut self, direction: Direction) -> Self { + fn with_direction(mut self, direction: Direction) -> Self { self.direction = direction; self } } } - -#[derive(Clone, Debug)] -pub struct CollaborativeRevert { - pub channel_id: ChannelId, - pub trader_pubkey: PublicKey, - pub price: f32, - pub coordinator_address: Address, - pub coordinator_amount_sats: Amount, - pub trader_amount_sats: Amount, - pub timestamp: OffsetDateTime, - pub txid: Txid, - pub vout: u32, -} diff --git a/crates/ln-dlc-node/src/ldk_node_wallet.rs b/crates/ln-dlc-node/src/ldk_node_wallet.rs index 5a01c0c8c..e67f6034c 100644 --- a/crates/ln-dlc-node/src/ldk_node_wallet.rs +++ b/crates/ln-dlc-node/src/ldk_node_wallet.rs @@ -310,7 +310,7 @@ where } #[cfg(test)] -pub mod tests { +mod tests { use super::*; use crate::channel::Channel; use crate::fee_rate_estimator::EstimateFeeRate; diff --git a/crates/ln-dlc-node/src/ln/coordinator_event_handler.rs b/crates/ln-dlc-node/src/ln/coordinator_event_handler.rs index b65a6a0e4..29012aa0e 100644 --- a/crates/ln-dlc-node/src/ln/coordinator_event_handler.rs +++ b/crates/ln-dlc-node/src/ln/coordinator_event_handler.rs @@ -602,7 +602,7 @@ mod tests { use std::str::FromStr; #[test] - pub fn test_calculate_channel_value() { + fn test_calculate_channel_value() { let dummy_pub_key = PublicKey::from_str( "02bd998ebd176715fe92b7467cf6b1df8023950a4dd911db4c94dfc89cc9f5a655", ) diff --git a/crates/payout_curve/src/lib.rs b/crates/payout_curve/src/lib.rs index 6c44be412..de26ef4c9 100644 --- a/crates/payout_curve/src/lib.rs +++ b/crates/payout_curve/src/lib.rs @@ -303,7 +303,7 @@ mod tests { const PRINT_CSV: bool = false; #[test] - pub fn calculate_lower_range_payout_points_when_offerer_long_then_gets_zero() { + fn calculate_lower_range_payout_points_when_offerer_long_then_gets_zero() { // setup // we take 2 BTC so that all tests have nice numbers let total_collateral = Amount::ONE_BTC.to_sat() * 2; @@ -336,8 +336,9 @@ mod tests { wtr.flush().unwrap(); } } + #[test] - pub fn calculate_lower_range_payout_points_when_offerer_long_then_gets_zero_plus_fee() { + fn calculate_lower_range_payout_points_when_offerer_long_then_gets_zero_plus_fee() { // setup // we take 2 BTC so that all tests have nice numbers let total_collateral = Amount::ONE_BTC.to_sat() * 2; @@ -373,7 +374,7 @@ mod tests { } #[test] - pub fn calculate_lower_range_payout_points_when_offer_short_then_gets_all() { + fn calculate_lower_range_payout_points_when_offer_short_then_gets_all() { // setup // we take 2 BTC so that all tests have nice numbers let total_collateral = Amount::ONE_BTC.to_sat() * 2; @@ -409,7 +410,7 @@ mod tests { } #[test] - pub fn snapshot_test_mid_range_offerer() { + fn snapshot_test_mid_range_offerer() { // setup let long_leverage = 2.0; let short_leverage = 2.0; @@ -535,7 +536,7 @@ mod tests { } #[test] - pub fn ensure_all_bounds_smaller_or_equal_max_btc_price() { + fn ensure_all_bounds_smaller_or_equal_max_btc_price() { // setup let long_leverage = 2.0; let short_leverage = 1.0; @@ -592,7 +593,7 @@ mod tests { } #[test] - pub fn calculate_upper_range_payout_points_when_offer_short_then_gets_zero() { + fn calculate_upper_range_payout_points_when_offer_short_then_gets_zero() { // setup // we take 2 BTC so that all tests have nice numbers let total_collateral = Amount::ONE_BTC.to_sat() * 2; @@ -627,7 +628,7 @@ mod tests { } #[test] - pub fn calculate_upper_range_payout_points_when_offer_long_then_gets_everything() { + fn calculate_upper_range_payout_points_when_offer_long_then_gets_everything() { // setup // we take 2 BTC so that all tests have nice numbers let total_collateral = Amount::ONE_BTC.to_sat() * 2; @@ -663,7 +664,7 @@ mod tests { } #[test] - pub fn upper_range_price_always_below_max_btc_price() { + fn upper_range_price_always_below_max_btc_price() { // setup let total_collateral = Amount::ONE_BTC.to_sat() * 2; let last_payout = PayoutPoint { @@ -703,20 +704,20 @@ mod tests { #[derive(Serialize, Deserialize)] struct PayoutCouple { - pub lower_event_outcome: u64, - pub lower_outcome_payout: u64, - pub lower_extra_precision: u16, - pub upper_event_outcome: u64, - pub upper_outcome_payout: u64, - pub upper_extra_precision: u16, + lower_event_outcome: u64, + lower_outcome_payout: u64, + lower_extra_precision: u16, + upper_event_outcome: u64, + upper_outcome_payout: u64, + upper_extra_precision: u16, } #[derive(Serialize, Deserialize, Debug)] struct ShouldPayout { - pub start: u64, - pub payout_offer: u64, - pub payout_accept: u64, - pub fee: u64, + start: u64, + payout_offer: u64, + payout_accept: u64, + fee: u64, } //******* Proptests *******// diff --git a/crates/trade/src/cfd.rs b/crates/trade/src/cfd.rs index e33b04c75..3aea548f6 100644 --- a/crates/trade/src/cfd.rs +++ b/crates/trade/src/cfd.rs @@ -117,7 +117,7 @@ pub fn calculate_pnl( } #[cfg(test)] -pub mod tests { +mod tests { use super::*; #[test] diff --git a/crates/trade/src/lib.rs b/crates/trade/src/lib.rs index 474b36eea..fae544502 100644 --- a/crates/trade/src/lib.rs +++ b/crates/trade/src/lib.rs @@ -88,12 +88,12 @@ impl fmt::Display for ContractSymbol { } #[cfg(test)] -pub mod tests { +mod tests { use crate::ContractSymbol; use std::str::FromStr; #[test] - pub fn contract_symbol_from_str() { + fn contract_symbol_from_str() { assert_eq!( ContractSymbol::from_str("btcusd").unwrap(), ContractSymbol::BtcUsd diff --git a/mobile/native/src/db/custom_types.rs b/mobile/native/src/db/custom_types.rs index 71a6b4ebf..4a2af594f 100644 --- a/mobile/native/src/db/custom_types.rs +++ b/mobile/native/src/db/custom_types.rs @@ -287,7 +287,7 @@ impl FromSql for ChannelState { } #[cfg(test)] -pub mod tests { +mod tests { use crate::db::custom_types::tests::customstruct::id; use crate::db::models::ContractSymbol; use crate::db::models::Direction; @@ -302,12 +302,12 @@ pub mod tests { #[derive(Insertable, Queryable, Identifiable, Debug, PartialEq, Clone)] #[diesel(table_name = customstruct)] - pub struct SampleStruct { - pub id: String, - pub order_type: OrderType, - pub order_state: OrderState, - pub contract_symbol: ContractSymbol, - pub direction: Direction, + struct SampleStruct { + id: String, + order_type: OrderType, + order_state: OrderState, + contract_symbol: ContractSymbol, + direction: Direction, } diesel::table! { diff --git a/mobile/native/src/db/models.rs b/mobile/native/src/db/models.rs index 22c5977c6..9cfdaf0f0 100644 --- a/mobile/native/src/db/models.rs +++ b/mobile/native/src/db/models.rs @@ -1451,7 +1451,7 @@ pub mod test { use time::Time; #[test] - pub fn order_round_trip() { + fn order_round_trip() { let mut connection = SqliteConnection::establish(":memory:").unwrap(); connection.run_pending_migrations(MIGRATIONS).unwrap(); @@ -1560,7 +1560,7 @@ pub mod test { } #[test] - pub fn given_several_orders_when_fetching_orders_for_ui_only_relevant_orders_are_loaded() { + fn given_several_orders_when_fetching_orders_for_ui_only_relevant_orders_are_loaded() { let mut connection = SqliteConnection::establish(":memory:").unwrap(); connection.run_pending_migrations(MIGRATIONS).unwrap(); @@ -1652,7 +1652,7 @@ pub mod test { } #[test] - pub fn payment_round_trip() { + fn payment_round_trip() { let mut connection = SqliteConnection::establish(":memory:").unwrap(); connection.run_pending_migrations(MIGRATIONS).unwrap(); @@ -1764,7 +1764,7 @@ pub mod test { } #[test] - pub fn spendable_output_round_trip() { + fn spendable_output_round_trip() { let mut connection = SqliteConnection::establish(":memory:").unwrap(); connection.run_pending_migrations(MIGRATIONS).unwrap(); @@ -1837,7 +1837,7 @@ pub mod test { } #[test] - pub fn channel_round_trip() { + fn channel_round_trip() { let mut connection = SqliteConnection::establish(":memory:").unwrap(); connection.run_pending_migrations(MIGRATIONS).unwrap(); @@ -1899,7 +1899,7 @@ pub mod test { } #[test] - pub fn transaction_round_trip() { + fn transaction_round_trip() { let mut connection = SqliteConnection::establish(":memory:").unwrap(); connection.run_pending_migrations(MIGRATIONS).unwrap(); diff --git a/mobile/native/src/ln_dlc/node.rs b/mobile/native/src/ln_dlc/node.rs index 4653cf503..35d5df739 100644 --- a/mobile/native/src/ln_dlc/node.rs +++ b/mobile/native/src/ln_dlc/node.rs @@ -566,7 +566,7 @@ impl node::Storage for NodeStorage { } #[cfg(test)] -pub mod tests { +mod tests { use crate::ln_dlc::node::is_expired; use bitcoin::secp256k1::schnorr::Signature; use bitcoin::secp256k1::PublicKey; @@ -596,7 +596,7 @@ pub mod tests { use time::OffsetDateTime; #[test] - pub fn contract_with_maturity_in_past_is_expired() { + fn contract_with_maturity_in_past_is_expired() { // setup let expired_timestamp = (OffsetDateTime::now_utc() - Duration::seconds(10)).unix_timestamp() as u32; @@ -611,7 +611,7 @@ pub mod tests { assert!(is_expired) } #[test] - pub fn contract_with_maturity_in_future_is_valid() { + fn contract_with_maturity_in_future_is_valid() { // setup let expired_timestamp = (OffsetDateTime::now_utc() + Duration::minutes(1)).unix_timestamp() as u32;