From e7480ab0e19e4baa83e4c46099bdf738e7f03385 Mon Sep 17 00:00:00 2001 From: pan93412 Date: Fri, 8 Jul 2022 22:34:05 +0800 Subject: [PATCH 1/2] refactor: run cargo clippy --fix Some issues are fixed manually: - useless use of `vec!` in macro - this loop never actually loops - replace to `rx.into_iter().next().expect(...);` - this `if` has identical blocks --- crypto-markets/tests/binance.rs | 12 +- crypto-markets/tests/bitfinex.rs | 4 +- crypto-markets/tests/bitget.rs | 6 +- crypto-markets/tests/bithumb.rs | 2 +- crypto-markets/tests/coinbase_pro.rs | 2 +- crypto-markets/tests/ftx.rs | 2 +- crypto-markets/tests/kraken.rs | 2 +- crypto-markets/tests/kucoin.rs | 2 +- crypto-markets/tests/mexc.rs | 2 +- crypto-msg-parser/src/exchanges/bitmex.rs | 4 +- crypto-msg-type/src/exchanges/binance.rs | 12 +- crypto-msg-type/src/exchanges/bitfinex.rs | 12 +- crypto-msg-type/src/exchanges/bitmex.rs | 12 +- crypto-msg-type/src/exchanges/bybit.rs | 12 +- crypto-msg-type/src/exchanges/deribit.rs | 12 +- crypto-msg-type/src/exchanges/ftx.rs | 8 +- crypto-msg-type/src/exchanges/huobi.rs | 12 +- crypto-msg-type/src/exchanges/okex.rs | 12 +- crypto-msg-type/src/exchanges/okx.rs | 12 +- crypto-pair/tests/binance.rs | 2 +- crypto-pair/tests/bitfinex.rs | 2 +- crypto-pair/tests/bitget.rs | 2 +- crypto-pair/tests/bithumb.rs | 2 +- crypto-pair/tests/bitmex.rs | 2 +- crypto-pair/tests/bitstamp.rs | 2 +- crypto-pair/tests/bitz.rs | 2 +- crypto-pair/tests/bybit.rs | 2 +- crypto-pair/tests/coinbase_pro.rs | 2 +- crypto-pair/tests/deribit.rs | 2 +- crypto-pair/tests/dydx.rs | 2 +- crypto-pair/tests/ftx.rs | 6 +- crypto-pair/tests/gate.rs | 4 +- crypto-pair/tests/huobi.rs | 2 +- crypto-pair/tests/kraken.rs | 8 +- crypto-pair/tests/kucoin.rs | 2 +- crypto-pair/tests/mexc.rs | 2 +- crypto-pair/tests/okx.rs | 4 +- crypto-pair/tests/zb.rs | 4 +- crypto-pair/tests/zbg.rs | 2 +- crypto-rest-client/tests/binance_inverse.rs | 8 +- crypto-rest-client/tests/binance_linear.rs | 8 +- crypto-rest-client/tests/binance_option.rs | 4 +- crypto-rest-client/tests/binance_spot.rs | 2 +- crypto-rest-client/tests/bitget_spot.rs | 4 +- crypto-rest-client/tests/bitget_swap.rs | 4 +- crypto-rest-client/tests/bithumb.rs | 6 +- crypto-rest-client/tests/bitstamp.rs | 4 +- crypto-rest-client/tests/bitz_spot.rs | 4 +- crypto-rest-client/tests/bitz_swap.rs | 4 +- crypto-rest-client/tests/coinbase_pro.rs | 4 +- crypto-rest-client/tests/deribit.rs | 2 +- crypto-rest-client/tests/huobi.rs | 12 +- crypto-rest-client/tests/mexc.rs | 8 +- crypto-rest-client/tests/okx.rs | 4 +- crypto-rest-client/tests/zb.rs | 8 +- crypto-rest-client/tests/zbg.rs | 4 +- crypto-ws-client/src/clients/binance.rs | 8 +- .../src/clients/binance_option.rs | 8 +- crypto-ws-client/src/clients/bitfinex.rs | 4 +- crypto-ws-client/src/clients/bitget/utils.rs | 10 +- crypto-ws-client/src/clients/bithumb.rs | 12 +- crypto-ws-client/src/clients/bitmex.rs | 8 +- crypto-ws-client/src/clients/bitstamp.rs | 8 +- crypto-ws-client/src/clients/bybit/utils.rs | 8 +- crypto-ws-client/src/clients/coinbase_pro.rs | 12 +- crypto-ws-client/src/clients/deribit.rs | 8 +- .../src/clients/dydx/dydx_swap.rs | 8 +- crypto-ws-client/src/clients/ftx.rs | 8 +- crypto-ws-client/src/clients/gate/utils.rs | 36 ++-- crypto-ws-client/src/clients/huobi.rs | 8 +- .../src/clients/kraken/kraken_futures.rs | 8 +- .../src/clients/kraken/kraken_spot.rs | 8 +- .../src/clients/kucoin/kucoin_spot.rs | 22 +-- .../src/clients/kucoin/kucoin_swap.rs | 22 +-- crypto-ws-client/src/clients/kucoin/utils.rs | 2 +- .../src/clients/mexc/mexc_spot.rs | 10 +- .../src/clients/mexc/mexc_swap.rs | 10 +- crypto-ws-client/src/clients/okx.rs | 8 +- crypto-ws-client/src/clients/zb/zb_spot.rs | 10 +- crypto-ws-client/src/clients/zb/zb_swap.rs | 10 +- crypto-ws-client/src/clients/zbg/zbg_spot.rs | 10 +- crypto-ws-client/src/clients/zbg/zbg_swap.rs | 10 +- crypto-ws-client/tests/binance.rs | 174 +++++++----------- crypto-ws-client/tests/binance_option.rs | 44 ++--- crypto-ws-client/tests/bitfinex.rs | 38 ++-- crypto-ws-client/tests/bitget.rs | 44 ++--- crypto-ws-client/tests/bithumb.rs | 16 +- crypto-ws-client/tests/bitmex.rs | 76 ++++---- crypto-ws-client/tests/bitstamp.rs | 20 +- crypto-ws-client/tests/bitz.rs | 18 +- crypto-ws-client/tests/bybit.rs | 38 ++-- crypto-ws-client/tests/coinbase_pro.rs | 18 +- crypto-ws-client/tests/deribit.rs | 42 ++--- crypto-ws-client/tests/dydx.rs | 10 +- crypto-ws-client/tests/ftx.rs | 34 ++-- crypto-ws-client/tests/gate.rs | 84 ++++----- crypto-ws-client/tests/huobi.rs | 137 ++++++-------- crypto-ws-client/tests/kraken.rs | 50 ++--- crypto-ws-client/tests/kucoin.rs | 94 +++++----- crypto-ws-client/tests/mexc.rs | 72 +++----- crypto-ws-client/tests/okx.rs | 72 ++++---- crypto-ws-client/tests/zb.rs | 36 ++-- crypto-ws-client/tests/zbg.rs | 72 +++----- 103 files changed, 760 insertions(+), 993 deletions(-) diff --git a/crypto-markets/tests/binance.rs b/crypto-markets/tests/binance.rs index 9990d931..11522140 100644 --- a/crypto-markets/tests/binance.rs +++ b/crypto-markets/tests/binance.rs @@ -21,7 +21,7 @@ fn fetch_spot_symbols() { assert_eq!(symbol.to_uppercase(), symbol.to_string()); assert_eq!( MarketType::Spot, - get_market_type(&symbol, EXCHANGE_NAME, Some(true)) + get_market_type(symbol, EXCHANGE_NAME, Some(true)) ); } } @@ -39,7 +39,7 @@ fn fetch_inverse_future_symbols() { assert_eq!(quote, "USD"); assert_eq!( MarketType::InverseFuture, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } @@ -57,7 +57,7 @@ fn fetch_linear_future_symbols() { assert_eq!(quote, "USDT"); assert_eq!( MarketType::LinearFuture, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } @@ -71,7 +71,7 @@ fn fetch_inverse_swap_symbols() { assert!(symbol.ends_with("USD_PERP")); assert_eq!( MarketType::InverseSwap, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } @@ -85,7 +85,7 @@ fn fetch_linear_swap_symbols() { assert!(symbol.ends_with("USDT") || symbol.ends_with("BUSD")); assert_eq!( MarketType::LinearSwap, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } @@ -100,7 +100,7 @@ fn fetch_option_symbols() { assert!(symbol.ends_with("-P") || symbol.ends_with("-C")); assert_eq!( MarketType::EuropeanOption, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } diff --git a/crypto-markets/tests/bitfinex.rs b/crypto-markets/tests/bitfinex.rs index a0d48890..e9184922 100644 --- a/crypto-markets/tests/bitfinex.rs +++ b/crypto-markets/tests/bitfinex.rs @@ -21,7 +21,7 @@ fn fetch_spot_symbols() { assert!(symbol.starts_with('t')); assert_eq!( MarketType::Spot, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } @@ -39,7 +39,7 @@ fn fetch_linear_swap_symbols() { ); assert_eq!( MarketType::LinearSwap, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } diff --git a/crypto-markets/tests/bitget.rs b/crypto-markets/tests/bitget.rs index 2e002027..666c16f4 100644 --- a/crypto-markets/tests/bitget.rs +++ b/crypto-markets/tests/bitget.rs @@ -25,7 +25,7 @@ fn fetch_spot_symbols() { ); assert_eq!( MarketType::Spot, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } @@ -38,7 +38,7 @@ fn fetch_inverse_swap_symbols() { assert!(symbol.ends_with("USD_DMCBL")); assert_eq!( MarketType::InverseSwap, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } @@ -51,7 +51,7 @@ fn fetch_linear_swap_symbols() { assert!(symbol.ends_with("USDT_UMCBL")); assert_eq!( MarketType::LinearSwap, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } diff --git a/crypto-markets/tests/bithumb.rs b/crypto-markets/tests/bithumb.rs index 33c29339..ccf6a1c9 100644 --- a/crypto-markets/tests/bithumb.rs +++ b/crypto-markets/tests/bithumb.rs @@ -22,7 +22,7 @@ fn fetch_spot_symbols() { assert_eq!(symbol.to_string(), symbol.to_uppercase()); assert_eq!( MarketType::Spot, - get_market_type(&symbol, EXCHANGE_NAME, None) + get_market_type(symbol, EXCHANGE_NAME, None) ); } } diff --git a/crypto-markets/tests/coinbase_pro.rs b/crypto-markets/tests/coinbase_pro.rs index aa267c0e..6d7bd7b4 100644 --- a/crypto-markets/tests/coinbase_pro.rs +++ b/crypto-markets/tests/coinbase_pro.rs @@ -18,7 +18,7 @@ fn fetch_spot_symbols() { assert!(!symbols.is_empty()); for symbol in symbols.iter() { - assert!(symbol.contains("-")); + assert!(symbol.contains('-')); assert_eq!(symbol.to_string(), symbol.to_uppercase()); assert_eq!( MarketType::Spot, diff --git a/crypto-markets/tests/ftx.rs b/crypto-markets/tests/ftx.rs index 882c1396..d22de93b 100644 --- a/crypto-markets/tests/ftx.rs +++ b/crypto-markets/tests/ftx.rs @@ -18,7 +18,7 @@ fn fetch_spot_symbols() { let symbols = fetch_symbols(EXCHANGE_NAME, MarketType::Spot).unwrap(); assert!(!symbols.is_empty()); for symbol in symbols.iter() { - assert!(symbol.contains("/")); + assert!(symbol.contains('/')); assert_eq!(*symbol, symbol.to_uppercase()); assert_eq!( MarketType::Spot, diff --git a/crypto-markets/tests/kraken.rs b/crypto-markets/tests/kraken.rs index a131cb0f..1b97a3ce 100644 --- a/crypto-markets/tests/kraken.rs +++ b/crypto-markets/tests/kraken.rs @@ -17,7 +17,7 @@ fn fetch_spot_symbols() { let symbols = fetch_symbols(EXCHANGE_NAME, MarketType::Spot).unwrap(); assert!(!symbols.is_empty()); for symbol in symbols.iter() { - assert!(symbol.contains("/")); + assert!(symbol.contains('/')); assert_eq!( MarketType::Spot, get_market_type(symbol, EXCHANGE_NAME, None) diff --git a/crypto-markets/tests/kucoin.rs b/crypto-markets/tests/kucoin.rs index 28cec840..d5fa7a0b 100644 --- a/crypto-markets/tests/kucoin.rs +++ b/crypto-markets/tests/kucoin.rs @@ -18,7 +18,7 @@ fn fetch_spot_symbols() { let symbols = fetch_symbols(EXCHANGE_NAME, MarketType::Spot).unwrap(); assert!(!symbols.is_empty()); for symbol in symbols.iter() { - assert!(symbol.contains("-")); + assert!(symbol.contains('-')); assert_eq!(symbol.to_string(), symbol.to_uppercase()); assert_eq!( MarketType::Spot, diff --git a/crypto-markets/tests/mexc.rs b/crypto-markets/tests/mexc.rs index 6e1ea343..ed78aab3 100644 --- a/crypto-markets/tests/mexc.rs +++ b/crypto-markets/tests/mexc.rs @@ -14,7 +14,7 @@ fn fetch_spot_symbols() { assert!(!symbols.is_empty()); for symbol in symbols.iter() { - assert!(symbol.contains("_")); + assert!(symbol.contains('_')); assert_eq!(symbol.to_uppercase(), symbol.to_string()); assert_eq!( MarketType::Spot, diff --git a/crypto-msg-parser/src/exchanges/bitmex.rs b/crypto-msg-parser/src/exchanges/bitmex.rs index ae52bacf..0799cd53 100644 --- a/crypto-msg-parser/src/exchanges/bitmex.rs +++ b/crypto-msg-parser/src/exchanges/bitmex.rs @@ -852,10 +852,10 @@ mod tests { #[ignore] fn test_fetch_tick_sizes() { let mut tick_sizes = super::fetch_tick_sizes(); - assert!(tick_sizes.len() > 0); + assert!(!tick_sizes.is_empty()); for (symbol, t) in super::SYMBOL_INDEX_AND_TICK_SIZE_MAP.iter() { if !tick_sizes.contains_key(symbol) { - tick_sizes.insert(symbol.clone(), t.clone()); + tick_sizes.insert(symbol.clone(), *t); } } for (symbol, tick_size) in tick_sizes { diff --git a/crypto-msg-type/src/exchanges/binance.rs b/crypto-msg-type/src/exchanges/binance.rs index 40af7180..84122441 100644 --- a/crypto-msg-type/src/exchanges/binance.rs +++ b/crypto-msg-type/src/exchanges/binance.rs @@ -69,8 +69,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()], + &[MessageType::Trade], + &["BTCUSDT".to_string(), "ETHUSDT".to_string()], true, None, ); @@ -84,8 +84,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["BTCUSDT".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["BTCUSDT".to_string()], true, None, ); @@ -101,8 +101,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "1m".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()], + &[MessageType::Candlestick], + &["BTCUSDT".to_string(), "ETHUSDT".to_string()], true, Some(&configs), ); diff --git a/crypto-msg-type/src/exchanges/bitfinex.rs b/crypto-msg-type/src/exchanges/bitfinex.rs index 5d84e41e..713344cf 100644 --- a/crypto-msg-type/src/exchanges/bitfinex.rs +++ b/crypto-msg-type/src/exchanges/bitfinex.rs @@ -72,8 +72,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["tBTCUST".to_string(), "tETHUST".to_string()], + &[MessageType::Trade], + &["tBTCUST".to_string(), "tETHUST".to_string()], true, None, ); @@ -91,8 +91,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["tBTCUST".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["tBTCUST".to_string()], true, None, ); @@ -112,8 +112,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "1m".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["tBTCUST".to_string(), "tETHUST".to_string()], + &[MessageType::Candlestick], + &["tBTCUST".to_string(), "tETHUST".to_string()], true, Some(&configs), ); diff --git a/crypto-msg-type/src/exchanges/bitmex.rs b/crypto-msg-type/src/exchanges/bitmex.rs index d21cee41..6db408d0 100644 --- a/crypto-msg-type/src/exchanges/bitmex.rs +++ b/crypto-msg-type/src/exchanges/bitmex.rs @@ -66,8 +66,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["XBTUSD".to_string(), "ETHUSD".to_string()], + &[MessageType::Trade], + &["XBTUSD".to_string(), "ETHUSD".to_string()], true, None, ); @@ -81,8 +81,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["XBTUSD".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["XBTUSD".to_string()], true, None, ); @@ -98,8 +98,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "1m".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["XBTUSD".to_string(), "ETHUSD".to_string()], + &[MessageType::Candlestick], + &["XBTUSD".to_string(), "ETHUSD".to_string()], true, Some(&configs), ); diff --git a/crypto-msg-type/src/exchanges/bybit.rs b/crypto-msg-type/src/exchanges/bybit.rs index 26fa7e38..f5af0b89 100644 --- a/crypto-msg-type/src/exchanges/bybit.rs +++ b/crypto-msg-type/src/exchanges/bybit.rs @@ -66,8 +66,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["BTCUSD".to_string(), "ETHUSD".to_string()], + &[MessageType::Trade], + &["BTCUSD".to_string(), "ETHUSD".to_string()], true, None, ); @@ -81,8 +81,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["BTCUSD".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["BTCUSD".to_string()], true, None, ); @@ -98,8 +98,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "1".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["BTCUSD".to_string(), "ETHUSD".to_string()], + &[MessageType::Candlestick], + &["BTCUSD".to_string(), "ETHUSD".to_string()], true, Some(&configs), ); diff --git a/crypto-msg-type/src/exchanges/deribit.rs b/crypto-msg-type/src/exchanges/deribit.rs index a96ee440..6cbbfc60 100644 --- a/crypto-msg-type/src/exchanges/deribit.rs +++ b/crypto-msg-type/src/exchanges/deribit.rs @@ -58,8 +58,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["BTC-PERPETUAL".to_string(), "ETH-PERPETUAL".to_string()], + &[MessageType::Trade], + &["BTC-PERPETUAL".to_string(), "ETH-PERPETUAL".to_string()], true, None, ); @@ -73,8 +73,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["BTC-PERPETUAL".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["BTC-PERPETUAL".to_string()], true, None, ); @@ -90,8 +90,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "1m".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["BTC-PERPETUAL".to_string(), "ETH-PERPETUAL".to_string()], + &[MessageType::Candlestick], + &["BTC-PERPETUAL".to_string(), "ETH-PERPETUAL".to_string()], true, Some(&configs), ); diff --git a/crypto-msg-type/src/exchanges/ftx.rs b/crypto-msg-type/src/exchanges/ftx.rs index 99a2afed..bf894f32 100644 --- a/crypto-msg-type/src/exchanges/ftx.rs +++ b/crypto-msg-type/src/exchanges/ftx.rs @@ -48,8 +48,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["BTC/USD".to_string(), "BTC-PERP".to_string()], + &[MessageType::Trade], + &["BTC/USD".to_string(), "BTC-PERP".to_string()], true, None, ); @@ -68,8 +68,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["BTC-PERP".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["BTC-PERP".to_string()], true, None, ); diff --git a/crypto-msg-type/src/exchanges/huobi.rs b/crypto-msg-type/src/exchanges/huobi.rs index 182dfa2f..ac918e9f 100644 --- a/crypto-msg-type/src/exchanges/huobi.rs +++ b/crypto-msg-type/src/exchanges/huobi.rs @@ -80,8 +80,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["BTC-USD".to_string(), "ETH-USD".to_string()], + &[MessageType::Trade], + &["BTC-USD".to_string(), "ETH-USD".to_string()], true, None, ); @@ -99,8 +99,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["BTC-USD".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["BTC-USD".to_string()], true, None, ); @@ -120,8 +120,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "1m".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["BTC-USD".to_string(), "ETH-USD".to_string()], + &[MessageType::Candlestick], + &["BTC-USD".to_string(), "ETH-USD".to_string()], true, Some(&configs), ); diff --git a/crypto-msg-type/src/exchanges/okex.rs b/crypto-msg-type/src/exchanges/okex.rs index 566dee65..da899e75 100644 --- a/crypto-msg-type/src/exchanges/okex.rs +++ b/crypto-msg-type/src/exchanges/okex.rs @@ -87,8 +87,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], + &[MessageType::Trade], + &["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], true, None, ); @@ -102,8 +102,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["BTC-USDT-SWAP".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["BTC-USDT-SWAP".to_string()], true, None, ); @@ -119,8 +119,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "60".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], + &[MessageType::Candlestick], + &["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], true, Some(&configs), ); diff --git a/crypto-msg-type/src/exchanges/okx.rs b/crypto-msg-type/src/exchanges/okx.rs index dd0ef26f..e5e6aa10 100644 --- a/crypto-msg-type/src/exchanges/okx.rs +++ b/crypto-msg-type/src/exchanges/okx.rs @@ -78,8 +78,8 @@ mod tests { #[test] fn single_msg_type_multiple_symbols() { let commands = get_ws_commands( - &vec![MessageType::Trade], - &vec!["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], + &[MessageType::Trade], + &["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], true, None, ); @@ -93,8 +93,8 @@ mod tests { #[test] fn multiple_msg_types_single_symbol() { let commands = get_ws_commands( - &vec![MessageType::Trade, MessageType::L2Event], - &vec!["BTC-USDT-SWAP".to_string()], + &[MessageType::Trade, MessageType::L2Event], + &["BTC-USDT-SWAP".to_string()], true, None, ); @@ -110,8 +110,8 @@ mod tests { let mut configs = HashMap::new(); configs.insert("interval".to_string(), "1m".to_string()); let commands = get_ws_commands( - &vec![MessageType::Candlestick], - &vec!["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], + &[MessageType::Candlestick], + &["BTC-USDT-SWAP".to_string(), "ETH-USDT-SWAP".to_string()], true, Some(&configs), ); diff --git a/crypto-pair/tests/binance.rs b/crypto-pair/tests/binance.rs index 4b17de12..69a9ca80 100644 --- a/crypto-pair/tests/binance.rs +++ b/crypto-pair/tests/binance.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "binance"; +const EXCHANGE_NAME: &str = "binance"; #[derive(Serialize, Deserialize)] struct BinanceResponse { symbols: Vec, diff --git a/crypto-pair/tests/bitfinex.rs b/crypto-pair/tests/bitfinex.rs index 7c5b444c..5cc28573 100644 --- a/crypto-pair/tests/bitfinex.rs +++ b/crypto-pair/tests/bitfinex.rs @@ -1,7 +1,7 @@ use crypto_market_type::MarketType; use crypto_pair::{get_market_type, normalize_pair}; -const EXCHANGE_NAME: &'static str = "bitfinex"; +const EXCHANGE_NAME: &str = "bitfinex"; #[test] fn verify_spot_symbols() { diff --git a/crypto-pair/tests/bitget.rs b/crypto-pair/tests/bitget.rs index 6667178b..688c4b79 100644 --- a/crypto-pair/tests/bitget.rs +++ b/crypto-pair/tests/bitget.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "bitget"; +const EXCHANGE_NAME: &str = "bitget"; // See https://bitgetlimited.github.io/apidoc/en/spot/#get-all-instruments #[derive(Clone, Serialize, Deserialize)] diff --git a/crypto-pair/tests/bithumb.rs b/crypto-pair/tests/bithumb.rs index bad3b2d4..821be2c3 100644 --- a/crypto-pair/tests/bithumb.rs +++ b/crypto-pair/tests/bithumb.rs @@ -1,7 +1,7 @@ use crypto_market_type::MarketType; use crypto_pair::{get_market_type, normalize_pair}; -const EXCHANGE_NAME: &'static str = "bithumb"; +const EXCHANGE_NAME: &str = "bithumb"; #[test] fn verify_spot_symbols() { diff --git a/crypto-pair/tests/bitmex.rs b/crypto-pair/tests/bitmex.rs index cbb56cfa..1155cd67 100644 --- a/crypto-pair/tests/bitmex.rs +++ b/crypto-pair/tests/bitmex.rs @@ -6,7 +6,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "bitmex"; +const EXCHANGE_NAME: &str = "bitmex"; #[derive(Clone, Serialize, Deserialize)] #[allow(non_snake_case)] diff --git a/crypto-pair/tests/bitstamp.rs b/crypto-pair/tests/bitstamp.rs index 6fbe59c7..162c850d 100644 --- a/crypto-pair/tests/bitstamp.rs +++ b/crypto-pair/tests/bitstamp.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "bitstamp"; +const EXCHANGE_NAME: &str = "bitstamp"; #[derive(Serialize, Deserialize)] struct SpotMarket { diff --git a/crypto-pair/tests/bitz.rs b/crypto-pair/tests/bitz.rs index abe33802..572d8336 100644 --- a/crypto-pair/tests/bitz.rs +++ b/crypto-pair/tests/bitz.rs @@ -6,7 +6,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "bitz"; +const EXCHANGE_NAME: &str = "bitz"; #[derive(Clone, Serialize, Deserialize)] #[allow(non_snake_case)] diff --git a/crypto-pair/tests/bybit.rs b/crypto-pair/tests/bybit.rs index ebb4e443..3d94a19a 100644 --- a/crypto-pair/tests/bybit.rs +++ b/crypto-pair/tests/bybit.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "bybit"; +const EXCHANGE_NAME: &str = "bybit"; #[derive(Serialize, Deserialize)] struct BybitMarket { diff --git a/crypto-pair/tests/coinbase_pro.rs b/crypto-pair/tests/coinbase_pro.rs index d2694813..51af47b0 100644 --- a/crypto-pair/tests/coinbase_pro.rs +++ b/crypto-pair/tests/coinbase_pro.rs @@ -5,7 +5,7 @@ use crypto_pair::{get_market_type, normalize_currency, normalize_pair}; use serde::{Deserialize, Serialize}; use utils::http_get; -const EXCHANGE_NAME: &'static str = "coinbase_pro"; +const EXCHANGE_NAME: &str = "coinbase_pro"; #[derive(Serialize, Deserialize)] struct SpotMarket { diff --git a/crypto-pair/tests/deribit.rs b/crypto-pair/tests/deribit.rs index 5bf66406..3ba0df6e 100644 --- a/crypto-pair/tests/deribit.rs +++ b/crypto-pair/tests/deribit.rs @@ -6,7 +6,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "deribit"; +const EXCHANGE_NAME: &str = "deribit"; #[derive(Serialize, Deserialize)] #[allow(non_snake_case)] diff --git a/crypto-pair/tests/dydx.rs b/crypto-pair/tests/dydx.rs index a8476b40..f6aa69f1 100644 --- a/crypto-pair/tests/dydx.rs +++ b/crypto-pair/tests/dydx.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "dydx"; +const EXCHANGE_NAME: &str = "dydx"; #[derive(Clone, Serialize, Deserialize)] #[allow(non_snake_case)] diff --git a/crypto-pair/tests/ftx.rs b/crypto-pair/tests/ftx.rs index 58fd5d4b..f9c0b2ad 100644 --- a/crypto-pair/tests/ftx.rs +++ b/crypto-pair/tests/ftx.rs @@ -6,7 +6,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "ftx"; +const EXCHANGE_NAME: &str = "ftx"; #[derive(Serialize, Deserialize)] #[allow(non_snake_case)] @@ -43,9 +43,7 @@ fn verify_all_symbols() { // spot market.name.clone() } else if market.type_ == "future" { - if market.name.ends_with("-PERP") { - format!("{}/USD", market.underlying.clone().unwrap()) - } else if market.name.contains("-MOVE-") { + if market.name.ends_with("-PERP") || market.name.contains("-MOVE-") { format!("{}/USD", market.underlying.clone().unwrap()) } else if market.name.contains("BVOL/") { format!( diff --git a/crypto-pair/tests/gate.rs b/crypto-pair/tests/gate.rs index b58aa33b..6709b4fe 100644 --- a/crypto-pair/tests/gate.rs +++ b/crypto-pair/tests/gate.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "gate"; +const EXCHANGE_NAME: &str = "gate"; #[derive(Serialize, Deserialize)] #[allow(non_snake_case)] @@ -89,7 +89,7 @@ fn verify_future_symbols() { let markets = fetch_future_markets_raw("usdt"); for market in markets.iter() { let pair = normalize_pair(&market.name, EXCHANGE_NAME).unwrap(); - let pair_expected = market.underlying.replace("_", "/"); + let pair_expected = market.underlying.replace('_', "/"); assert_eq!(pair, pair_expected); diff --git a/crypto-pair/tests/huobi.rs b/crypto-pair/tests/huobi.rs index f4b61e80..af9940a3 100644 --- a/crypto-pair/tests/huobi.rs +++ b/crypto-pair/tests/huobi.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "huobi"; +const EXCHANGE_NAME: &str = "huobi"; #[derive(Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] diff --git a/crypto-pair/tests/kraken.rs b/crypto-pair/tests/kraken.rs index bc0cb71d..e3e184f9 100644 --- a/crypto-pair/tests/kraken.rs +++ b/crypto-pair/tests/kraken.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "kraken"; +const EXCHANGE_NAME: &str = "kraken"; // https://docs.kraken.com/rest/#operation/getTradableAssetPairs #[derive(Clone, Serialize, Deserialize)] @@ -75,13 +75,13 @@ struct FuturesResponse { fn fetch_futures_markets_raw() -> Vec { let txt = http_get("https://futures.kraken.com/derivatives/api/v3/instruments").unwrap(); let obj = serde_json::from_str::>(&txt).unwrap(); - let markets = obj + + obj .instruments .into_iter() .filter(|x| x.tradeable) .filter(|m| m.symbol.starts_with("pi_") || m.symbol.starts_with("fi_")) - .collect::>(); - markets + .collect::>() } #[test] diff --git a/crypto-pair/tests/kucoin.rs b/crypto-pair/tests/kucoin.rs index 71772c0d..0f46b931 100644 --- a/crypto-pair/tests/kucoin.rs +++ b/crypto-pair/tests/kucoin.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "kucoin"; +const EXCHANGE_NAME: &str = "kucoin"; #[derive(Clone, Serialize, Deserialize)] #[allow(non_snake_case)] diff --git a/crypto-pair/tests/mexc.rs b/crypto-pair/tests/mexc.rs index d208ee1a..1c0631ba 100644 --- a/crypto-pair/tests/mexc.rs +++ b/crypto-pair/tests/mexc.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "mexc"; +const EXCHANGE_NAME: &str = "mexc"; #[test] fn verify_spot_symbols() { diff --git a/crypto-pair/tests/okx.rs b/crypto-pair/tests/okx.rs index 565b1042..5af82fb6 100644 --- a/crypto-pair/tests/okx.rs +++ b/crypto-pair/tests/okx.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "okx"; +const EXCHANGE_NAME: &str = "okx"; // see #[derive(Serialize, Deserialize)] @@ -38,7 +38,7 @@ fn fetch_raw_markets_raw(inst_type: &str) -> Vec { let data = json_obj.get("data").unwrap().as_array().unwrap()[0] .as_array() .unwrap(); - data.into_iter() + data.iter() .map(|x| x.as_str().unwrap().to_string()) .collect::>() }; diff --git a/crypto-pair/tests/zb.rs b/crypto-pair/tests/zb.rs index 4a31da05..b7769b6e 100644 --- a/crypto-pair/tests/zb.rs +++ b/crypto-pair/tests/zb.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "zb"; +const EXCHANGE_NAME: &str = "zb"; #[derive(Serialize, Deserialize)] #[allow(non_snake_case)] @@ -32,7 +32,7 @@ fn fetch_swap_markets(url: &str) -> Vec { let txt = http_get(url).unwrap(); let resp = serde_json::from_str::(&txt).unwrap(); if resp.code == 1000 { - return resp.data; + resp.data } else { Vec::new() } diff --git a/crypto-pair/tests/zbg.rs b/crypto-pair/tests/zbg.rs index dd37f85d..e74812e3 100644 --- a/crypto-pair/tests/zbg.rs +++ b/crypto-pair/tests/zbg.rs @@ -7,7 +7,7 @@ use serde_json::Value; use std::collections::HashMap; use utils::http_get; -const EXCHANGE_NAME: &'static str = "zbg"; +const EXCHANGE_NAME: &str = "zbg"; #[derive(Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] diff --git a/crypto-rest-client/tests/binance_inverse.rs b/crypto-rest-client/tests/binance_inverse.rs index 58909409..1810a005 100644 --- a/crypto-rest-client/tests/binance_inverse.rs +++ b/crypto-rest-client/tests/binance_inverse.rs @@ -14,14 +14,14 @@ mod inverse_swap { fn test_l2_snapshot() { let text = fetch_l2_snapshot("binance", MarketType::InverseSwap, "BTCUSD_PERP", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_open_interest() { let text = fetch_open_interest("binance", MarketType::InverseSwap, Some("BTCUSD_PERP")).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } @@ -46,13 +46,13 @@ mod inverse_future { Some(3), ) .unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_open_interest() { let text = fetch_open_interest("binance", MarketType::InverseFuture, Some("BTCUSD_220930")) .unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } diff --git a/crypto-rest-client/tests/binance_linear.rs b/crypto-rest-client/tests/binance_linear.rs index 0a6bf24d..895ed287 100644 --- a/crypto-rest-client/tests/binance_linear.rs +++ b/crypto-rest-client/tests/binance_linear.rs @@ -13,13 +13,13 @@ mod linear_swap { fn test_l2_snapshot() { let text = fetch_l2_snapshot("binance", MarketType::LinearSwap, "BTCUSDT", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_open_interest() { let text = fetch_open_interest("binance", MarketType::LinearSwap, Some("BTCUSDT")).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } @@ -44,13 +44,13 @@ mod linear_future { Some(3), ) .unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_open_interest() { let text = fetch_open_interest("binance", MarketType::LinearFuture, Some("BTCUSDT_220930")) .unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } diff --git a/crypto-rest-client/tests/binance_option.rs b/crypto-rest-client/tests/binance_option.rs index 2d8b72ab..6c4d0ae6 100644 --- a/crypto-rest-client/tests/binance_option.rs +++ b/crypto-rest-client/tests/binance_option.rs @@ -5,7 +5,7 @@ use crypto_rest_client::{fetch_l2_snapshot, BinanceOptionRestClient}; #[test] fn test_agg_trades() { let text = BinanceOptionRestClient::fetch_trades("BTC-220610-30000-C", None).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[ignore] @@ -18,5 +18,5 @@ fn test_l2_snapshot() { Some(3), ) .unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } diff --git a/crypto-rest-client/tests/binance_spot.rs b/crypto-rest-client/tests/binance_spot.rs index 3627fdc0..c5590df6 100644 --- a/crypto-rest-client/tests/binance_spot.rs +++ b/crypto-rest-client/tests/binance_spot.rs @@ -10,5 +10,5 @@ fn test_agg_trades() { #[test] fn test_l2_snapshot() { let text = fetch_l2_snapshot("binance", MarketType::Spot, "BTCUSDT", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } diff --git a/crypto-rest-client/tests/bitget_spot.rs b/crypto-rest-client/tests/bitget_spot.rs index d3978909..6bfd4549 100644 --- a/crypto-rest-client/tests/bitget_spot.rs +++ b/crypto-rest-client/tests/bitget_spot.rs @@ -11,6 +11,6 @@ fn test_l2_snapshot() { assert_eq!(obj.get("msg").unwrap().as_str().unwrap(), "success"); let data = obj.get("data").unwrap().as_object().unwrap(); - assert!(data.get("asks").unwrap().as_array().unwrap().len() > 0); - assert!(data.get("bids").unwrap().as_array().unwrap().len() > 0); + assert!(!data.get("asks").unwrap().as_array().unwrap().is_empty()); + assert!(!data.get("bids").unwrap().as_array().unwrap().is_empty()); } diff --git a/crypto-rest-client/tests/bitget_swap.rs b/crypto-rest-client/tests/bitget_swap.rs index a00c3bb0..bd858f23 100644 --- a/crypto-rest-client/tests/bitget_swap.rs +++ b/crypto-rest-client/tests/bitget_swap.rs @@ -11,8 +11,8 @@ fn test_l2_snapshot(market_type: MarketType, symbol: &str) { let obj = serde_json::from_str::>(&text).unwrap(); let data = obj.get("data").unwrap().as_object().unwrap(); - assert!(data.get("asks").unwrap().as_array().unwrap().len() > 0); - assert!(data.get("bids").unwrap().as_array().unwrap().len() > 0); + assert!(!data.get("asks").unwrap().as_array().unwrap().is_empty()); + assert!(!data.get("bids").unwrap().as_array().unwrap().is_empty()); } #[test_case(MarketType::InverseSwap, "BTCUSD_DMCBL")] diff --git a/crypto-rest-client/tests/bithumb.rs b/crypto-rest-client/tests/bithumb.rs index 3b463de1..d2529bf0 100644 --- a/crypto-rest-client/tests/bithumb.rs +++ b/crypto-rest-client/tests/bithumb.rs @@ -11,7 +11,7 @@ fn test_trades() { assert_eq!(obj.get("code").unwrap().as_str().unwrap(), "0"); let data = obj.get("data").unwrap().as_array().unwrap(); - assert!(data.len() > 0); + assert!(!data.is_empty()); } #[test] @@ -23,6 +23,6 @@ fn test_l2_snapshot() { let data = obj.get("data").unwrap().as_object().unwrap(); let buy = data.get("b").unwrap().as_array().unwrap(); let sell = data.get("s").unwrap().as_array().unwrap(); - assert!(buy.len() > 0); - assert!(sell.len() > 0); + assert!(!buy.is_empty()); + assert!(!sell.is_empty()); } diff --git a/crypto-rest-client/tests/bitstamp.rs b/crypto-rest-client/tests/bitstamp.rs index 91af91e5..d7f3fc0f 100644 --- a/crypto-rest-client/tests/bitstamp.rs +++ b/crypto-rest-client/tests/bitstamp.rs @@ -10,11 +10,11 @@ fn test_trades() { #[test] fn test_l2_snapshot() { let text = fetch_l2_snapshot("bitstamp", MarketType::Spot, "btcusd", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_l3_snapshot() { let text = fetch_l3_snapshot("bitstamp", MarketType::Spot, "btcusd", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } diff --git a/crypto-rest-client/tests/bitz_spot.rs b/crypto-rest-client/tests/bitz_spot.rs index d0d20a64..4ed66675 100644 --- a/crypto-rest-client/tests/bitz_spot.rs +++ b/crypto-rest-client/tests/bitz_spot.rs @@ -13,6 +13,6 @@ fn test_l2_snapshot() { assert_eq!(obj.get("status").unwrap().as_i64().unwrap(), 200); let data = obj.get("data").unwrap().as_object().unwrap(); - assert!(data.get("asks").unwrap().as_array().unwrap().len() > 0); - assert!(data.get("bids").unwrap().as_array().unwrap().len() > 0); + assert!(!data.get("asks").unwrap().as_array().unwrap().is_empty()); + assert!(!data.get("bids").unwrap().as_array().unwrap().is_empty()); } diff --git a/crypto-rest-client/tests/bitz_swap.rs b/crypto-rest-client/tests/bitz_swap.rs index 3df951e5..dd696f76 100644 --- a/crypto-rest-client/tests/bitz_swap.rs +++ b/crypto-rest-client/tests/bitz_swap.rs @@ -14,8 +14,8 @@ fn test_l2_snapshot(market_type: MarketType, symbol: &str) { assert_eq!(obj.get("status").unwrap().as_i64().unwrap(), 200); let data = obj.get("data").unwrap().as_object().unwrap(); - assert!(data.get("asks").unwrap().as_array().unwrap().len() > 0); - assert!(data.get("bids").unwrap().as_array().unwrap().len() > 0); + assert!(!data.get("asks").unwrap().as_array().unwrap().is_empty()); + assert!(!data.get("bids").unwrap().as_array().unwrap().is_empty()); } #[test_case(MarketType::InverseSwap; "inconclusive 1")] diff --git a/crypto-rest-client/tests/coinbase_pro.rs b/crypto-rest-client/tests/coinbase_pro.rs index 2e23c73a..2029c349 100644 --- a/crypto-rest-client/tests/coinbase_pro.rs +++ b/crypto-rest-client/tests/coinbase_pro.rs @@ -10,11 +10,11 @@ fn test_trades() { #[test] fn test_l2_snapshot() { let text = fetch_l2_snapshot("coinbase_pro", MarketType::Spot, "BTC-USD", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_l3_snapshot() { let text = fetch_l3_snapshot("coinbase_pro", MarketType::Spot, "BTC-USD", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } diff --git a/crypto-rest-client/tests/deribit.rs b/crypto-rest-client/tests/deribit.rs index 463d893e..a28b12bb 100644 --- a/crypto-rest-client/tests/deribit.rs +++ b/crypto-rest-client/tests/deribit.rs @@ -35,7 +35,7 @@ fn test_l2_snapshot(market_type: MarketType, symbol: &str) { fn test_open_interest(market_type: MarketType) { let text = fetch_open_interest("deribit", market_type, None).unwrap(); for line in text.lines() { - let obj = serde_json::from_str::>(&line).unwrap(); + let obj = serde_json::from_str::>(line).unwrap(); let arr = obj.get("result").unwrap().as_array().unwrap(); assert!(!arr.is_empty()); } diff --git a/crypto-rest-client/tests/huobi.rs b/crypto-rest-client/tests/huobi.rs index 0d83878c..c234e56d 100644 --- a/crypto-rest-client/tests/huobi.rs +++ b/crypto-rest-client/tests/huobi.rs @@ -11,7 +11,7 @@ use test_case::test_case; #[test_case(MarketType::EuropeanOption, "BTC-USDT-210625-P-27000"; "inconclusive")] fn test_l2_snapshot(market_type: MarketType, symbol: &str) { let text = fetch_l2_snapshot("huobi", market_type, symbol, Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); let obj = serde_json::from_str::>(&text).unwrap(); assert_eq!("ok", obj.get("status").unwrap().as_str().unwrap()); @@ -56,7 +56,7 @@ mod huobi_spot { #[test] fn test_trades() { let text = HuobiSpotRestClient::fetch_trades("btcusdt").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } @@ -67,7 +67,7 @@ mod huobi_future { #[test] fn test_trades() { let text = HuobiFutureRestClient::fetch_trades("BTC_CQ").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } @@ -78,7 +78,7 @@ mod huobi_linear_swap { #[test] fn test_trades() { let text = HuobiLinearSwapRestClient::fetch_trades("BTC-USDT").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } @@ -89,7 +89,7 @@ mod huobi_inverse_swap { #[test] fn test_trades() { let text = HuobiInverseSwapRestClient::fetch_trades("BTC-USD").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } @@ -101,6 +101,6 @@ mod huobi_option { #[ignore] fn test_trades() { let text = HuobiOptionRestClient::fetch_trades("BTC-USDT-210625-P-27000").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } diff --git a/crypto-rest-client/tests/mexc.rs b/crypto-rest-client/tests/mexc.rs index a39cce42..d90ff179 100644 --- a/crypto-rest-client/tests/mexc.rs +++ b/crypto-rest-client/tests/mexc.rs @@ -5,13 +5,13 @@ mod mexc_spot { #[test] fn test_trades() { let text = MexcSpotRestClient::fetch_trades("BTC_USDT").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_l2_snapshot() { let text = MexcSpotRestClient::fetch_l2_snapshot("BTC_USDT").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } @@ -23,12 +23,12 @@ mod mexc_swap { #[test] fn test_trades() { let text = MexcSwapRestClient::fetch_trades("BTC_USDT").unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test] fn test_l2_snapshot() { let text = fetch_l2_snapshot("mexc", MarketType::LinearSwap, "BTC_USDT", Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } } diff --git a/crypto-rest-client/tests/okx.rs b/crypto-rest-client/tests/okx.rs index 448d174f..4b463207 100644 --- a/crypto-rest-client/tests/okx.rs +++ b/crypto-rest-client/tests/okx.rs @@ -12,7 +12,7 @@ use test_case::test_case; #[test_case(MarketType::EuropeanOption, "BTC-USD-220930-10000-P")] fn test_l2_snapshot(market_type: MarketType, symbol: &str) { let text = fetch_l2_snapshot("okx", market_type, symbol, Some(3)).unwrap(); - assert!(text.starts_with("{")); + assert!(text.starts_with('{')); } #[test_case(MarketType::InverseFuture, "BTC-USD-220930")] @@ -24,7 +24,7 @@ fn test_open_interest(market_type: MarketType, symbol: &str) { let text = fetch_open_interest("okx", market_type, Some(symbol)).unwrap(); let json_obj = serde_json::from_str::>(&text).unwrap(); let arr = json_obj.get("data").unwrap().as_array().unwrap(); - assert!(arr.len() > 0); + assert!(!arr.is_empty()); } #[cfg(test)] diff --git a/crypto-rest-client/tests/zb.rs b/crypto-rest-client/tests/zb.rs index cd75e04e..cf6d23a0 100644 --- a/crypto-rest-client/tests/zb.rs +++ b/crypto-rest-client/tests/zb.rs @@ -9,8 +9,8 @@ fn test_spot_l2_snapshot() { let text = fetch_l2_snapshot("zb", MarketType::Spot, "btc_usdt", Some(3)).unwrap(); let obj = serde_json::from_str::>(&text).unwrap(); - assert!(obj.get("asks").unwrap().as_array().unwrap().len() > 0); - assert!(obj.get("bids").unwrap().as_array().unwrap().len() > 0); + assert!(!obj.get("asks").unwrap().as_array().unwrap().is_empty()); + assert!(!obj.get("bids").unwrap().as_array().unwrap().is_empty()); } #[test] @@ -21,6 +21,6 @@ fn test_swap_l2_snapshot() { assert_eq!(10000, obj["code"].as_i64().unwrap()); let data = obj.get("data").unwrap().as_object().unwrap(); - assert!(data.get("asks").unwrap().as_array().unwrap().len() > 0); - assert!(data.get("bids").unwrap().as_array().unwrap().len() > 0); + assert!(!data.get("asks").unwrap().as_array().unwrap().is_empty()); + assert!(!data.get("bids").unwrap().as_array().unwrap().is_empty()); } diff --git a/crypto-rest-client/tests/zbg.rs b/crypto-rest-client/tests/zbg.rs index 19a15775..6f95d7cf 100644 --- a/crypto-rest-client/tests/zbg.rs +++ b/crypto-rest-client/tests/zbg.rs @@ -25,8 +25,8 @@ fn test_l2_snapshot(market_type: MarketType, symbol: &str) { ); let data = obj.get("datas").unwrap().as_object().unwrap(); - assert!(data.get("asks").unwrap().as_array().unwrap().len() > 0); - assert!(data.get("bids").unwrap().as_array().unwrap().len() > 0); + assert!(!data.get("asks").unwrap().as_array().unwrap().is_empty()); + assert!(!data.get("bids").unwrap().as_array().unwrap().is_empty()); } #[test_case(MarketType::InverseSwap, "BTC_USD-R")] diff --git a/crypto-ws-client/src/clients/binance.rs b/crypto-ws-client/src/clients/binance.rs index feec4561..78e5adf2 100644 --- a/crypto-ws-client/src/clients/binance.rs +++ b/crypto-ws-client/src/clients/binance.rs @@ -297,7 +297,7 @@ mod tests { fn test_one_topic() { let translator = super::BinanceCommandTranslator { market_type: 'S' }; let commands = translator - .translate_to_commands(true, &vec![("aggTrade".to_string(), "BTCUSDT".to_string())]); + .translate_to_commands(true, &[("aggTrade".to_string(), "BTCUSDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -311,10 +311,8 @@ mod tests { let translator = super::BinanceCommandTranslator { market_type: 'S' }; let commands = translator.translate_to_commands( true, - &vec![ - ("aggTrade".to_string(), "BTCUSDT".to_string()), - ("ticker".to_string(), "BTCUSDT".to_string()), - ], + &[("aggTrade".to_string(), "BTCUSDT".to_string()), + ("ticker".to_string(), "BTCUSDT".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/binance_option.rs b/crypto-ws-client/src/clients/binance_option.rs index 365f282a..c3ba1d0f 100644 --- a/crypto-ws-client/src/clients/binance_option.rs +++ b/crypto-ws-client/src/clients/binance_option.rs @@ -159,7 +159,7 @@ mod tests { let translator = super::BinanceOptionCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![("trade".to_string(), "BTC-220429-50000-C".to_string())], + &[("trade".to_string(), "BTC-220429-50000-C".to_string())], ); assert_eq!(1, commands.len()); @@ -174,10 +174,8 @@ mod tests { let translator = super::BinanceOptionCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trade".to_string(), "BTC-220429-50000-C".to_string()), - ("ticker".to_string(), "BTC-220429-50000-C".to_string()), - ], + &[("trade".to_string(), "BTC-220429-50000-C".to_string()), + ("ticker".to_string(), "BTC-220429-50000-C".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bitfinex.rs b/crypto-ws-client/src/clients/bitfinex.rs index 1e8ce1cf..ae42ad8e 100644 --- a/crypto-ws-client/src/clients/bitfinex.rs +++ b/crypto-ws-client/src/clients/bitfinex.rs @@ -303,7 +303,7 @@ mod tests { fn test_spot_command() { let translator = super::BitfinexCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("trades".to_string(), "tBTCUSD".to_string())]); + .translate_to_commands(true, &[("trades".to_string(), "tBTCUSD".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -317,7 +317,7 @@ mod tests { let translator = super::BitfinexCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![("trades".to_string(), "tBTCF0:USTF0".to_string())], + &[("trades".to_string(), "tBTCF0:USTF0".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bitget/utils.rs b/crypto-ws-client/src/clients/bitget/utils.rs index 5670640c..f1a7e436 100644 --- a/crypto-ws-client/src/clients/bitget/utils.rs +++ b/crypto-ws-client/src/clients/bitget/utils.rs @@ -158,7 +158,7 @@ mod tests { fn test_one_topic() { let translator = super::BitgetCommandTranslator::<'S'> {}; let commands = translator - .translate_to_commands(true, &vec![("trade".to_string(), "BTCUSDT".to_string())]); + .translate_to_commands(true, &[("trade".to_string(), "BTCUSDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -172,10 +172,8 @@ mod tests { let translator = super::BitgetCommandTranslator::<'S'> {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trade".to_string(), "BTCUSDT".to_string()), - ("books".to_string(), "ETHUSDT".to_string()), - ], + &[("trade".to_string(), "BTCUSDT".to_string()), + ("books".to_string(), "ETHUSDT".to_string())], ); assert_eq!(1, commands.len()); @@ -190,7 +188,7 @@ mod tests { let translator = super::BitgetCommandTranslator::<'S'> {}; let commands = translator.translate_to_candlestick_commands( true, - &vec![("BTCUSDT".to_string(), 60), ("ETHUSDT".to_string(), 300)], + &[("BTCUSDT".to_string(), 60), ("ETHUSDT".to_string(), 300)], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bithumb.rs b/crypto-ws-client/src/clients/bithumb.rs index 6e6ec308..373164e2 100644 --- a/crypto-ws-client/src/clients/bithumb.rs +++ b/crypto-ws-client/src/clients/bithumb.rs @@ -131,10 +131,8 @@ mod tests { let translator = super::BithumbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("TRADE".to_string(), "BTC-USDT".to_string()), - ("TRADE".to_string(), "ETH-USDT".to_string()), - ], + &[("TRADE".to_string(), "BTC-USDT".to_string()), + ("TRADE".to_string(), "ETH-USDT".to_string())], ); assert_eq!(1, commands.len()); @@ -149,10 +147,8 @@ mod tests { let translator = super::BithumbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("TRADE".to_string(), "BTC-USDT".to_string()), - ("ORDERBOOK".to_string(), "BTC-USDT".to_string()), - ], + &[("TRADE".to_string(), "BTC-USDT".to_string()), + ("ORDERBOOK".to_string(), "BTC-USDT".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bitmex.rs b/crypto-ws-client/src/clients/bitmex.rs index f4d03d29..a3de3b3e 100644 --- a/crypto-ws-client/src/clients/bitmex.rs +++ b/crypto-ws-client/src/clients/bitmex.rs @@ -178,7 +178,7 @@ mod tests { fn test_one_topic() { let translator = super::BitmexCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("trade".to_string(), "XBTUSD".to_string())]); + .translate_to_commands(true, &[("trade".to_string(), "XBTUSD".to_string())]); assert_eq!(1, commands.len()); assert_eq!(r#"{"op":"subscribe","args":["trade:XBTUSD"]}"#, commands[0]); @@ -189,12 +189,10 @@ mod tests { let translator = super::BitmexCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trade".to_string(), "XBTUSD".to_string()), + &[("trade".to_string(), "XBTUSD".to_string()), ("quote".to_string(), "XBTUSD".to_string()), ("orderBookL2_25".to_string(), "XBTUSD".to_string()), - ("tradeBin1m".to_string(), "XBTUSD".to_string()), - ], + ("tradeBin1m".to_string(), "XBTUSD".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bitstamp.rs b/crypto-ws-client/src/clients/bitstamp.rs index 02398a16..40b4f405 100644 --- a/crypto-ws-client/src/clients/bitstamp.rs +++ b/crypto-ws-client/src/clients/bitstamp.rs @@ -133,7 +133,7 @@ mod tests { let translator = super::BitstampCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![("live_trades".to_string(), "btcusd".to_string())], + &[("live_trades".to_string(), "btcusd".to_string())], ); assert_eq!(1, commands.len()); @@ -148,10 +148,8 @@ mod tests { let translator = super::BitstampCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("live_trades".to_string(), "btcusd".to_string()), - ("diff_order_book".to_string(), "btcusd".to_string()), - ], + &[("live_trades".to_string(), "btcusd".to_string()), + ("diff_order_book".to_string(), "btcusd".to_string())], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/bybit/utils.rs b/crypto-ws-client/src/clients/bybit/utils.rs index bad0ffab..732fbeb6 100644 --- a/crypto-ws-client/src/clients/bybit/utils.rs +++ b/crypto-ws-client/src/clients/bybit/utils.rs @@ -65,18 +65,16 @@ mod tests { #[test] fn test_one_channel() { let command = - super::topics_to_command(&vec![("trade".to_string(), "BTCUSD".to_string())], true); + super::topics_to_command(&[("trade".to_string(), "BTCUSD".to_string())], true); assert_eq!(r#"{"op":"subscribe","args":["trade.BTCUSD"]}"#, command); } #[test] fn test_multiple_channels() { let command = super::topics_to_command( - &vec![ - ("trade".to_string(), "BTCUSD".to_string()), + &[("trade".to_string(), "BTCUSD".to_string()), ("orderBookL2_25".to_string(), "BTCUSD".to_string()), - ("instrument_info.100ms".to_string(), "BTCUSD".to_string()), - ], + ("instrument_info.100ms".to_string(), "BTCUSD".to_string())], true, ); diff --git a/crypto-ws-client/src/clients/coinbase_pro.rs b/crypto-ws-client/src/clients/coinbase_pro.rs index 662d1b9b..7b1a7f88 100644 --- a/crypto-ws-client/src/clients/coinbase_pro.rs +++ b/crypto-ws-client/src/clients/coinbase_pro.rs @@ -162,10 +162,8 @@ mod tests { let translator = super::CoinbaseProCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("matches".to_string(), "BTC-USD".to_string()), - ("matches".to_string(), "ETH-USD".to_string()), - ], + &[("matches".to_string(), "BTC-USD".to_string()), + ("matches".to_string(), "ETH-USD".to_string())], ); assert_eq!(1, commands.len()); @@ -180,10 +178,8 @@ mod tests { let translator = super::CoinbaseProCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("matches".to_string(), "BTC-USD".to_string()), - ("level2".to_string(), "BTC-USD".to_string()), - ], + &[("matches".to_string(), "BTC-USD".to_string()), + ("level2".to_string(), "BTC-USD".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/deribit.rs b/crypto-ws-client/src/clients/deribit.rs index 3e076570..cbf814f1 100644 --- a/crypto-ws-client/src/clients/deribit.rs +++ b/crypto-ws-client/src/clients/deribit.rs @@ -187,7 +187,7 @@ mod tests { let translator = super::DeribitCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![("trades.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string())], + &[("trades.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string())], ); assert_eq!(2, commands.len()); @@ -206,10 +206,8 @@ mod tests { let translator = super::DeribitCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trades.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string()), - ("ticker.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string()), - ], + &[("trades.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string()), + ("ticker.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string())], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/dydx/dydx_swap.rs b/crypto-ws-client/src/clients/dydx/dydx_swap.rs index 38775bbd..cd4ca176 100644 --- a/crypto-ws-client/src/clients/dydx/dydx_swap.rs +++ b/crypto-ws-client/src/clients/dydx/dydx_swap.rs @@ -133,7 +133,7 @@ mod tests { let translator = super::DydxCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![("v3_trades".to_string(), "BTC-USD".to_string())], + &[("v3_trades".to_string(), "BTC-USD".to_string())], ); assert_eq!(1, commands.len()); @@ -148,10 +148,8 @@ mod tests { let translator = super::DydxCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("v3_trades".to_string(), "BTC-USD".to_string()), - ("v3_orderbook".to_string(), "BTC-USD".to_string()), - ], + &[("v3_trades".to_string(), "BTC-USD".to_string()), + ("v3_orderbook".to_string(), "BTC-USD".to_string())], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/ftx.rs b/crypto-ws-client/src/clients/ftx.rs index 71365086..79796a0c 100644 --- a/crypto-ws-client/src/clients/ftx.rs +++ b/crypto-ws-client/src/clients/ftx.rs @@ -128,7 +128,7 @@ mod tests { fn test_one_topic() { let translator = super::FtxCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("trades".to_string(), "BTC/USD".to_string())]); + .translate_to_commands(true, &[("trades".to_string(), "BTC/USD".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -142,10 +142,8 @@ mod tests { let translator = super::FtxCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trades".to_string(), "BTC/USD".to_string()), - ("orderbook".to_string(), "BTC/USD".to_string()), - ], + &[("trades".to_string(), "BTC/USD".to_string()), + ("orderbook".to_string(), "BTC/USD".to_string())], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/gate/utils.rs b/crypto-ws-client/src/clients/gate/utils.rs index 80dc43ac..56296375 100644 --- a/crypto-ws-client/src/clients/gate/utils.rs +++ b/crypto-ws-client/src/clients/gate/utils.rs @@ -214,19 +214,15 @@ mod tests { r#"{"channel":"spot.trades", "event":"subscribe", "payload":["BTC_USDT","ETH_USDT"]}"#, translator.translate_to_commands( true, - &vec![ - ("trades".to_string(), "BTC_USDT".to_string()), - ("trades".to_string(), "ETH_USDT".to_string()) - ] + &[("trades".to_string(), "BTC_USDT".to_string()), + ("trades".to_string(), "ETH_USDT".to_string())] )[0] ); let commands = translator.translate_to_commands( true, - &vec![ - ("order_book".to_string(), "BTC_USDT".to_string()), - ("order_book".to_string(), "ETH_USDT".to_string()), - ], + &[("order_book".to_string(), "BTC_USDT".to_string()), + ("order_book".to_string(), "ETH_USDT".to_string())], ); assert_eq!(2, commands.len()); assert_eq!( @@ -240,10 +236,8 @@ mod tests { let commands = translator.translate_to_commands( true, - &vec![ - ("order_book_update".to_string(), "BTC_USDT".to_string()), - ("order_book_update".to_string(), "ETH_USDT".to_string()), - ], + &[("order_book_update".to_string(), "BTC_USDT".to_string()), + ("order_book_update".to_string(), "ETH_USDT".to_string())], ); assert_eq!(2, commands.len()); assert_eq!( @@ -264,19 +258,15 @@ mod tests { r#"{"channel":"futures.trades", "event":"subscribe", "payload":["BTC_USD","ETH_USD"]}"#, translator.translate_to_commands( true, - &vec![ - ("trades".to_string(), "BTC_USD".to_string()), - ("trades".to_string(), "ETH_USD".to_string()) - ] + &[("trades".to_string(), "BTC_USD".to_string()), + ("trades".to_string(), "ETH_USD".to_string())] )[0] ); let commands = translator.translate_to_commands( true, - &vec![ - ("order_book".to_string(), "BTC_USD".to_string()), - ("order_book".to_string(), "ETH_USD".to_string()), - ], + &[("order_book".to_string(), "BTC_USD".to_string()), + ("order_book".to_string(), "ETH_USD".to_string())], ); assert_eq!(2, commands.len()); assert_eq!( @@ -290,10 +280,8 @@ mod tests { let commands = translator.translate_to_commands( true, - &vec![ - ("order_book_update".to_string(), "BTC_USD".to_string()), - ("order_book_update".to_string(), "ETH_USD".to_string()), - ], + &[("order_book_update".to_string(), "BTC_USD".to_string()), + ("order_book_update".to_string(), "ETH_USD".to_string())], ); assert_eq!(2, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/huobi.rs b/crypto-ws-client/src/clients/huobi.rs index 218bb687..ac4bcf58 100644 --- a/crypto-ws-client/src/clients/huobi.rs +++ b/crypto-ws-client/src/clients/huobi.rs @@ -335,7 +335,7 @@ mod tests { let translator = super::HuobiCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![("trade.detail".to_string(), "btcusdt".to_string())], + &[("trade.detail".to_string(), "btcusdt".to_string())], ); assert_eq!(1, commands.len()); @@ -350,10 +350,8 @@ mod tests { let translator = super::HuobiCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trade.detail".to_string(), "btcusdt".to_string()), - ("bbo".to_string(), "btcusdt".to_string()), - ], + &[("trade.detail".to_string(), "btcusdt".to_string()), + ("bbo".to_string(), "btcusdt".to_string())], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/kraken/kraken_futures.rs b/crypto-ws-client/src/clients/kraken/kraken_futures.rs index a1078c82..677e2620 100644 --- a/crypto-ws-client/src/clients/kraken/kraken_futures.rs +++ b/crypto-ws-client/src/clients/kraken/kraken_futures.rs @@ -151,7 +151,7 @@ mod tests { fn test_one_symbol() { let translator = super::KrakenCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("trade".to_string(), "PI_XBTUSD".to_string())]); + .translate_to_commands(true, &[("trade".to_string(), "PI_XBTUSD".to_string())]); assert_eq!(2, commands.len()); assert_eq!( @@ -166,10 +166,8 @@ mod tests { let translator = super::KrakenCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trade".to_string(), "PI_XBTUSD".to_string()), - ("trade".to_string(), "PI_ETHUSD".to_string()), - ], + &[("trade".to_string(), "PI_XBTUSD".to_string()), + ("trade".to_string(), "PI_ETHUSD".to_string())], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/kraken/kraken_spot.rs b/crypto-ws-client/src/clients/kraken/kraken_spot.rs index ba8610d7..57c3a53d 100644 --- a/crypto-ws-client/src/clients/kraken/kraken_spot.rs +++ b/crypto-ws-client/src/clients/kraken/kraken_spot.rs @@ -251,7 +251,7 @@ mod tests { fn test_one_symbol() { let translator = super::KrakenCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("trade".to_string(), "XBT/USD".to_string())]); + .translate_to_commands(true, &[("trade".to_string(), "XBT/USD".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -265,10 +265,8 @@ mod tests { let translator = super::KrakenCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trade".to_string(), "XBT/USD".to_string()), - ("trade".to_string(), "ETH/USD".to_string()), - ], + &[("trade".to_string(), "XBT/USD".to_string()), + ("trade".to_string(), "ETH/USD".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs b/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs index aa095901..8ea44245 100644 --- a/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs +++ b/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs @@ -121,7 +121,7 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![("/market/match".to_string(), "BTC-USDT".to_string())], + &[("/market/match".to_string(), "BTC-USDT".to_string())], ); assert_eq!(1, commands.len()); @@ -132,10 +132,8 @@ mod tests { let commands = translator.translate_to_commands( true, - &vec![ - ("/market/match".to_string(), "BTC-USDT".to_string()), - ("/market/match".to_string(), "ETH-USDT".to_string()), - ], + &[("/market/match".to_string(), "BTC-USDT".to_string()), + ("/market/match".to_string(), "ETH-USDT".to_string())], ); assert_eq!(1, commands.len()); @@ -150,10 +148,8 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("/market/match".to_string(), "BTC-USDT".to_string()), - ("/market/level2".to_string(), "ETH-USDT".to_string()), - ], + &[("/market/match".to_string(), "BTC-USDT".to_string()), + ("/market/level2".to_string(), "ETH-USDT".to_string())], ); assert_eq!(2, commands.len()); @@ -168,12 +164,10 @@ mod tests { let commands = translator.translate_to_commands( true, - &vec![ - ("/market/match".to_string(), "BTC-USDT".to_string()), + &[("/market/match".to_string(), "BTC-USDT".to_string()), ("/market/match".to_string(), "ETH-USDT".to_string()), ("/market/level2".to_string(), "BTC-USDT".to_string()), - ("/market/level2".to_string(), "ETH-USDT".to_string()), - ], + ("/market/level2".to_string(), "ETH-USDT".to_string())], ); assert_eq!(2, commands.len()); @@ -192,7 +186,7 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_candlestick_commands( true, - &vec![("BTC-USDT".to_string(), 180), ("ETH-USDT".to_string(), 60)], + &[("BTC-USDT".to_string(), 180), ("ETH-USDT".to_string(), 60)], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs b/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs index 4add7161..eff0a5a5 100644 --- a/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs +++ b/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs @@ -117,7 +117,7 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![( + &[( "/contractMarket/execution".to_string(), "BTC_USD".to_string(), )], @@ -131,16 +131,14 @@ mod tests { let commands = translator.translate_to_commands( true, - &vec![ - ( + &[( "/contractMarket/execution".to_string(), "BTC_USD".to_string(), ), ( "/contractMarket/execution".to_string(), "ETH_USD".to_string(), - ), - ], + )], ); assert_eq!(1, commands.len()); @@ -155,13 +153,11 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ( + &[( "/contractMarket/execution".to_string(), "BTC_USD".to_string(), ), - ("/contractMarket/level2".to_string(), "ETH_USD".to_string()), - ], + ("/contractMarket/level2".to_string(), "ETH_USD".to_string())], ); assert_eq!(2, commands.len()); @@ -176,8 +172,7 @@ mod tests { let commands = translator.translate_to_commands( true, - &vec![ - ( + &[( "/contractMarket/execution".to_string(), "BTC_USD".to_string(), ), @@ -186,8 +181,7 @@ mod tests { "ETH_USD".to_string(), ), ("/contractMarket/level2".to_string(), "BTC_USD".to_string()), - ("/contractMarket/level2".to_string(), "ETH_USD".to_string()), - ], + ("/contractMarket/level2".to_string(), "ETH_USD".to_string())], ); assert_eq!(2, commands.len()); @@ -206,7 +200,7 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_candlestick_commands( true, - &vec![("BTC_USD".to_string(), 300), ("ETH_USD".to_string(), 60)], + &[("BTC_USD".to_string(), 300), ("ETH_USD".to_string(), 60)], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/kucoin/utils.rs b/crypto-ws-client/src/clients/kucoin/utils.rs index fad16a28..0fd75349 100644 --- a/crypto-ws-client/src/clients/kucoin/utils.rs +++ b/crypto-ws-client/src/clients/kucoin/utils.rs @@ -165,7 +165,7 @@ mod tests { #[test] fn test_topics_to_commands() { let commands = super::topics_to_commands( - &vec![("/market/match".to_string(), "BTC-USDT".to_string())], + &[("/market/match".to_string(), "BTC-USDT".to_string())], true, ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/mexc/mexc_spot.rs b/crypto-ws-client/src/clients/mexc/mexc_spot.rs index c635b71e..5cf2a95e 100644 --- a/crypto-ws-client/src/clients/mexc/mexc_spot.rs +++ b/crypto-ws-client/src/clients/mexc/mexc_spot.rs @@ -167,7 +167,7 @@ mod tests { fn test_one_topic() { let translator = super::MexcCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("deal".to_string(), "BTC_USDT".to_string())]); + .translate_to_commands(true, &[("deal".to_string(), "BTC_USDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!(r#"{"op":"sub.deal","symbol":"BTC_USDT"}"#, commands[0]); @@ -178,10 +178,8 @@ mod tests { let translator = super::MexcCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("deal".to_string(), "BTC_USDT".to_string()), - ("depth".to_string(), "ETH_USDT".to_string()), - ], + &[("deal".to_string(), "BTC_USDT".to_string()), + ("depth".to_string(), "ETH_USDT".to_string())], ); assert_eq!(2, commands.len()); @@ -193,7 +191,7 @@ mod tests { fn test_candlestick() { let translator = super::MexcCommandTranslator {}; let commands = - translator.translate_to_candlestick_commands(true, &vec![("BTC_USDT".to_string(), 60)]); + translator.translate_to_candlestick_commands(true, &[("BTC_USDT".to_string(), 60)]); assert_eq!(1, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/mexc/mexc_swap.rs b/crypto-ws-client/src/clients/mexc/mexc_swap.rs index 8b8ee209..79d19f34 100644 --- a/crypto-ws-client/src/clients/mexc/mexc_swap.rs +++ b/crypto-ws-client/src/clients/mexc/mexc_swap.rs @@ -154,7 +154,7 @@ mod tests { fn test_one_topic() { let translator = super::MexcCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("deal".to_string(), "BTC_USDT".to_string())]); + .translate_to_commands(true, &[("deal".to_string(), "BTC_USDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -168,10 +168,8 @@ mod tests { let translator = super::MexcCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("deal".to_string(), "BTC_USDT".to_string()), - ("depth".to_string(), "ETH_USDT".to_string()), - ], + &[("deal".to_string(), "BTC_USDT".to_string()), + ("depth".to_string(), "ETH_USDT".to_string())], ); assert_eq!(2, commands.len()); @@ -189,7 +187,7 @@ mod tests { fn test_candlestick() { let translator = super::MexcCommandTranslator {}; let commands = - translator.translate_to_candlestick_commands(true, &vec![("BTC_USDT".to_string(), 60)]); + translator.translate_to_candlestick_commands(true, &[("BTC_USDT".to_string(), 60)]); assert_eq!(1, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/okx.rs b/crypto-ws-client/src/clients/okx.rs index d89d9235..9d4fde7c 100644 --- a/crypto-ws-client/src/clients/okx.rs +++ b/crypto-ws-client/src/clients/okx.rs @@ -217,7 +217,7 @@ mod tests { fn test_one_topic() { let translator = super::OkxCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("trades".to_string(), "BTC-USDT".to_string())]); + .translate_to_commands(true, &[("trades".to_string(), "BTC-USDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -231,10 +231,8 @@ mod tests { let translator = super::OkxCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trades".to_string(), "BTC-USDT".to_string()), - ("tickers".to_string(), "BTC-USDT".to_string()), - ], + &[("trades".to_string(), "BTC-USDT".to_string()), + ("tickers".to_string(), "BTC-USDT".to_string())], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/zb/zb_spot.rs b/crypto-ws-client/src/clients/zb/zb_spot.rs index b04fb5e9..2e2fc481 100644 --- a/crypto-ws-client/src/clients/zb/zb_spot.rs +++ b/crypto-ws-client/src/clients/zb/zb_spot.rs @@ -157,7 +157,7 @@ mod tests { async fn test_one_topic() { let translator = super::ZbCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("trades".to_string(), "btc_usdt".to_string())]); + .translate_to_commands(true, &[("trades".to_string(), "btc_usdt".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -171,10 +171,8 @@ mod tests { let translator = super::ZbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("trades".to_string(), "btc_usdt".to_string()), - ("depth".to_string(), "eth_usdt".to_string()), - ], + &[("trades".to_string(), "btc_usdt".to_string()), + ("depth".to_string(), "eth_usdt".to_string())], ); assert_eq!(2, commands.len()); @@ -192,7 +190,7 @@ mod tests { async fn test_candlestick() { let translator = super::ZbCommandTranslator {}; let commands = - translator.translate_to_candlestick_commands(true, &vec![("btc_usdt".to_string(), 60)]); + translator.translate_to_candlestick_commands(true, &[("btc_usdt".to_string(), 60)]); assert_eq!(1, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/zb/zb_swap.rs b/crypto-ws-client/src/clients/zb/zb_swap.rs index 3f5ddaf9..85255652 100644 --- a/crypto-ws-client/src/clients/zb/zb_swap.rs +++ b/crypto-ws-client/src/clients/zb/zb_swap.rs @@ -178,7 +178,7 @@ mod tests { async fn test_one_topic() { let translator = super::ZbCommandTranslator {}; let commands = translator - .translate_to_commands(true, &vec![("Trade".to_string(), "BTC_USDT".to_string())]); + .translate_to_commands(true, &[("Trade".to_string(), "BTC_USDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -192,10 +192,8 @@ mod tests { let translator = super::ZbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &vec![ - ("Trade".to_string(), "BTC_USDT".to_string()), - ("Depth".to_string(), "ETH_USDT".to_string()), - ], + &[("Trade".to_string(), "BTC_USDT".to_string()), + ("Depth".to_string(), "ETH_USDT".to_string())], ); assert_eq!(2, commands.len()); @@ -213,7 +211,7 @@ mod tests { async fn test_candlestick() { let translator = super::ZbCommandTranslator {}; let commands = - translator.translate_to_candlestick_commands(true, &vec![("BTC_USDT".to_string(), 60)]); + translator.translate_to_candlestick_commands(true, &[("BTC_USDT".to_string(), 60)]); assert_eq!(1, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/zbg/zbg_spot.rs b/crypto-ws-client/src/clients/zbg/zbg_spot.rs index d68e6b35..c30e8bf3 100644 --- a/crypto-ws-client/src/clients/zbg/zbg_spot.rs +++ b/crypto-ws-client/src/clients/zbg/zbg_spot.rs @@ -153,7 +153,7 @@ mod tests { async fn test_one_topic() { let translator = super::ZbgCommandTranslator::new().await; let commands = translator - .translate_to_commands(true, &vec![("TRADE".to_string(), "btc_usdt".to_string())]); + .translate_to_commands(true, &[("TRADE".to_string(), "btc_usdt".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -167,10 +167,8 @@ mod tests { let translator = super::ZbgCommandTranslator::new().await; let commands = translator.translate_to_commands( true, - &vec![ - ("TRADE".to_string(), "btc_usdt".to_string()), - ("ENTRUST_ADD".to_string(), "eth_usdt".to_string()), - ], + &[("TRADE".to_string(), "btc_usdt".to_string()), + ("ENTRUST_ADD".to_string(), "eth_usdt".to_string())], ); assert_eq!(2, commands.len()); @@ -188,7 +186,7 @@ mod tests { async fn test_candlestick() { let translator = super::ZbgCommandTranslator::new().await; let commands = - translator.translate_to_candlestick_commands(true, &vec![("btc_usdt".to_string(), 60)]); + translator.translate_to_candlestick_commands(true, &[("btc_usdt".to_string(), 60)]); assert_eq!(1, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/zbg/zbg_swap.rs b/crypto-ws-client/src/clients/zbg/zbg_swap.rs index c2d3b277..bfc8ff80 100644 --- a/crypto-ws-client/src/clients/zbg/zbg_swap.rs +++ b/crypto-ws-client/src/clients/zbg/zbg_swap.rs @@ -151,7 +151,7 @@ mod tests { let translator = super::ZbgCommandTranslator::new().await; let commands = translator.translate_to_commands( true, - &vec![("future_tick".to_string(), "BTC_USDT".to_string())], + &[("future_tick".to_string(), "BTC_USDT".to_string())], ); assert_eq!(1, commands.len()); @@ -166,10 +166,8 @@ mod tests { let translator = super::ZbgCommandTranslator::new().await; let commands = translator.translate_to_commands( true, - &vec![ - ("future_tick".to_string(), "BTC_USDT".to_string()), - ("future_snapshot_depth".to_string(), "ETH_USDT".to_string()), - ], + &[("future_tick".to_string(), "BTC_USDT".to_string()), + ("future_snapshot_depth".to_string(), "ETH_USDT".to_string())], ); assert_eq!(2, commands.len()); @@ -187,7 +185,7 @@ mod tests { async fn test_candlestick() { let translator = super::ZbgCommandTranslator::new().await; let commands = - translator.translate_to_candlestick_commands(true, &vec![("BTC_USDT".to_string(), 60)]); + translator.translate_to_candlestick_commands(true, &[("BTC_USDT".to_string(), 60)]); assert_eq!(1, commands.len()); assert_eq!( diff --git a/crypto-ws-client/tests/binance.rs b/crypto-ws-client/tests/binance.rs index 77f8842b..b11ac421 100644 --- a/crypto-ws-client/tests/binance.rs +++ b/crypto-ws-client/tests/binance.rs @@ -10,10 +10,8 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, subscribe, - &vec![ - ("aggTrade".to_string(), "BTCUSDT".to_string()), - ("ticker".to_string(), "BTCUSDT".to_string()) - ] + &[("aggTrade".to_string(), "BTCUSDT".to_string()), + ("ticker".to_string(), "BTCUSDT".to_string())] ); } @@ -22,7 +20,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] ); } @@ -31,7 +29,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["btcusdt@aggTrade","btcusdt@ticker"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["btcusdt@aggTrade","btcusdt@ticker"]}"#.to_string()] ); } @@ -40,7 +38,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, subscribe_trade, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -49,7 +47,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, subscribe_ticker, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -58,7 +56,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] ); } @@ -67,7 +65,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, subscribe_bbo, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -76,7 +74,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, subscribe_orderbook, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -85,7 +83,7 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, subscribe_orderbook_topk, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -93,14 +91,12 @@ mod binance_spot { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceSpotWSClient, - &vec![("BTCUSDT".to_string(), 60), ("ETHUSDT".to_string(), 60)] + &[("BTCUSDT".to_string(), 60), ("ETHUSDT".to_string(), 60)] ); gen_test_subscribe_candlestick!( BinanceSpotWSClient, - &vec![ - ("BTCUSDT".to_string(), 2592000), - ("ETHUSDT".to_string(), 2592000) - ] + &[("BTCUSDT".to_string(), 2592000), + ("ETHUSDT".to_string(), 2592000)] ); } } @@ -114,11 +110,9 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe, - &vec![ - ("aggTrade".to_string(), "BTCUSD_220930".to_string()), + &[("aggTrade".to_string(), "BTCUSD_220930".to_string()), ("aggTrade".to_string(), "ETHUSD_220930".to_string()), - ("aggTrade".to_string(), "BNBUSD_220930".to_string()) - ] + ("aggTrade".to_string(), "BNBUSD_220930".to_string())] ); } @@ -127,7 +121,7 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] ); } @@ -136,11 +130,9 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_trade, - &vec![ - "BTCUSD_220930".to_string(), + &["BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string(), - ] + "BNBUSD_220930".to_string()] ); } @@ -149,11 +141,9 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_ticker, - &vec![ - "BTCUSD_220930".to_string(), + &["BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string(), - ] + "BNBUSD_220930".to_string()] ); } @@ -162,7 +152,7 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] ); } @@ -171,11 +161,9 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_bbo, - &vec![ - "BTCUSD_220930".to_string(), + &["BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string(), - ] + "BNBUSD_220930".to_string()] ); } @@ -184,11 +172,9 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_orderbook, - &vec![ - "BTCUSD_220930".to_string(), + &["BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string(), - ] + "BNBUSD_220930".to_string()] ); } @@ -197,11 +183,9 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_orderbook_topk, - &vec![ - "BTCUSD_220930".to_string(), + &["BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string(), - ] + "BNBUSD_220930".to_string()] ); } @@ -209,19 +193,15 @@ mod binance_inverse_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &vec![ - ("BTCUSD_220930".to_string(), 60), + &[("BTCUSD_220930".to_string(), 60), ("ETHUSD_220930".to_string(), 60), - ("BNBUSD_220930".to_string(), 60) - ] + ("BNBUSD_220930".to_string(), 60)] ); gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &vec![ - ("BTCUSD_220930".to_string(), 2592000), + &[("BTCUSD_220930".to_string(), 2592000), ("ETHUSD_220930".to_string(), 2592000), - ("BNBUSD_220930".to_string(), 2592000) - ] + ("BNBUSD_220930".to_string(), 2592000)] ); } } @@ -235,10 +215,8 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, subscribe, - &vec![ - ("aggTrade".to_string(), "BTCUSDT_220930".to_string()), - ("aggTrade".to_string(), "ETHUSDT_220930".to_string()), - ] + &[("aggTrade".to_string(), "BTCUSDT_220930".to_string()), + ("aggTrade".to_string(), "ETHUSDT_220930".to_string())] ); } @@ -247,7 +225,7 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] ); } @@ -256,7 +234,7 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, subscribe_trade, - &vec!["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] + &["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] ); } @@ -265,7 +243,7 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, subscribe_ticker, - &vec!["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] + &["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] ); } @@ -274,7 +252,7 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] ); } @@ -283,7 +261,7 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, subscribe_bbo, - &vec!["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] + &["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] ); } @@ -292,7 +270,7 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, subscribe_orderbook, - &vec!["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] + &["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] ); } @@ -301,7 +279,7 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, subscribe_orderbook_topk, - &vec!["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] + &["BTCUSDT_220930".to_string(), "ETHUSDT_220930".to_string()] ); } @@ -309,17 +287,13 @@ mod binance_linear_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceLinearWSClient, - &vec![ - ("BTCUSDT_220930".to_string(), 60), - ("ETHUSDT_220930".to_string(), 60) - ] + &[("BTCUSDT_220930".to_string(), 60), + ("ETHUSDT_220930".to_string(), 60)] ); gen_test_subscribe_candlestick!( BinanceLinearWSClient, - &vec![ - ("BTCUSDT_220930".to_string(), 2592000), - ("ETHUSDT_220930".to_string(), 2592000) - ] + &[("BTCUSDT_220930".to_string(), 2592000), + ("ETHUSDT_220930".to_string(), 2592000)] ); } } @@ -333,7 +307,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, subscribe, - &vec![("aggTrade".to_string(), "btcusd_perp".to_string())] + &[("aggTrade".to_string(), "btcusd_perp".to_string())] ); } @@ -342,7 +316,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] ); } @@ -351,7 +325,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, subscribe_trade, - &vec!["btcusd_perp".to_string(), "ethusd_perp".to_string()] + &["btcusd_perp".to_string(), "ethusd_perp".to_string()] ); } @@ -360,7 +334,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, subscribe_ticker, - &vec!["btcusd_perp".to_string(), "ethusd_perp".to_string()] + &["btcusd_perp".to_string(), "ethusd_perp".to_string()] ); } @@ -369,7 +343,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] ); } @@ -378,7 +352,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, subscribe_bbo, - &vec!["btcusd_perp".to_string(), "ethusd_perp".to_string()] + &["btcusd_perp".to_string(), "ethusd_perp".to_string()] ); } @@ -387,7 +361,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, subscribe_orderbook, - &vec!["btcusd_perp".to_string(), "ethusd_perp".to_string()] + &["btcusd_perp".to_string(), "ethusd_perp".to_string()] ); } @@ -396,7 +370,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, subscribe_orderbook_topk, - &vec!["btcusd_perp".to_string(), "ethusd_perp".to_string()] + &["btcusd_perp".to_string(), "ethusd_perp".to_string()] ); } @@ -404,17 +378,13 @@ mod binance_inverse_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &vec![ - ("btcusd_perp".to_string(), 60), - ("ethusd_perp".to_string(), 60) - ] + &[("btcusd_perp".to_string(), 60), + ("ethusd_perp".to_string(), 60)] ); gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &vec![ - ("btcusd_perp".to_string(), 2592000), - ("ethusd_perp".to_string(), 2592000) - ] + &[("btcusd_perp".to_string(), 2592000), + ("ethusd_perp".to_string(), 2592000)] ); } @@ -423,7 +393,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, subscribe, - &vec![("markPrice".to_string(), "btcusd_perp".to_string())] + &[("markPrice".to_string(), "btcusd_perp".to_string())] ); } @@ -432,7 +402,7 @@ mod binance_inverse_swap { gen_test_code!( BinanceInverseWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!markPrice@arr"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!markPrice@arr"]}"#.to_string()] ); } } @@ -446,7 +416,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, subscribe, - &vec![("aggTrade".to_string(), "BTCUSDT".to_string())] + &[("aggTrade".to_string(), "BTCUSDT".to_string())] ); } @@ -455,7 +425,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!bookTicker"]}"#.to_string()] ); } @@ -464,7 +434,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, subscribe_trade, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -473,7 +443,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, subscribe_ticker, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -482,7 +452,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!ticker@arr"]}"#.to_string()] ); } @@ -491,7 +461,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, subscribe_bbo, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -500,7 +470,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, subscribe_orderbook, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -509,7 +479,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, subscribe_orderbook_topk, - &vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()] + &["BTCUSDT".to_string(), "ETHUSDT".to_string()] ); } @@ -517,14 +487,12 @@ mod binance_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceLinearWSClient, - &vec![("BTCUSDT".to_string(), 60), ("ETHUSDT".to_string(), 60)] + &[("BTCUSDT".to_string(), 60), ("ETHUSDT".to_string(), 60)] ); gen_test_subscribe_candlestick!( BinanceLinearWSClient, - &vec![ - ("BTCUSDT".to_string(), 2592000), - ("ETHUSDT".to_string(), 2592000) - ] + &[("BTCUSDT".to_string(), 2592000), + ("ETHUSDT".to_string(), 2592000)] ); } @@ -533,7 +501,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, subscribe, - &vec![("markPrice".to_string(), "BTCUSDT".to_string())] + &[("markPrice".to_string(), "BTCUSDT".to_string())] ); } @@ -542,7 +510,7 @@ mod binance_linear_swap { gen_test_code!( BinanceLinearWSClient, send, - &vec![r#"{"id":9527,"method":"SUBSCRIBE","params":["!markPrice@arr"]}"#.to_string()] + &[r#"{"id":9527,"method":"SUBSCRIBE","params":["!markPrice@arr"]}"#.to_string()] ); } } diff --git a/crypto-ws-client/tests/binance_option.rs b/crypto-ws-client/tests/binance_option.rs index 270d65a0..f3abc753 100644 --- a/crypto-ws-client/tests/binance_option.rs +++ b/crypto-ws-client/tests/binance_option.rs @@ -9,11 +9,9 @@ async fn subscribe() { gen_test_code!( BinanceOptionWSClient, subscribe, - &vec![ - ("TICKER_ALL".to_string(), "BTCUSDT".to_string()), + &[("TICKER_ALL".to_string(), "BTCUSDT".to_string()), ("TRADE_ALL".to_string(), "BTCUSDT_C".to_string()), - ("TRADE_ALL".to_string(), "BTCUSDT_P".to_string()) - ] + ("TRADE_ALL".to_string(), "BTCUSDT_P".to_string())] ); } @@ -23,10 +21,8 @@ async fn subscribe_trade() { gen_test_code!( BinanceOptionWSClient, subscribe_trade, - &vec![ - "BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string() - ] + &["BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string()] ); } @@ -36,10 +32,8 @@ async fn subscribe_ticker() { gen_test_code!( BinanceOptionWSClient, subscribe_ticker, - &vec![ - "BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string() - ] + &["BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string()] ); } @@ -49,7 +43,7 @@ async fn subscribe_ticker_all() { gen_test_code!( BinanceOptionWSClient, subscribe, - &vec![("TICKER_ALL".to_string(), "BTCUSDT".to_string())] + &[("TICKER_ALL".to_string(), "BTCUSDT".to_string())] ); } @@ -59,10 +53,8 @@ async fn subscribe_orderbook() { gen_test_code!( BinanceOptionWSClient, subscribe_orderbook, - &vec![ - "BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string() - ] + &["BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string()] ); } @@ -72,10 +64,8 @@ async fn subscribe_orderbook_topk() { gen_test_code!( BinanceOptionWSClient, subscribe_orderbook_topk, - &vec![ - "BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string() - ] + &["BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string()] ); } @@ -84,16 +74,12 @@ async fn subscribe_orderbook_topk() { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceOptionWSClient, - &vec![ - ("BTC-220325-40000-C".to_string(), 60), - ("BTC-220325-35000-P".to_string(), 60), - ] + &[("BTC-220325-40000-C".to_string(), 60), + ("BTC-220325-35000-P".to_string(), 60)] ); gen_test_subscribe_candlestick!( BinanceOptionWSClient, - &vec![ - ("BTC-220325-40000-C".to_string(), 60), - ("BTC-220325-35000-P".to_string(), 60), - ] + &[("BTC-220325-40000-C".to_string(), 60), + ("BTC-220325-35000-P".to_string(), 60)] ); } diff --git a/crypto-ws-client/tests/bitfinex.rs b/crypto-ws-client/tests/bitfinex.rs index e12ee9ec..6ce1edd8 100644 --- a/crypto-ws-client/tests/bitfinex.rs +++ b/crypto-ws-client/tests/bitfinex.rs @@ -10,10 +10,8 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe, - &vec![ - ("trades".to_string(), "tBTCUST".to_string()), - ("trades".to_string(), "tETHUST".to_string()), - ] + &[("trades".to_string(), "tBTCUST".to_string()), + ("trades".to_string(), "tETHUST".to_string())] ); } @@ -23,7 +21,7 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe, - &vec![("trades".to_string(), "tXXXYYY".to_string())] + &[("trades".to_string(), "tXXXYYY".to_string())] ); } @@ -32,7 +30,7 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe_trade, - &vec!["tBTCUST".to_string(), "tETHUST".to_string()] + &["tBTCUST".to_string(), "tETHUST".to_string()] ); } @@ -41,7 +39,7 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe_ticker, - &vec!["tBTCUST".to_string()] + &["tBTCUST".to_string()] ); } @@ -50,7 +48,7 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe_bbo, - &vec!["tBTCUST".to_string()] + &["tBTCUST".to_string()] ); } @@ -59,7 +57,7 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe_orderbook, - &vec!["tBTCUST".to_string()] + &["tBTCUST".to_string()] ); } @@ -68,14 +66,14 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe_l3_orderbook, - &vec!["tBTCUST".to_string()] + &["tBTCUST".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitfinexWSClient, &vec![("tBTCUST".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitfinexWSClient, &vec![("tBTCUST".to_string(), 2592000)]); + gen_test_subscribe_candlestick!(BitfinexWSClient, &[("tBTCUST".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitfinexWSClient, &[("tBTCUST".to_string(), 2592000)]); } } @@ -88,7 +86,7 @@ mod bitfinex_swap { gen_test_code!( BitfinexWSClient, subscribe, - &vec![("trades".to_string(), "tBTCF0:USTF0".to_string())] + &[("trades".to_string(), "tBTCF0:USTF0".to_string())] ); } @@ -97,7 +95,7 @@ mod bitfinex_swap { gen_test_code!( BitfinexWSClient, subscribe_trade, - &vec!["tBTCF0:USTF0".to_string(), "tETHF0:USTF0".to_string()] + &["tBTCF0:USTF0".to_string(), "tETHF0:USTF0".to_string()] ); } @@ -106,7 +104,7 @@ mod bitfinex_swap { gen_test_code!( BitfinexWSClient, subscribe_ticker, - &vec!["tBTCF0:USTF0".to_string()] + &["tBTCF0:USTF0".to_string()] ); } @@ -115,7 +113,7 @@ mod bitfinex_swap { gen_test_code!( BitfinexWSClient, subscribe_bbo, - &vec!["tBTCF0:USTF0".to_string()] + &["tBTCF0:USTF0".to_string()] ); } @@ -124,7 +122,7 @@ mod bitfinex_swap { gen_test_code!( BitfinexWSClient, subscribe_orderbook, - &vec!["tBTCF0:USTF0".to_string()] + &["tBTCF0:USTF0".to_string()] ); } @@ -133,16 +131,16 @@ mod bitfinex_swap { gen_test_code!( BitfinexWSClient, subscribe_l3_orderbook, - &vec!["tBTCF0:USTF0".to_string(), "tETHF0:USTF0".to_string()] + &["tBTCF0:USTF0".to_string(), "tETHF0:USTF0".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitfinexWSClient, &vec![("tBTCF0:USTF0".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitfinexWSClient, &[("tBTCF0:USTF0".to_string(), 60)]); gen_test_subscribe_candlestick!( BitfinexWSClient, - &vec![("tBTCF0:USTF0".to_string(), 2592000)] + &[("tBTCF0:USTF0".to_string(), 2592000)] ); } } diff --git a/crypto-ws-client/tests/bitget.rs b/crypto-ws-client/tests/bitget.rs index 1fe6d0b5..aecd20cc 100644 --- a/crypto-ws-client/tests/bitget.rs +++ b/crypto-ws-client/tests/bitget.rs @@ -10,7 +10,7 @@ mod bitget_spot { gen_test_code!( BitgetSpotWSClient, subscribe_trade, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -19,7 +19,7 @@ mod bitget_spot { gen_test_code!( BitgetSpotWSClient, subscribe_orderbook_topk, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -28,7 +28,7 @@ mod bitget_spot { gen_test_code!( BitgetSpotWSClient, subscribe_orderbook, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -37,14 +37,14 @@ mod bitget_spot { gen_test_code!( BitgetSpotWSClient, subscribe_ticker, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitgetSpotWSClient, &vec![("BTCUSDT".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitgetSpotWSClient, &vec![("BTCUSDT".to_string(), 604800)]); + gen_test_subscribe_candlestick!(BitgetSpotWSClient, &[("BTCUSDT".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitgetSpotWSClient, &[("BTCUSDT".to_string(), 604800)]); } } @@ -57,7 +57,7 @@ mod bitget_inverse_swap { gen_test_code!( BitgetSwapWSClient, subscribe, - &vec![("trade".to_string(), "BTCUSD".to_string())] + &[("trade".to_string(), "BTCUSD".to_string())] ); } @@ -66,7 +66,7 @@ mod bitget_inverse_swap { gen_test_code!( BitgetSwapWSClient, send, - &vec![r#"{"op":"subscribe","args":[{"channel":"trade","instId":"BTCUSD","instType":"MC"}]}"#.to_string()] + &[r#"{"op":"subscribe","args":[{"channel":"trade","instId":"BTCUSD","instType":"MC"}]}"#.to_string()] ); } @@ -75,7 +75,7 @@ mod bitget_inverse_swap { gen_test_code!( BitgetSwapWSClient, subscribe_trade, - &vec!["BTCUSD".to_string()] + &["BTCUSD".to_string()] ); } @@ -84,7 +84,7 @@ mod bitget_inverse_swap { gen_test_code!( BitgetSwapWSClient, subscribe_orderbook_topk, - &vec!["BTCUSD".to_string()] + &["BTCUSD".to_string()] ); } @@ -93,7 +93,7 @@ mod bitget_inverse_swap { gen_test_code!( BitgetSwapWSClient, subscribe_orderbook, - &vec!["BTCUSD".to_string()] + &["BTCUSD".to_string()] ); } @@ -102,14 +102,14 @@ mod bitget_inverse_swap { gen_test_code!( BitgetSwapWSClient, subscribe_ticker, - &vec!["BTCUSD".to_string()] + &["BTCUSD".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitgetSwapWSClient, &vec![("BTCUSD".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitgetSwapWSClient, &vec![("BTCUSD".to_string(), 604800)]); + gen_test_subscribe_candlestick!(BitgetSwapWSClient, &[("BTCUSD".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitgetSwapWSClient, &[("BTCUSD".to_string(), 604800)]); } #[ignore] @@ -118,7 +118,7 @@ mod bitget_inverse_swap { gen_test_code!( BitgetSwapWSClient, subscribe, - &vec![("funding_rate".to_string(), "BTCUSD".to_string())] + &[("funding_rate".to_string(), "BTCUSD".to_string())] ); } } @@ -132,7 +132,7 @@ mod bitget_linear_swap { gen_test_code!( BitgetSwapWSClient, subscribe_trade, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -141,7 +141,7 @@ mod bitget_linear_swap { gen_test_code!( BitgetSwapWSClient, subscribe_orderbook_topk, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -150,7 +150,7 @@ mod bitget_linear_swap { gen_test_code!( BitgetSwapWSClient, subscribe_orderbook, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -159,14 +159,14 @@ mod bitget_linear_swap { gen_test_code!( BitgetSwapWSClient, subscribe_ticker, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitgetSwapWSClient, &vec![("BTCUSDT".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitgetSwapWSClient, &vec![("BTCUSDT".to_string(), 604800)]); + gen_test_subscribe_candlestick!(BitgetSwapWSClient, &[("BTCUSDT".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitgetSwapWSClient, &[("BTCUSDT".to_string(), 604800)]); } #[ignore] @@ -175,7 +175,7 @@ mod bitget_linear_swap { gen_test_code!( BitgetSwapWSClient, subscribe, - &vec![("funding_rate".to_string(), "BTCUSDT".to_string())] + &[("funding_rate".to_string(), "BTCUSDT".to_string())] ); } } diff --git a/crypto-ws-client/tests/bithumb.rs b/crypto-ws-client/tests/bithumb.rs index 70861f1d..871ce08f 100644 --- a/crypto-ws-client/tests/bithumb.rs +++ b/crypto-ws-client/tests/bithumb.rs @@ -9,10 +9,8 @@ async fn subscribe() { gen_test_code!( BithumbWSClient, subscribe, - &vec![ - ("TRADE".to_string(), "BTC-USDT".to_string()), - ("TRADE".to_string(), "ETH-USDT".to_string()), - ] + &[("TRADE".to_string(), "BTC-USDT".to_string()), + ("TRADE".to_string(), "ETH-USDT".to_string())] ); } @@ -22,7 +20,7 @@ fn subscribe_illegal_symbol() { gen_test_code!( BithumbWSClient, subscribe, - &vec![("TRADE".to_string(), "XXX-YYY".to_string())] + &[("TRADE".to_string(), "XXX-YYY".to_string())] ); } @@ -31,7 +29,7 @@ async fn subscribe_raw_json() { gen_test_code!( BithumbWSClient, send, - &vec![r#"{"cmd":"subscribe","args":["TRADE:BTC-USDT","TRADE:ETH-USDT"]}"#.to_string()] + &[r#"{"cmd":"subscribe","args":["TRADE:BTC-USDT","TRADE:ETH-USDT"]}"#.to_string()] ); } @@ -40,7 +38,7 @@ async fn subscribe_trade() { gen_test_code!( BithumbWSClient, subscribe_trade, - &vec!["BTC-USDT".to_string(), "ETH-USDT".to_string()] + &["BTC-USDT".to_string(), "ETH-USDT".to_string()] ); } @@ -49,7 +47,7 @@ async fn subscribe_orderbook() { gen_test_code!( BithumbWSClient, subscribe_orderbook, - &vec!["BTC-USDT".to_string(), "ETH-USDT".to_string()] + &["BTC-USDT".to_string(), "ETH-USDT".to_string()] ); } @@ -59,6 +57,6 @@ async fn subscribe_ticker() { gen_test_code!( BithumbWSClient, subscribe_ticker, - &vec!["BTC-USDT".to_string(), "ETH-USDT".to_string()] + &["BTC-USDT".to_string(), "ETH-USDT".to_string()] ); } diff --git a/crypto-ws-client/tests/bitmex.rs b/crypto-ws-client/tests/bitmex.rs index c4041f4a..a3a016fa 100644 --- a/crypto-ws-client/tests/bitmex.rs +++ b/crypto-ws-client/tests/bitmex.rs @@ -8,7 +8,7 @@ async fn bitmex_instrument() { gen_test_code!( BitmexWSClient, send, - &vec![r#"{"op":"subscribe","args":["instrument"]}"#.to_string()] + &[r#"{"op":"subscribe","args":["instrument"]}"#.to_string()] ); } @@ -21,10 +21,8 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, subscribe, - &vec![ - ("trade".to_string(), "XBTUSD".to_string()), - ("quote".to_string(), "XBTUSD".to_string()) - ] + &[("trade".to_string(), "XBTUSD".to_string()), + ("quote".to_string(), "XBTUSD".to_string())] ); } @@ -33,18 +31,18 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, send, - &vec![r#"{"op":"subscribe","args":["trade:XBTUSD","quote:XBTUSD"]}"#.to_string()] + &[r#"{"op":"subscribe","args":["trade:XBTUSD","quote:XBTUSD"]}"#.to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!(BitmexWSClient, subscribe_trade, &vec!["XBTUSD".to_string()]); + gen_test_code!(BitmexWSClient, subscribe_trade, &["XBTUSD".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!(BitmexWSClient, subscribe_bbo, &vec!["XBTUSD".to_string()]); + gen_test_code!(BitmexWSClient, subscribe_bbo, &["XBTUSD".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -52,7 +50,7 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, subscribe_orderbook, - &vec!["XBTUSD".to_string()] + &["XBTUSD".to_string()] ); } @@ -61,14 +59,14 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, subscribe_orderbook_topk, - &vec!["XBTUSD".to_string()] + &["XBTUSD".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitmexWSClient, &vec![("XBTUSD".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitmexWSClient, &vec![("XBTUSD".to_string(), 86400)]); + gen_test_subscribe_candlestick!(BitmexWSClient, &[("XBTUSD".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitmexWSClient, &[("XBTUSD".to_string(), 86400)]); } #[test] @@ -77,7 +75,7 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, subscribe, - &vec![("funding".to_string(), "XBTUSD".to_string())] + &[("funding".to_string(), "XBTUSD".to_string())] ); } @@ -86,7 +84,7 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, send, - &vec![r#"{"op":"subscribe","args":["funding"]}"#.to_string()] + &[r#"{"op":"subscribe","args":["funding"]}"#.to_string()] ); } @@ -95,7 +93,7 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, subscribe, - &vec![("instrument".to_string(), "XBTUSD".to_string())] + &[("instrument".to_string(), "XBTUSD".to_string())] ); } } @@ -109,10 +107,8 @@ mod bitmex_inverse_future { gen_test_code!( BitmexWSClient, subscribe, - &vec![ - ("trade".to_string(), "XBTU22".to_string()), - ("quote".to_string(), "XBTU22".to_string()) - ] + &[("trade".to_string(), "XBTU22".to_string()), + ("quote".to_string(), "XBTU22".to_string())] ); } @@ -121,7 +117,7 @@ mod bitmex_inverse_future { gen_test_code!( BitmexWSClient, subscribe_trade, - &vec!["XBTU22".to_string(), "XBTU22".to_string()] + &["XBTU22".to_string(), "XBTU22".to_string()] ); } @@ -130,7 +126,7 @@ mod bitmex_inverse_future { gen_test_code!( BitmexWSClient, subscribe_bbo, - &vec!["XBTU22".to_string(), "XBTU22".to_string()] + &["XBTU22".to_string(), "XBTU22".to_string()] ); } @@ -139,7 +135,7 @@ mod bitmex_inverse_future { gen_test_code!( BitmexWSClient, subscribe_orderbook, - &vec!["XBTU22".to_string(), "XBTU22".to_string()] + &["XBTU22".to_string(), "XBTU22".to_string()] ); } @@ -148,7 +144,7 @@ mod bitmex_inverse_future { gen_test_code!( BitmexWSClient, subscribe_orderbook_topk, - &vec!["XBTU22".to_string(), "XBTU22".to_string()] + &["XBTU22".to_string(), "XBTU22".to_string()] ); } @@ -156,11 +152,11 @@ mod bitmex_inverse_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BitmexWSClient, - &vec![("XBTU22".to_string(), 60), ("XBTU22".to_string(), 60)] + &[("XBTU22".to_string(), 60), ("XBTU22".to_string(), 60)] ); gen_test_subscribe_candlestick!( BitmexWSClient, - &vec![("XBTU22".to_string(), 86400), ("XBTU22".to_string(), 86400)] + &[("XBTU22".to_string(), 86400), ("XBTU22".to_string(), 86400)] ); } } @@ -171,12 +167,12 @@ mod bitmex_quanto_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!(BitmexWSClient, subscribe_trade, &vec!["ETHUSD".to_string()]); + gen_test_code!(BitmexWSClient, subscribe_trade, &["ETHUSD".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!(BitmexWSClient, subscribe_bbo, &vec!["ETHUSD".to_string()]); + gen_test_code!(BitmexWSClient, subscribe_bbo, &["ETHUSD".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -184,7 +180,7 @@ mod bitmex_quanto_swap { gen_test_code!( BitmexWSClient, subscribe_orderbook, - &vec!["ETHUSD".to_string()] + &["ETHUSD".to_string()] ); } @@ -193,14 +189,14 @@ mod bitmex_quanto_swap { gen_test_code!( BitmexWSClient, subscribe_orderbook_topk, - &vec!["ETHUSD".to_string()] + &["ETHUSD".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitmexWSClient, &vec![("ETHUSD".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitmexWSClient, &vec![("ETHUSD".to_string(), 86400)]); + gen_test_subscribe_candlestick!(BitmexWSClient, &[("ETHUSD".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitmexWSClient, &[("ETHUSD".to_string(), 86400)]); } #[test] @@ -209,7 +205,7 @@ mod bitmex_quanto_swap { gen_test_code!( BitmexWSClient, subscribe, - &vec![("funding".to_string(), "ETHUSD".to_string())] + &[("funding".to_string(), "ETHUSD".to_string())] ); } } @@ -223,17 +219,15 @@ mod bitmex_linear_future { gen_test_code!( BitmexWSClient, subscribe_trade, - &vec![ - "XBTUSDTU22".to_string(), + &["XBTUSDTU22".to_string(), "ETHU22".to_string(), - "ETHUSDTU22".to_string() - ] + "ETHUSDTU22".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!(BitmexWSClient, subscribe_bbo, &vec!["ETHU22".to_string()]); + gen_test_code!(BitmexWSClient, subscribe_bbo, &["ETHU22".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -241,7 +235,7 @@ mod bitmex_linear_future { gen_test_code!( BitmexWSClient, subscribe_orderbook, - &vec!["ETHU22".to_string()] + &["ETHU22".to_string()] ); } @@ -250,13 +244,13 @@ mod bitmex_linear_future { gen_test_code!( BitmexWSClient, subscribe_orderbook_topk, - &vec!["ETHU22".to_string()] + &["ETHU22".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitmexWSClient, &vec![("ETHU22".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitmexWSClient, &vec![("ETHU22".to_string(), 86400)]); + gen_test_subscribe_candlestick!(BitmexWSClient, &[("ETHU22".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitmexWSClient, &[("ETHU22".to_string(), 86400)]); } } diff --git a/crypto-ws-client/tests/bitstamp.rs b/crypto-ws-client/tests/bitstamp.rs index 2d38560e..08209d28 100644 --- a/crypto-ws-client/tests/bitstamp.rs +++ b/crypto-ws-client/tests/bitstamp.rs @@ -8,10 +8,8 @@ async fn subscribe() { gen_test_code!( BitstampWSClient, subscribe, - &vec![ - ("live_trades".to_string(), "btcusd".to_string()), - ("diff_order_book".to_string(), "btcusd".to_string()), - ] + &[("live_trades".to_string(), "btcusd".to_string()), + ("diff_order_book".to_string(), "btcusd".to_string())] ); } @@ -20,10 +18,8 @@ async fn subscribe_raw_json() { gen_test_code!( BitstampWSClient, send, - &vec![ - r#"{"event":"bts:subscribe","data":{"channel":"live_trades_btcusd"}}"#.to_string(), - r#"{"event":"bts:subscribe","data":{"channel":"live_trades_ethusd"}}"#.to_string() - ] + &[r#"{"event":"bts:subscribe","data":{"channel":"live_trades_btcusd"}}"#.to_string(), + r#"{"event":"bts:subscribe","data":{"channel":"live_trades_ethusd"}}"#.to_string()] ); } @@ -32,7 +28,7 @@ async fn subscribe_trade() { gen_test_code!( BitstampWSClient, subscribe_trade, - &vec!["btcusd".to_string(), "ethusd".to_string()] + &["btcusd".to_string(), "ethusd".to_string()] ); } @@ -41,7 +37,7 @@ async fn subscribe_orderbook() { gen_test_code!( BitstampWSClient, subscribe_orderbook, - &vec!["btcusd".to_string(), "ethusd".to_string()] + &["btcusd".to_string(), "ethusd".to_string()] ); } @@ -50,7 +46,7 @@ async fn subscribe_orderbook_topk() { gen_test_code!( BitstampWSClient, subscribe_orderbook_topk, - &vec!["btcusd".to_string(), "ethusd".to_string()] + &["btcusd".to_string(), "ethusd".to_string()] ); } @@ -59,6 +55,6 @@ async fn subscribe_l3_orderbook() { gen_test_code!( BitstampWSClient, subscribe_l3_orderbook, - &vec!["btcusd".to_string(), "ethusd".to_string()] + &["btcusd".to_string(), "ethusd".to_string()] ); } diff --git a/crypto-ws-client/tests/bitz.rs b/crypto-ws-client/tests/bitz.rs index 4dc623f0..428fec69 100644 --- a/crypto-ws-client/tests/bitz.rs +++ b/crypto-ws-client/tests/bitz.rs @@ -12,11 +12,9 @@ mod bitz_spot { gen_test_code!( BitzSpotWSClient, subscribe, - &vec![ - ("market".to_string(), "btc_usdt".to_string()), + &[("market".to_string(), "btc_usdt".to_string()), ("depth".to_string(), "btc_usdt".to_string()), - ("order".to_string(), "btc_usdt".to_string()), - ] + ("order".to_string(), "btc_usdt".to_string())] ); } @@ -26,7 +24,7 @@ mod bitz_spot { gen_test_code!( BitzSpotWSClient, send, - &vec![format!( + &[format!( r#"{{"action":"Topic.sub", "data":{{"symbol":"btc_usdt", "type":"market,depth,order", "_CDID":"100002", "dataType":"1"}}, "msg_id":{}}}"#, SystemTime::now() .duration_since(UNIX_EPOCH) @@ -42,7 +40,7 @@ mod bitz_spot { gen_test_code!( BitzSpotWSClient, subscribe_trade, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } @@ -52,7 +50,7 @@ mod bitz_spot { gen_test_code!( BitzSpotWSClient, subscribe_orderbook, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } @@ -62,14 +60,14 @@ mod bitz_spot { gen_test_code!( BitzSpotWSClient, subscribe_ticker, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } #[tokio::test(flavor = "multi_thread")] #[ignore = "bitz.com has shutdown since October 2021"] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BitzSpotWSClient, &vec![("btc_usdt".to_string(), 60)]); - gen_test_subscribe_candlestick!(BitzSpotWSClient, &vec![("btc_usdt".to_string(), 2592000)]); + gen_test_subscribe_candlestick!(BitzSpotWSClient, &[("btc_usdt".to_string(), 60)]); + gen_test_subscribe_candlestick!(BitzSpotWSClient, &[("btc_usdt".to_string(), 2592000)]); } } diff --git a/crypto-ws-client/tests/bybit.rs b/crypto-ws-client/tests/bybit.rs index 5fb5df5b..401d48ea 100644 --- a/crypto-ws-client/tests/bybit.rs +++ b/crypto-ws-client/tests/bybit.rs @@ -10,7 +10,7 @@ mod bybit_inverse_future { gen_test_code!( BybitInverseWSClient, subscribe, - &vec![("trade".to_string(), "BTCUSDU22".to_string())] + &[("trade".to_string(), "BTCUSDU22".to_string())] ); } @@ -19,7 +19,7 @@ mod bybit_inverse_future { gen_test_code!( BybitInverseWSClient, send, - &vec![r#"{"op":"subscribe","args":["trade.BTCUSDU22"]}"#.to_string()] + &[r#"{"op":"subscribe","args":["trade.BTCUSDU22"]}"#.to_string()] ); } @@ -28,7 +28,7 @@ mod bybit_inverse_future { gen_test_code!( BybitInverseWSClient, subscribe_trade, - &vec!["BTCUSDU22".to_string()] + &["BTCUSDU22".to_string()] ); } @@ -37,7 +37,7 @@ mod bybit_inverse_future { gen_test_code!( BybitInverseWSClient, subscribe_orderbook, - &vec!["BTCUSDU22".to_string()] + &["BTCUSDU22".to_string()] ); } @@ -46,16 +46,16 @@ mod bybit_inverse_future { gen_test_code!( BybitInverseWSClient, subscribe_ticker, - &vec!["BTCUSDU22".to_string()] + &["BTCUSDU22".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BybitInverseWSClient, &vec![("BTCUSDU22".to_string(), 60)]); + gen_test_subscribe_candlestick!(BybitInverseWSClient, &[("BTCUSDU22".to_string(), 60)]); gen_test_subscribe_candlestick!( BybitInverseWSClient, - &vec![("BTCUSDU22".to_string(), 2592000)] + &[("BTCUSDU22".to_string(), 2592000)] ); } } @@ -69,7 +69,7 @@ mod bybit_inverse_swap { gen_test_code!( BybitInverseWSClient, subscribe, - &vec![("trade".to_string(), "BTCUSD".to_string())] + &[("trade".to_string(), "BTCUSD".to_string())] ); } @@ -78,7 +78,7 @@ mod bybit_inverse_swap { gen_test_code!( BybitInverseWSClient, send, - &vec![r#"{"op":"subscribe","args":["trade.BTCUSD"]}"#.to_string()] + &[r#"{"op":"subscribe","args":["trade.BTCUSD"]}"#.to_string()] ); } @@ -87,7 +87,7 @@ mod bybit_inverse_swap { gen_test_code!( BybitInverseWSClient, subscribe_trade, - &vec!["BTCUSD".to_string()] + &["BTCUSD".to_string()] ); } @@ -96,7 +96,7 @@ mod bybit_inverse_swap { gen_test_code!( BybitInverseWSClient, subscribe_orderbook, - &vec!["BTCUSD".to_string()] + &["BTCUSD".to_string()] ); } @@ -105,16 +105,16 @@ mod bybit_inverse_swap { gen_test_code!( BybitInverseWSClient, subscribe_ticker, - &vec!["BTCUSD".to_string()] + &["BTCUSD".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(BybitInverseWSClient, &vec![("BTCUSD".to_string(), 60)]); + gen_test_subscribe_candlestick!(BybitInverseWSClient, &[("BTCUSD".to_string(), 60)]); gen_test_subscribe_candlestick!( BybitInverseWSClient, - &vec![("BTCUSD".to_string(), 2592000)] + &[("BTCUSD".to_string(), 2592000)] ); } } @@ -128,7 +128,7 @@ mod bybit_linear_swap { gen_test_code!( BybitLinearSwapWSClient, subscribe_trade, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -137,7 +137,7 @@ mod bybit_linear_swap { gen_test_code!( BybitLinearSwapWSClient, subscribe_orderbook, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -146,7 +146,7 @@ mod bybit_linear_swap { gen_test_code!( BybitLinearSwapWSClient, subscribe_ticker, - &vec!["BTCUSDT".to_string()] + &["BTCUSDT".to_string()] ); } @@ -154,11 +154,11 @@ mod bybit_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BybitLinearSwapWSClient, - &vec![("BTCUSDT".to_string(), 60)] + &[("BTCUSDT".to_string(), 60)] ); gen_test_subscribe_candlestick!( BybitLinearSwapWSClient, - &vec![("BTCUSDT".to_string(), 2592000)] + &[("BTCUSDT".to_string(), 2592000)] ); } } diff --git a/crypto-ws-client/tests/coinbase_pro.rs b/crypto-ws-client/tests/coinbase_pro.rs index f93ca435..f503277b 100644 --- a/crypto-ws-client/tests/coinbase_pro.rs +++ b/crypto-ws-client/tests/coinbase_pro.rs @@ -8,10 +8,8 @@ async fn subscribe() { gen_test_code!( CoinbaseProWSClient, subscribe, - &vec![ - ("matches".to_string(), "BTC-USD".to_string()), - ("heartbeat".to_string(), "BTC-USD".to_string()) - ] + &[("matches".to_string(), "BTC-USD".to_string()), + ("heartbeat".to_string(), "BTC-USD".to_string())] ); } @@ -21,7 +19,7 @@ async fn subscribe_illegal_symbol() { gen_test_code!( CoinbaseProWSClient, subscribe, - &vec![("matches".to_string(), "XXX-YYY".to_string())] + &[("matches".to_string(), "XXX-YYY".to_string())] ); } @@ -30,7 +28,7 @@ async fn subscribe_raw_json() { gen_test_code!( CoinbaseProWSClient, send, - &vec![r#"{ + &[r#"{ "type":"subscribe", "channels":[ { @@ -56,7 +54,7 @@ async fn subscribe_trade() { gen_test_code!( CoinbaseProWSClient, subscribe_trade, - &vec!["BTC-USD".to_string(), "ETH-USD".to_string()] + &["BTC-USD".to_string(), "ETH-USD".to_string()] ); } @@ -65,7 +63,7 @@ async fn subscribe_ticker() { gen_test_code!( CoinbaseProWSClient, subscribe_ticker, - &vec!["BTC-USD".to_string(), "ETH-USD".to_string()] + &["BTC-USD".to_string(), "ETH-USD".to_string()] ); } @@ -74,7 +72,7 @@ async fn subscribe_orderbook() { gen_test_code!( CoinbaseProWSClient, subscribe_orderbook, - &vec!["BTC-USD".to_string()] + &["BTC-USD".to_string()] ); } @@ -83,6 +81,6 @@ async fn subscribe_l3_orderbook() { gen_test_code!( CoinbaseProWSClient, subscribe_l3_orderbook, - &vec!["BTC-USD".to_string()] + &["BTC-USD".to_string()] ); } diff --git a/crypto-ws-client/tests/deribit.rs b/crypto-ws-client/tests/deribit.rs index 972d228f..173a1a79 100644 --- a/crypto-ws-client/tests/deribit.rs +++ b/crypto-ws-client/tests/deribit.rs @@ -9,10 +9,8 @@ async fn deribit_all_trades() { DeribitWSClient, subscribe, // https://docs.deribit.com/?javascript#trades-kind-currency-interval - &vec![ - ("trades.future.SYMBOL.100ms".to_string(), "any".to_string()), - ("trades.option.SYMBOL.100ms".to_string(), "any".to_string()), - ] + &[("trades.future.SYMBOL.100ms".to_string(), "any".to_string()), + ("trades.option.SYMBOL.100ms".to_string(), "any".to_string())] ); } @@ -25,7 +23,7 @@ mod deribit_inverse_future { gen_test_code!( DeribitWSClient, subscribe, - &vec![("trades.future.SYMBOL.100ms".to_string(), "BTC".to_string())] + &[("trades.future.SYMBOL.100ms".to_string(), "BTC".to_string())] ); } @@ -35,7 +33,7 @@ mod deribit_inverse_future { gen_test_code!( DeribitWSClient, subscribe_trade, - &vec!["BTC-26AUG22".to_string(), "BTC-30SEP22".to_string()] + &["BTC-26AUG22".to_string(), "BTC-30SEP22".to_string()] ); } @@ -44,7 +42,7 @@ mod deribit_inverse_future { gen_test_code!( DeribitWSClient, subscribe_ticker, - &vec!["BTC-30SEP22".to_string()] + &["BTC-30SEP22".to_string()] ); } @@ -53,7 +51,7 @@ mod deribit_inverse_future { gen_test_code!( DeribitWSClient, subscribe_orderbook, - &vec!["BTC-30SEP22".to_string()] + &["BTC-30SEP22".to_string()] ); } @@ -62,7 +60,7 @@ mod deribit_inverse_future { gen_test_code!( DeribitWSClient, subscribe_orderbook_topk, - &vec!["BTC-30SEP22".to_string()] + &["BTC-30SEP22".to_string()] ); } @@ -71,14 +69,14 @@ mod deribit_inverse_future { gen_test_code!( DeribitWSClient, subscribe_bbo, - &vec!["BTC-30SEP22".to_string()] + &["BTC-30SEP22".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(DeribitWSClient, &vec![("BTC-30SEP22".to_string(), 60)]); - gen_test_subscribe_candlestick!(DeribitWSClient, &vec![("BTC-30SEP22".to_string(), 86400)]); + gen_test_subscribe_candlestick!(DeribitWSClient, &[("BTC-30SEP22".to_string(), 60)]); + gen_test_subscribe_candlestick!(DeribitWSClient, &[("BTC-30SEP22".to_string(), 86400)]); } } @@ -91,7 +89,7 @@ mod deribit_inverse_swap { gen_test_code!( DeribitWSClient, subscribe, - &vec![( + &[( "trades.SYMBOL.100ms".to_string(), "BTC-PERPETUAL".to_string() )] @@ -103,7 +101,7 @@ mod deribit_inverse_swap { gen_test_code!( DeribitWSClient, subscribe_trade, - &vec!["BTC-PERPETUAL".to_string()] + &["BTC-PERPETUAL".to_string()] ); } @@ -112,7 +110,7 @@ mod deribit_inverse_swap { gen_test_code!( DeribitWSClient, subscribe_ticker, - &vec!["BTC-PERPETUAL".to_string()] + &["BTC-PERPETUAL".to_string()] ); } @@ -121,7 +119,7 @@ mod deribit_inverse_swap { gen_test_code!( DeribitWSClient, subscribe_orderbook, - &vec!["BTC-PERPETUAL".to_string()] + &["BTC-PERPETUAL".to_string()] ); } @@ -130,7 +128,7 @@ mod deribit_inverse_swap { gen_test_code!( DeribitWSClient, subscribe_orderbook_topk, - &vec!["BTC-PERPETUAL".to_string()] + &["BTC-PERPETUAL".to_string()] ); } @@ -139,16 +137,16 @@ mod deribit_inverse_swap { gen_test_code!( DeribitWSClient, subscribe_bbo, - &vec!["BTC-PERPETUAL".to_string()] + &["BTC-PERPETUAL".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(DeribitWSClient, &vec![("BTC-PERPETUAL".to_string(), 60)]); + gen_test_subscribe_candlestick!(DeribitWSClient, &[("BTC-PERPETUAL".to_string(), 60)]); gen_test_subscribe_candlestick!( DeribitWSClient, - &vec![("BTC-PERPETUAL".to_string(), 86400)] + &[("BTC-PERPETUAL".to_string(), 86400)] ); } } @@ -157,7 +155,7 @@ mod deribit_inverse_swap { mod deribit_option { use crypto_ws_client::{DeribitWSClient, WSClient}; - const SYMBOLS: &'static [&str] = &[ + const SYMBOLS: &[&str] = &[ "BTC-26AUG22-23000-C", "BTC-26AUG22-45000-C", "BTC-30SEP22-40000-C", @@ -170,7 +168,7 @@ mod deribit_option { gen_test_code!( DeribitWSClient, subscribe, - &vec![("trades.option.SYMBOL.100ms".to_string(), "any".to_string())] + &[("trades.option.SYMBOL.100ms".to_string(), "any".to_string())] ); } diff --git a/crypto-ws-client/tests/dydx.rs b/crypto-ws-client/tests/dydx.rs index 0a5eba91..f3190d7f 100644 --- a/crypto-ws-client/tests/dydx.rs +++ b/crypto-ws-client/tests/dydx.rs @@ -10,10 +10,8 @@ mod dydx_linear_swap { gen_test_code!( DydxSwapWSClient, send, - &vec![ - r#"{"type": "subscribe", "channel": "v3_trades", "id": "BTC-USD"}"#.to_string(), - r#"{"type": "subscribe", "channel": "v3_trades", "id": "ETH-USD"}"#.to_string() - ] + &[r#"{"type": "subscribe", "channel": "v3_trades", "id": "BTC-USD"}"#.to_string(), + r#"{"type": "subscribe", "channel": "v3_trades", "id": "ETH-USD"}"#.to_string()] ); } @@ -22,7 +20,7 @@ mod dydx_linear_swap { gen_test_code!( DydxSwapWSClient, subscribe_trade, - &vec!["BTC-USD".to_string(), "ETH-USD".to_string()] + &["BTC-USD".to_string(), "ETH-USD".to_string()] ); } @@ -31,7 +29,7 @@ mod dydx_linear_swap { gen_test_code!( DydxSwapWSClient, subscribe_orderbook, - &vec!["BTC-USD".to_string(), "ETH-USD".to_string()] + &["BTC-USD".to_string(), "ETH-USD".to_string()] ); } } diff --git a/crypto-ws-client/tests/ftx.rs b/crypto-ws-client/tests/ftx.rs index 61d2a6fe..5c40d15d 100644 --- a/crypto-ws-client/tests/ftx.rs +++ b/crypto-ws-client/tests/ftx.rs @@ -10,7 +10,7 @@ mod ftx_spot { gen_test_code!( FtxWSClient, subscribe, - &vec![("trades".to_string(), "BTC/USD".to_string())] + &[("trades".to_string(), "BTC/USD".to_string())] ); } @@ -19,18 +19,18 @@ mod ftx_spot { gen_test_code!( FtxWSClient, send, - &vec![r#"{"op":"subscribe","channel":"trades","market":"BTC/USD"}"#.to_string()] + &[r#"{"op":"subscribe","channel":"trades","market":"BTC/USD"}"#.to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!(FtxWSClient, subscribe_trade, &vec!["BTC/USD".to_string()]); + gen_test_code!(FtxWSClient, subscribe_trade, &["BTC/USD".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!(FtxWSClient, subscribe_bbo, &vec!["BTC/USD".to_string()]); + gen_test_code!(FtxWSClient, subscribe_bbo, &["BTC/USD".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -38,7 +38,7 @@ mod ftx_spot { gen_test_code!( FtxWSClient, subscribe_orderbook, - &vec!["BTC/USD".to_string()] + &["BTC/USD".to_string()] ); } } @@ -49,12 +49,12 @@ mod ftx_linear_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!(FtxWSClient, subscribe_trade, &vec!["BTC-PERP".to_string()]); + gen_test_code!(FtxWSClient, subscribe_trade, &["BTC-PERP".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!(FtxWSClient, subscribe_bbo, &vec!["BTC-PERP".to_string()]); + gen_test_code!(FtxWSClient, subscribe_bbo, &["BTC-PERP".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -62,7 +62,7 @@ mod ftx_linear_swap { gen_test_code!( FtxWSClient, subscribe_orderbook, - &vec!["BTC-PERP".to_string(), "ETH-PERP".to_string()] + &["BTC-PERP".to_string(), "ETH-PERP".to_string()] ); } } @@ -76,7 +76,7 @@ mod ftx_linear_future { gen_test_code!( FtxWSClient, subscribe_trade, - &vec!["BTC-0930".to_string(), "ETH-0930".to_string()] + &["BTC-0930".to_string(), "ETH-0930".to_string()] ); } @@ -85,7 +85,7 @@ mod ftx_linear_future { gen_test_code!( FtxWSClient, subscribe_bbo, - &vec!["BTC-0930".to_string(), "ETH-0930".to_string()] + &["BTC-0930".to_string(), "ETH-0930".to_string()] ); } @@ -94,7 +94,7 @@ mod ftx_linear_future { gen_test_code!( FtxWSClient, subscribe_orderbook, - &vec!["BTC-0930".to_string()] + &["BTC-0930".to_string()] ); } } @@ -109,7 +109,7 @@ mod ftx_move { gen_test_code!( FtxWSClient, subscribe_trade, - &vec!["BTC-MOVE-2022Q4".to_string()] + &["BTC-MOVE-2022Q4".to_string()] ); } @@ -118,7 +118,7 @@ mod ftx_move { gen_test_code!( FtxWSClient, subscribe_bbo, - &vec!["BTC-MOVE-2022Q4".to_string()] + &["BTC-MOVE-2022Q4".to_string()] ); } @@ -127,7 +127,7 @@ mod ftx_move { gen_test_code!( FtxWSClient, subscribe_orderbook, - &vec!["BTC-MOVE-2022Q4".to_string()] + &["BTC-MOVE-2022Q4".to_string()] ); } } @@ -139,12 +139,12 @@ mod ftx_bvol { #[test] #[ignore] fn subscribe_trade() { - gen_test_code!(FtxWSClient, subscribe_trade, &vec!["BVOL/USD".to_string()]); + gen_test_code!(FtxWSClient, subscribe_trade, &["BVOL/USD".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!(FtxWSClient, subscribe_bbo, &vec!["BVOL/USD".to_string()]); + gen_test_code!(FtxWSClient, subscribe_bbo, &["BVOL/USD".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -152,7 +152,7 @@ mod ftx_bvol { gen_test_code!( FtxWSClient, subscribe_orderbook, - &vec!["BVOL/USD".to_string()] + &["BVOL/USD".to_string()] ); } } diff --git a/crypto-ws-client/tests/gate.rs b/crypto-ws-client/tests/gate.rs index 11dbad9b..021405e4 100644 --- a/crypto-ws-client/tests/gate.rs +++ b/crypto-ws-client/tests/gate.rs @@ -10,10 +10,8 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, subscribe, - &vec![ - ("trades".to_string(), "BTC_USDT".to_string()), - ("trades".to_string(), "ETH_USDT".to_string()) - ] + &[("trades".to_string(), "BTC_USDT".to_string()), + ("trades".to_string(), "ETH_USDT".to_string())] ); } @@ -22,9 +20,7 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, send, - &vec![ - r#"{"channel":"spot.trades", "event":"subscribe", "payload":["BTC_USDT","ETH_USDT"]}"#.to_string() - ] + &[r#"{"channel":"spot.trades", "event":"subscribe", "payload":["BTC_USDT","ETH_USDT"]}"#.to_string()] ); } @@ -33,7 +29,7 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, subscribe_trade, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -42,7 +38,7 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, subscribe_orderbook, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -51,7 +47,7 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, subscribe_orderbook_topk, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -60,7 +56,7 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, subscribe_bbo, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -69,15 +65,15 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, subscribe_ticker, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } #[ignore = "too slow"] #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(GateSpotWSClient, &vec![("BTC_USDT".to_string(), 10)]); - gen_test_subscribe_candlestick!(GateSpotWSClient, &vec![("BTC_USDT".to_string(), 604800)]); + gen_test_subscribe_candlestick!(GateSpotWSClient, &[("BTC_USDT".to_string(), 10)]); + gen_test_subscribe_candlestick!(GateSpotWSClient, &[("BTC_USDT".to_string(), 604800)]); } } @@ -91,12 +87,10 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, subscribe, - &vec![ - ("trades".to_string(), "BTC_USD".to_string()), + &[("trades".to_string(), "BTC_USD".to_string()), ("trades".to_string(), "ETH_USD".to_string()), ("trades".to_string(), "BNB_USD".to_string()), - ("trades".to_string(), "XRP_USD".to_string()) - ] + ("trades".to_string(), "XRP_USD".to_string())] ); } @@ -106,10 +100,8 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, send, - &vec![ - r#"{"channel":"futures.trades", "event":"subscribe", "payload":["BTC_USD","ETH_USD","BNB_USD","XRP_USD"]}"# - .to_string() - ] + &[r#"{"channel":"futures.trades", "event":"subscribe", "payload":["BTC_USD","ETH_USD","BNB_USD","XRP_USD"]}"# + .to_string()] ); } @@ -119,7 +111,7 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, subscribe_trade, - &vec!["BTC_USD".to_string(), "ETH_USD".to_string()] + &["BTC_USD".to_string(), "ETH_USD".to_string()] ); } @@ -128,7 +120,7 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, subscribe_orderbook, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } @@ -137,7 +129,7 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, subscribe_orderbook_topk, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } @@ -146,7 +138,7 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, subscribe_bbo, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } @@ -155,7 +147,7 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, subscribe_ticker, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } @@ -164,11 +156,11 @@ mod gate_inverse_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( GateInverseSwapWSClient, - &vec![("BTC_USD".to_string(), 10)] + &[("BTC_USD".to_string(), 10)] ); gen_test_subscribe_candlestick!( GateInverseSwapWSClient, - &vec![("BTC_USD".to_string(), 604800)] + &[("BTC_USD".to_string(), 604800)] ); } } @@ -182,7 +174,7 @@ mod gate_linear_swap { gen_test_code!( GateLinearSwapWSClient, subscribe_trade, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -191,7 +183,7 @@ mod gate_linear_swap { gen_test_code!( GateLinearSwapWSClient, subscribe_orderbook, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -200,7 +192,7 @@ mod gate_linear_swap { gen_test_code!( GateLinearSwapWSClient, subscribe_orderbook_topk, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -209,7 +201,7 @@ mod gate_linear_swap { gen_test_code!( GateLinearSwapWSClient, subscribe_bbo, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -218,7 +210,7 @@ mod gate_linear_swap { gen_test_code!( GateLinearSwapWSClient, subscribe_ticker, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -227,11 +219,11 @@ mod gate_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( GateLinearSwapWSClient, - &vec![("BTC_USDT".to_string(), 10)] + &[("BTC_USDT".to_string(), 10)] ); gen_test_subscribe_candlestick!( GateLinearSwapWSClient, - &vec![("BTC_USDT".to_string(), 604800)] + &[("BTC_USDT".to_string(), 604800)] ); } } @@ -246,7 +238,7 @@ mod gate_inverse_future { gen_test_code!( GateInverseFutureWSClient, subscribe_trade, - &vec!["BTC_USD_20220930".to_string()] + &["BTC_USD_20220930".to_string()] ); } @@ -255,7 +247,7 @@ mod gate_inverse_future { gen_test_code!( GateInverseFutureWSClient, subscribe_orderbook, - &vec!["BTC_USD_20220930".to_string()] + &["BTC_USD_20220930".to_string()] ); } @@ -264,7 +256,7 @@ mod gate_inverse_future { gen_test_code!( GateInverseFutureWSClient, subscribe_ticker, - &vec!["BTC_USD_20220930".to_string()] + &["BTC_USD_20220930".to_string()] ); } @@ -273,11 +265,11 @@ mod gate_inverse_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( GateInverseFutureWSClient, - &vec![("BTC_USD_20220930".to_string(), 10)] + &[("BTC_USD_20220930".to_string(), 10)] ); gen_test_subscribe_candlestick!( GateInverseFutureWSClient, - &vec![("BTC_USD_20220930".to_string(), 604800)] + &[("BTC_USD_20220930".to_string(), 604800)] ); } } @@ -292,7 +284,7 @@ mod gate_linear_future { gen_test_code!( GateLinearFutureWSClient, subscribe_trade, - &vec!["BTC_USDT_20220930".to_string()] + &["BTC_USDT_20220930".to_string()] ); } @@ -302,7 +294,7 @@ mod gate_linear_future { gen_test_code!( GateLinearFutureWSClient, subscribe_orderbook, - &vec!["BTC_USDT_20220930".to_string()] + &["BTC_USDT_20220930".to_string()] ); } @@ -311,7 +303,7 @@ mod gate_linear_future { gen_test_code!( GateLinearFutureWSClient, subscribe_ticker, - &vec!["BTC_USDT_20220930".to_string()] + &["BTC_USDT_20220930".to_string()] ); } @@ -320,11 +312,11 @@ mod gate_linear_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( GateLinearFutureWSClient, - &vec![("BTC_USDT_20220930".to_string(), 10)] + &[("BTC_USDT_20220930".to_string(), 10)] ); gen_test_subscribe_candlestick!( GateLinearFutureWSClient, - &vec![("BTC_USDT_20220930".to_string(), 604800)] + &[("BTC_USDT_20220930".to_string(), 604800)] ); } } diff --git a/crypto-ws-client/tests/huobi.rs b/crypto-ws-client/tests/huobi.rs index 16c39f8f..ddabc719 100644 --- a/crypto-ws-client/tests/huobi.rs +++ b/crypto-ws-client/tests/huobi.rs @@ -10,7 +10,7 @@ mod huobi_spot { gen_test_code!( HuobiSpotWSClient, subscribe, - &vec![("trade.detail".to_string(), "btcusdt".to_string())] + &[("trade.detail".to_string(), "btcusdt".to_string())] ); } @@ -19,7 +19,7 @@ mod huobi_spot { gen_test_code!( HuobiSpotWSClient, send, - &vec![r#"{"sub":"market.btcusdt.trade.detail","id":"crypto-ws-client"}"#.to_string()] + &[r#"{"sub":"market.btcusdt.trade.detail","id":"crypto-ws-client"}"#.to_string()] ); } @@ -28,7 +28,7 @@ mod huobi_spot { gen_test_code!( HuobiSpotWSClient, subscribe_trade, - &vec!["btcusdt".to_string()] + &["btcusdt".to_string()] ); } @@ -37,7 +37,7 @@ mod huobi_spot { gen_test_code!( HuobiSpotWSClient, subscribe_ticker, - &vec!["btcusdt".to_string()] + &["btcusdt".to_string()] ); } @@ -46,7 +46,7 @@ mod huobi_spot { gen_test_code!( HuobiSpotWSClient, subscribe_bbo, - &vec!["btcusdt".to_string()] + &["btcusdt".to_string()] ); } @@ -56,19 +56,14 @@ mod huobi_spot { tokio::task::spawn(async move { let ws_client = HuobiSpotWSClient::new(tx, Some("wss://api.huobi.pro/feed")).await; ws_client - .subscribe_orderbook(&vec!["btcusdt".to_string()]) + .subscribe_orderbook(&["btcusdt".to_string()]) .await; // run for 60 seconds at most let _ = tokio::time::timeout(std::time::Duration::from_secs(60), ws_client.run()).await; ws_client.close(); }); - let mut messages = Vec::::new(); - for msg in rx { - messages.push(msg); - break; - } - assert!(!messages.is_empty()); + rx.into_iter().next().expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] @@ -76,14 +71,14 @@ mod huobi_spot { gen_test_code!( HuobiSpotWSClient, subscribe_orderbook_topk, - &vec!["btcusdt".to_string()] + &["btcusdt".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(HuobiSpotWSClient, &vec![("btcusdt".to_string(), 60)]); - gen_test_subscribe_candlestick!(HuobiSpotWSClient, &vec![("btcusdt".to_string(), 2592000)]); + gen_test_subscribe_candlestick!(HuobiSpotWSClient, &[("btcusdt".to_string(), 60)]); + gen_test_subscribe_candlestick!(HuobiSpotWSClient, &[("btcusdt".to_string(), 2592000)]); } } @@ -96,7 +91,7 @@ mod huobi_inverse_future { gen_test_code!( HuobiFutureWSClient, subscribe, - &vec![("trade.detail".to_string(), "BTC_CQ".to_string())] + &[("trade.detail".to_string(), "BTC_CQ".to_string())] ); } @@ -105,7 +100,7 @@ mod huobi_inverse_future { gen_test_code!( HuobiFutureWSClient, subscribe_trade, - &vec!["BTC_CQ".to_string()] + &["BTC_CQ".to_string()] ); } @@ -114,7 +109,7 @@ mod huobi_inverse_future { gen_test_code!( HuobiFutureWSClient, subscribe_ticker, - &vec!["BTC_CQ".to_string()] + &["BTC_CQ".to_string()] ); } @@ -123,7 +118,7 @@ mod huobi_inverse_future { gen_test_code!( HuobiFutureWSClient, subscribe_bbo, - &vec!["BTC_CQ".to_string()] + &["BTC_CQ".to_string()] ); } @@ -132,7 +127,7 @@ mod huobi_inverse_future { gen_test_code!( HuobiFutureWSClient, subscribe_orderbook, - &vec!["BTC_CQ".to_string()] + &["BTC_CQ".to_string()] ); } @@ -141,16 +136,16 @@ mod huobi_inverse_future { gen_test_code!( HuobiFutureWSClient, subscribe_orderbook_topk, - &vec!["BTC_CQ".to_string()] + &["BTC_CQ".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(HuobiFutureWSClient, &vec![("BTC_CQ".to_string(), 60)]); + gen_test_subscribe_candlestick!(HuobiFutureWSClient, &[("BTC_CQ".to_string(), 60)]); gen_test_subscribe_candlestick!( HuobiFutureWSClient, - &vec![("BTC_CQ".to_string(), 2592000)] + &[("BTC_CQ".to_string(), 2592000)] ); } } @@ -164,7 +159,7 @@ mod huobi_linear_swap { gen_test_code!( HuobiLinearSwapWSClient, subscribe, - &vec![("trade.detail".to_string(), "BTC-USDT".to_string())] + &[("trade.detail".to_string(), "BTC-USDT".to_string())] ); } @@ -173,7 +168,7 @@ mod huobi_linear_swap { gen_test_code!( HuobiLinearSwapWSClient, subscribe_trade, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -182,7 +177,7 @@ mod huobi_linear_swap { gen_test_code!( HuobiLinearSwapWSClient, subscribe_ticker, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -191,7 +186,7 @@ mod huobi_linear_swap { gen_test_code!( HuobiLinearSwapWSClient, subscribe_bbo, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -200,7 +195,7 @@ mod huobi_linear_swap { gen_test_code!( HuobiLinearSwapWSClient, subscribe_orderbook, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -209,7 +204,7 @@ mod huobi_linear_swap { gen_test_code!( HuobiLinearSwapWSClient, subscribe_orderbook_topk, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -217,11 +212,11 @@ mod huobi_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( HuobiLinearSwapWSClient, - &vec![("BTC-USDT".to_string(), 60)] + &[("BTC-USDT".to_string(), 60)] ); gen_test_subscribe_candlestick!( HuobiLinearSwapWSClient, - &vec![("BTC-USDT".to_string(), 2592000)] + &[("BTC-USDT".to_string(), 2592000)] ); } @@ -235,21 +230,14 @@ mod huobi_linear_swap { ) .await; ws_client - .send(&vec![ - r#"{"topic":"public.BTC-USDT.funding_rate","op":"sub"}"#.to_string(), - ]) + .send(&[r#"{"topic":"public.BTC-USDT.funding_rate","op":"sub"}"#.to_string()]) .await; // run for 60 seconds at most let _ = tokio::time::timeout(std::time::Duration::from_secs(60), ws_client.run()).await; ws_client.close(); }); - let mut messages = Vec::::new(); - for msg in rx { - messages.push(msg); - break; - } - assert!(!messages.is_empty()); + rx.into_iter().next().expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] @@ -262,21 +250,14 @@ mod huobi_linear_swap { ) .await; ws_client - .send(&vec![ - r#"{"topic":"public.*.funding_rate","op":"sub"}"#.to_string() - ]) + .send(&[r#"{"topic":"public.*.funding_rate","op":"sub"}"#.to_string()]) .await; // run for 60 seconds at most let _ = tokio::time::timeout(std::time::Duration::from_secs(60), ws_client.run()).await; ws_client.close(); }); - let mut messages = Vec::::new(); - for msg in rx { - messages.push(msg); - break; - } - assert!(!messages.is_empty()); + rx.into_iter().next().expect("should has at least 1 element"); } } @@ -289,7 +270,7 @@ mod huobi_inverse_swap { gen_test_code!( HuobiInverseSwapWSClient, subscribe, - &vec![("trade.detail".to_string(), "BTC-USD".to_string())] + &[("trade.detail".to_string(), "BTC-USD".to_string())] ); } @@ -298,7 +279,7 @@ mod huobi_inverse_swap { gen_test_code!( HuobiInverseSwapWSClient, subscribe_trade, - &vec!["BTC-USD".to_string()] + &["BTC-USD".to_string()] ); } @@ -307,7 +288,7 @@ mod huobi_inverse_swap { gen_test_code!( HuobiInverseSwapWSClient, subscribe_ticker, - &vec!["BTC-USD".to_string()] + &["BTC-USD".to_string()] ); } @@ -316,7 +297,7 @@ mod huobi_inverse_swap { gen_test_code!( HuobiInverseSwapWSClient, subscribe_bbo, - &vec!["BTC-USD".to_string()] + &["BTC-USD".to_string()] ); } @@ -325,7 +306,7 @@ mod huobi_inverse_swap { gen_test_code!( HuobiInverseSwapWSClient, subscribe_orderbook, - &vec!["BTC-USD".to_string()] + &["BTC-USD".to_string()] ); } @@ -334,7 +315,7 @@ mod huobi_inverse_swap { gen_test_code!( HuobiInverseSwapWSClient, subscribe_orderbook_topk, - &vec!["BTC-USD".to_string()] + &["BTC-USD".to_string()] ); } @@ -342,11 +323,11 @@ mod huobi_inverse_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( HuobiInverseSwapWSClient, - &vec![("BTC-USD".to_string(), 60)] + &[("BTC-USD".to_string(), 60)] ); gen_test_subscribe_candlestick!( HuobiInverseSwapWSClient, - &vec![("BTC-USD".to_string(), 2592000)] + &[("BTC-USD".to_string(), 2592000)] ); } @@ -358,21 +339,14 @@ mod huobi_inverse_swap { HuobiInverseSwapWSClient::new(tx, Some("wss://api.hbdm.com/swap-notification")) .await; ws_client - .send(&vec![ - r#"{"topic":"public.BTC-USD.funding_rate","op":"sub"}"#.to_string(), - ]) + .send(&[r#"{"topic":"public.BTC-USD.funding_rate","op":"sub"}"#.to_string()]) .await; // run for 60 seconds at most let _ = tokio::time::timeout(std::time::Duration::from_secs(60), ws_client.run()).await; ws_client.close(); }); - let mut messages = Vec::::new(); - for msg in rx { - messages.push(msg); - break; - } - assert!(!messages.is_empty()); + rx.into_iter().next().expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] @@ -383,21 +357,14 @@ mod huobi_inverse_swap { HuobiInverseSwapWSClient::new(tx, Some("wss://api.hbdm.com/swap-notification")) .await; ws_client - .send(&vec![ - r#"{"topic":"public.*.funding_rate","op":"sub"}"#.to_string() - ]) + .send(&[r#"{"topic":"public.*.funding_rate","op":"sub"}"#.to_string()]) .await; // run for 60 seconds at most let _ = tokio::time::timeout(std::time::Duration::from_secs(60), ws_client.run()).await; ws_client.close(); }); - let mut messages = Vec::::new(); - for msg in rx { - messages.push(msg); - break; - } - assert!(!messages.is_empty()); + rx.into_iter().next().expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] @@ -405,7 +372,7 @@ mod huobi_inverse_swap { gen_test_code!( HuobiInverseSwapWSClient, send, - &vec![r#"{"sub":"market.overview","id":"crypto-ws-client"}"#.to_string()] + &[r#"{"sub":"market.overview","id":"crypto-ws-client"}"#.to_string()] ); } } @@ -420,7 +387,7 @@ mod huobi_option { gen_test_code!( HuobiOptionWSClient, subscribe, - &vec![( + &[( "trade.detail".to_string(), "BTC-USDT-210625-P-27000".to_string() )] @@ -433,7 +400,7 @@ mod huobi_option { gen_test_code!( HuobiOptionWSClient, subscribe_trade, - &vec!["BTC-USDT-210625-P-27000".to_string()] + &["BTC-USDT-210625-P-27000".to_string()] ); } @@ -443,7 +410,7 @@ mod huobi_option { gen_test_code!( HuobiOptionWSClient, subscribe_ticker, - &vec!["BTC-USDT-210625-P-27000".to_string()] + &["BTC-USDT-210625-P-27000".to_string()] ); } @@ -453,7 +420,7 @@ mod huobi_option { gen_test_code!( HuobiOptionWSClient, subscribe_bbo, - &vec!["BTC-USDT-210625-P-27000".to_string()] + &["BTC-USDT-210625-P-27000".to_string()] ); } @@ -463,7 +430,7 @@ mod huobi_option { gen_test_code!( HuobiOptionWSClient, subscribe_orderbook, - &vec!["BTC-USDT-210625-P-27000".to_string()] + &["BTC-USDT-210625-P-27000".to_string()] ); } @@ -473,7 +440,7 @@ mod huobi_option { gen_test_code!( HuobiOptionWSClient, subscribe_orderbook_topk, - &vec!["BTC-USDT-210625-P-27000".to_string()] + &["BTC-USDT-210625-P-27000".to_string()] ); } @@ -482,11 +449,11 @@ mod huobi_option { fn subscribe_candlestick() { gen_test_subscribe_candlestick!( HuobiOptionWSClient, - &vec![("BTC-USDT-210625-P-27000".to_string(), 60)] + &[("BTC-USDT-210625-P-27000".to_string(), 60)] ); gen_test_subscribe_candlestick!( HuobiOptionWSClient, - &vec![("BTC-USDT-210625-P-27000".to_string(), 2592000)] + &[("BTC-USDT-210625-P-27000".to_string(), 2592000)] ); } @@ -496,7 +463,7 @@ mod huobi_option { gen_test_code!( HuobiOptionWSClient, send, - &vec![r#"{"sub":"market.overview","id":"crypto-ws-client"}"#.to_string()] + &[r#"{"sub":"market.overview","id":"crypto-ws-client"}"#.to_string()] ); } } diff --git a/crypto-ws-client/tests/kraken.rs b/crypto-ws-client/tests/kraken.rs index bb66f7b1..707767fb 100644 --- a/crypto-ws-client/tests/kraken.rs +++ b/crypto-ws-client/tests/kraken.rs @@ -10,12 +10,10 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, subscribe, - &vec![ - ("trade".to_string(), "XBT/USD".to_string()), + &[("trade".to_string(), "XBT/USD".to_string()), ("ticker".to_string(), "XBT/USD".to_string()), ("spread".to_string(), "XBT/USD".to_string()), - ("book".to_string(), "XBT/USD".to_string()), - ] + ("book".to_string(), "XBT/USD".to_string())] ); } @@ -24,10 +22,8 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, send, - &vec![ - r#"{"event":"subscribe","pair":["XBT/USD"],"subscription":{"name":"trade"}}"# - .to_string() - ] + &[r#"{"event":"subscribe","pair":["XBT/USD"],"subscription":{"name":"trade"}}"# + .to_string()] ); } @@ -36,7 +32,7 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, subscribe_trade, - &vec!["XBT/USD".to_string(), "ETH/USD".to_string()] + &["XBT/USD".to_string(), "ETH/USD".to_string()] ); } @@ -45,7 +41,7 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, subscribe_ticker, - &vec!["XBT/USD".to_string(), "ETH/USD".to_string()] + &["XBT/USD".to_string(), "ETH/USD".to_string()] ); } @@ -54,7 +50,7 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, subscribe_bbo, - &vec!["XBT/USD".to_string(), "ETH/USD".to_string()] + &["XBT/USD".to_string(), "ETH/USD".to_string()] ); } @@ -63,7 +59,7 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, subscribe_orderbook, - &vec!["XBT/USD".to_string(), "ETH/USD".to_string()] + &["XBT/USD".to_string(), "ETH/USD".to_string()] ); } @@ -71,15 +67,13 @@ mod kraken_spot { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KrakenSpotWSClient, - &vec![("XBT/USD".to_string(), 60), ("ETH/USD".to_string(), 60)] + &[("XBT/USD".to_string(), 60), ("ETH/USD".to_string(), 60)] ); gen_test_subscribe_candlestick!( KrakenSpotWSClient, - &vec![ - ("XBT/USD".to_string(), 1296000), - ("ETH/USD".to_string(), 1296000) - ] + &[("XBT/USD".to_string(), 1296000), + ("ETH/USD".to_string(), 1296000)] ); } } @@ -93,9 +87,7 @@ mod kraken_inverse_swap { gen_test_code!( KrakenFuturesWSClient, send, - &vec![ - r#"{"event":"subscribe","feed":"trade","product_ids":["PI_XBTUSD"]}"#.to_string() - ] + &[r#"{"event":"subscribe","feed":"trade","product_ids":["PI_XBTUSD"]}"#.to_string()] ); } @@ -104,7 +96,7 @@ mod kraken_inverse_swap { gen_test_code!( KrakenFuturesWSClient, subscribe_trade, - &vec!["PI_XBTUSD".to_string()] + &["PI_XBTUSD".to_string()] ); } @@ -113,7 +105,7 @@ mod kraken_inverse_swap { gen_test_code!( KrakenFuturesWSClient, subscribe_ticker, - &vec!["PI_XBTUSD".to_string()] + &["PI_XBTUSD".to_string()] ); } @@ -122,7 +114,7 @@ mod kraken_inverse_swap { gen_test_code!( KrakenFuturesWSClient, subscribe_orderbook, - &vec!["PI_XBTUSD".to_string()] + &["PI_XBTUSD".to_string()] ); } } @@ -136,10 +128,8 @@ mod kraken_inverse_future { gen_test_code!( KrakenFuturesWSClient, send, - &vec![ - r#"{"event":"subscribe","feed":"trade","product_ids":["FI_XBTUSD_220930"]}"# - .to_string() - ] + &[r#"{"event":"subscribe","feed":"trade","product_ids":["FI_XBTUSD_220930"]}"# + .to_string()] ); } @@ -148,7 +138,7 @@ mod kraken_inverse_future { gen_test_code!( KrakenFuturesWSClient, subscribe_trade, - &vec!["FI_XBTUSD_220930".to_string()] + &["FI_XBTUSD_220930".to_string()] ); } @@ -157,7 +147,7 @@ mod kraken_inverse_future { gen_test_code!( KrakenFuturesWSClient, subscribe_ticker, - &vec!["FI_XBTUSD_220930".to_string()] + &["FI_XBTUSD_220930".to_string()] ); } @@ -166,7 +156,7 @@ mod kraken_inverse_future { gen_test_code!( KrakenFuturesWSClient, subscribe_orderbook, - &vec!["FI_XBTUSD_220930".to_string()] + &["FI_XBTUSD_220930".to_string()] ); } } diff --git a/crypto-ws-client/tests/kucoin.rs b/crypto-ws-client/tests/kucoin.rs index 9893c3fc..10e4ff48 100644 --- a/crypto-ws-client/tests/kucoin.rs +++ b/crypto-ws-client/tests/kucoin.rs @@ -10,7 +10,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe, - &vec![("/market/match".to_string(), "BTC-USDT".to_string())] + &[("/market/match".to_string(), "BTC-USDT".to_string())] ); } @@ -19,7 +19,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe, - &vec![("/market/ticker".to_string(), "all".to_string())] + &[("/market/ticker".to_string(), "all".to_string())] ); } @@ -28,7 +28,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, send, - &vec![r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/market/match:BTC-USDT","privateChannel":false,"response":true}"#.to_string()] + &[r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/market/match:BTC-USDT","privateChannel":false,"response":true}"#.to_string()] ); } @@ -37,7 +37,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe_trade, - &vec!["BTC-USDT".to_string(), "ETH-USDT".to_string()] + &["BTC-USDT".to_string(), "ETH-USDT".to_string()] ); } @@ -46,7 +46,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe_bbo, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -55,7 +55,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe_orderbook, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -64,7 +64,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe_l3_orderbook, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -73,7 +73,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe_orderbook_topk, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -82,7 +82,7 @@ mod kucoin_spot { gen_test_code!( KuCoinSpotWSClient, subscribe_ticker, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -90,10 +90,8 @@ mod kucoin_spot { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KuCoinSpotWSClient, - &vec![ - ("BTC-USDT".to_string(), 60), - ("BTC-USDT".to_string(), 604800) - ] + &[("BTC-USDT".to_string(), 60), + ("BTC-USDT".to_string(), 604800)] ); } } @@ -107,8 +105,7 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe, - &vec![ - ( + &[( "/contractMarket/execution".to_string(), "XBTUSDM".to_string() ), @@ -123,8 +120,7 @@ mod kucoin_inverse_swap { ( "/contractMarket/execution".to_string(), "XRPUSDM".to_string() - ) - ] + )] ); } @@ -133,7 +129,7 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, send, - &vec![r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/contractMarket/execution:XBTUSDM,ETHUSDM,DOTUSDM,XRPUSDM","privateChannel":false,"response":true}"#.to_string()] + &[r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/contractMarket/execution:XBTUSDM,ETHUSDM,DOTUSDM,XRPUSDM","privateChannel":false,"response":true}"#.to_string()] ); } @@ -142,12 +138,10 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_trade, - &vec![ - "XBTUSDM".to_string(), + &["XBTUSDM".to_string(), "ETHUSDM".to_string(), "DOTUSDM".to_string(), - "XRPUSDM".to_string() - ] + "XRPUSDM".to_string()] ); } @@ -156,7 +150,7 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_bbo, - &vec!["XBTUSDM".to_string()] + &["XBTUSDM".to_string()] ); } @@ -165,7 +159,7 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_orderbook, - &vec!["XBTUSDM".to_string()] + &["XBTUSDM".to_string()] ); } @@ -174,7 +168,7 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_l3_orderbook, - &vec!["XBTUSDM".to_string()] + &["XBTUSDM".to_string()] ); } @@ -183,7 +177,7 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_orderbook_topk, - &vec!["XBTUSDM".to_string()] + &["XBTUSDM".to_string()] ); } @@ -192,7 +186,7 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_ticker, - &vec!["XBTUSDM".to_string()] + &["XBTUSDM".to_string()] ); } @@ -201,12 +195,10 @@ mod kucoin_inverse_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KuCoinSwapWSClient, - &vec![ - ("XBTUSDM".to_string(), 60), + &[("XBTUSDM".to_string(), 60), ("ETHUSDM".to_string(), 60), ("XBTUSDM".to_string(), 604800), - ("ETHUSDM".to_string(), 604800) - ] + ("ETHUSDM".to_string(), 604800)] ); } } @@ -220,7 +212,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, subscribe, - &vec![( + &[( "/contractMarket/execution".to_string(), "XBTUSDTM".to_string() )] @@ -232,7 +224,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, send, - &vec![r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/contractMarket/execution:XBTUSDTM","privateChannel":false,"response":true}"#.to_string()] + &[r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/contractMarket/execution:XBTUSDTM","privateChannel":false,"response":true}"#.to_string()] ); } @@ -241,7 +233,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_trade, - &vec!["XBTUSDTM".to_string()] + &["XBTUSDTM".to_string()] ); } @@ -250,7 +242,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_bbo, - &vec!["XBTUSDTM".to_string()] + &["XBTUSDTM".to_string()] ); } @@ -259,7 +251,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_orderbook, - &vec!["XBTUSDTM".to_string()] + &["XBTUSDTM".to_string()] ); } @@ -268,7 +260,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_l3_orderbook, - &vec!["XBTUSDTM".to_string()] + &["XBTUSDTM".to_string()] ); } @@ -277,7 +269,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_orderbook_topk, - &vec!["XBTUSDTM".to_string()] + &["XBTUSDTM".to_string()] ); } @@ -286,7 +278,7 @@ mod kucoin_linear_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_ticker, - &vec!["XBTUSDTM".to_string()] + &["XBTUSDTM".to_string()] ); } @@ -295,12 +287,10 @@ mod kucoin_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KuCoinSwapWSClient, - &vec![ - ("XBTUSDTM".to_string(), 60), + &[("XBTUSDTM".to_string(), 60), ("ETHUSDTM".to_string(), 60), ("XBTUSDTM".to_string(), 604800), - ("ETHUSDTM".to_string(), 604800), - ] + ("ETHUSDTM".to_string(), 604800)] ); } } @@ -315,7 +305,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, subscribe, - &vec![( + &[( "/contractMarket/execution".to_string(), "XBTMU22".to_string() )] @@ -328,7 +318,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, send, - &vec![r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/contractMarket/execution:XBTMU22","privateChannel":false,"response":true}"#.to_string()] + &[r#"{"id":"crypto-ws-client","type":"subscribe","topic":"/contractMarket/execution:XBTMU22","privateChannel":false,"response":true}"#.to_string()] ); } @@ -338,7 +328,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, subscribe_trade, - &vec!["XBTMU22".to_string()] + &["XBTMU22".to_string()] ); } @@ -348,7 +338,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, subscribe_bbo, - &vec!["XBTMU22".to_string()] + &["XBTMU22".to_string()] ); } @@ -357,7 +347,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, subscribe_orderbook, - &vec!["XBTMU22".to_string()] + &["XBTMU22".to_string()] ); } @@ -366,7 +356,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, subscribe_l3_orderbook, - &vec!["XBTMU22".to_string()] + &["XBTMU22".to_string()] ); } @@ -375,7 +365,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, subscribe_orderbook_topk, - &vec!["XBTMU22".to_string()] + &["XBTMU22".to_string()] ); } @@ -384,7 +374,7 @@ mod kucoin_inverse_future { gen_test_code!( KuCoinSwapWSClient, subscribe_ticker, - &vec!["XBTMU22".to_string()] + &["XBTMU22".to_string()] ); } @@ -393,7 +383,7 @@ mod kucoin_inverse_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KuCoinSwapWSClient, - &vec![("XBTMU22".to_string(), 60), ("XBTMU22".to_string(), 604800)] + &[("XBTMU22".to_string(), 60), ("XBTMU22".to_string(), 604800)] ); } } diff --git a/crypto-ws-client/tests/mexc.rs b/crypto-ws-client/tests/mexc.rs index f8531408..72134662 100644 --- a/crypto-ws-client/tests/mexc.rs +++ b/crypto-ws-client/tests/mexc.rs @@ -10,11 +10,9 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, subscribe, - &vec![ - ("deal".to_string(), "BTC_USDT".to_string()), + &[("deal".to_string(), "BTC_USDT".to_string()), ("deal".to_string(), "ETH_USDT".to_string()), - ("deal".to_string(), "MX_USDT".to_string()), - ] + ("deal".to_string(), "MX_USDT".to_string())] ); } @@ -23,11 +21,9 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, send, - &vec![ - r#"{"op":"sub.deal","symbol":"BTC_USDT"}"#.to_string(), + &[r#"{"op":"sub.deal","symbol":"BTC_USDT"}"#.to_string(), r#"{"op":"sub.deal","symbol":"ETH_USDT"}"#.to_string(), - r#"{"op":"sub.deal","symbol":"MX_USDT"}"#.to_string() - ] + r#"{"op":"sub.deal","symbol":"MX_USDT"}"#.to_string()] ); } @@ -36,11 +32,9 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, subscribe_trade, - &vec![ - "BTC_USDT".to_string(), + &["BTC_USDT".to_string(), "ETH_USDT".to_string(), - "MX_USDT".to_string() - ] + "MX_USDT".to_string()] ); } @@ -49,11 +43,9 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, subscribe_orderbook, - &vec![ - "BTC_USDT".to_string(), + &["BTC_USDT".to_string(), "ETH_USDT".to_string(), - "MX_USDT".to_string() - ] + "MX_USDT".to_string()] ); } @@ -62,7 +54,7 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, subscribe_orderbook_topk, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -70,19 +62,15 @@ mod mexc_spot { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( MexcSpotWSClient, - &vec![ - ("BTC_USDT".to_string(), 60), + &[("BTC_USDT".to_string(), 60), ("ETH_USDT".to_string(), 60), - ("MX_USDT".to_string(), 60) - ] + ("MX_USDT".to_string(), 60)] ); gen_test_subscribe_candlestick!( MexcSpotWSClient, - &vec![ - ("BTC_USDT".to_string(), 2592000), + &[("BTC_USDT".to_string(), 2592000), ("ETH_USDT".to_string(), 2592000), - ("MX_USDT".to_string(), 2592000) - ] + ("MX_USDT".to_string(), 2592000)] ); } @@ -91,7 +79,7 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, send, - &vec![r#"{"op":"sub.overview"}"#.to_string()] + &[r#"{"op":"sub.overview"}"#.to_string()] ); } } @@ -105,10 +93,8 @@ mod mexc_linear_swap { gen_test_code!( MexcSwapWSClient, subscribe, - &vec![ - ("deal".to_string(), "BTC_USDT".to_string()), - ("deal".to_string(), "ETH_USDT".to_string()), - ] + &[("deal".to_string(), "BTC_USDT".to_string()), + ("deal".to_string(), "ETH_USDT".to_string())] ); } @@ -117,7 +103,7 @@ mod mexc_linear_swap { gen_test_code!( MexcSwapWSClient, send, - &vec![r#"{"method":"sub.deal","param":{"symbol":"BTC_USDT"}}"#.to_string()] + &[r#"{"method":"sub.deal","param":{"symbol":"BTC_USDT"}}"#.to_string()] ); } @@ -126,7 +112,7 @@ mod mexc_linear_swap { gen_test_code!( MexcSwapWSClient, subscribe_trade, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -135,7 +121,7 @@ mod mexc_linear_swap { gen_test_code!( MexcSwapWSClient, subscribe_ticker, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -144,7 +130,7 @@ mod mexc_linear_swap { gen_test_code!( MexcSwapWSClient, subscribe_orderbook, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } @@ -153,14 +139,14 @@ mod mexc_linear_swap { gen_test_code!( MexcSwapWSClient, subscribe_orderbook_topk, - &vec!["BTC_USDT".to_string()] + &["BTC_USDT".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(MexcSwapWSClient, &vec![("BTC_USDT".to_string(), 60)]); - gen_test_subscribe_candlestick!(MexcSwapWSClient, &vec![("BTC_USDT".to_string(), 2592000)]); + gen_test_subscribe_candlestick!(MexcSwapWSClient, &[("BTC_USDT".to_string(), 60)]); + gen_test_subscribe_candlestick!(MexcSwapWSClient, &[("BTC_USDT".to_string(), 2592000)]); } } @@ -173,7 +159,7 @@ mod mexc_inverse_swap { gen_test_code!( MexcSwapWSClient, subscribe_trade, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } @@ -182,7 +168,7 @@ mod mexc_inverse_swap { gen_test_code!( MexcSwapWSClient, subscribe_ticker, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } @@ -191,7 +177,7 @@ mod mexc_inverse_swap { gen_test_code!( MexcSwapWSClient, subscribe_orderbook, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } @@ -200,13 +186,13 @@ mod mexc_inverse_swap { gen_test_code!( MexcSwapWSClient, subscribe_orderbook_topk, - &vec!["BTC_USD".to_string()] + &["BTC_USD".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(MexcSwapWSClient, &vec![("BTC_USD".to_string(), 60)]); - gen_test_subscribe_candlestick!(MexcSwapWSClient, &vec![("BTC_USD".to_string(), 2592000)]); + gen_test_subscribe_candlestick!(MexcSwapWSClient, &[("BTC_USD".to_string(), 60)]); + gen_test_subscribe_candlestick!(MexcSwapWSClient, &[("BTC_USD".to_string(), 2592000)]); } } diff --git a/crypto-ws-client/tests/okx.rs b/crypto-ws-client/tests/okx.rs index f40006b9..5d60f602 100644 --- a/crypto-ws-client/tests/okx.rs +++ b/crypto-ws-client/tests/okx.rs @@ -8,7 +8,7 @@ async fn okex_index() { gen_test_code!( OkxWSClient, subscribe, - &vec![("index-tickers".to_string(), "BTC-USDT".to_string())] + &[("index-tickers".to_string(), "BTC-USDT".to_string())] ); } @@ -21,7 +21,7 @@ mod okx_spot { gen_test_code!( OkxWSClient, subscribe, - &vec![("trades".to_string(), "BTC-USDT".to_string())] + &[("trades".to_string(), "BTC-USDT".to_string())] ); } @@ -30,26 +30,24 @@ mod okx_spot { gen_test_code!( OkxWSClient, send, - &vec![ - r#"{"op":"subscribe","args":[{"channel":"trades","instId":"BTC-USDT"}]}"# - .to_string() - ] + &[r#"{"op":"subscribe","args":[{"channel":"trades","instId":"BTC-USDT"}]}"# + .to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!(OkxWSClient, subscribe_trade, &vec!["BTC-USDT".to_string()]); + gen_test_code!(OkxWSClient, subscribe_trade, &["BTC-USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_ticker() { - gen_test_code!(OkxWSClient, subscribe_ticker, &vec!["BTC-USDT".to_string()]); + gen_test_code!(OkxWSClient, subscribe_ticker, &["BTC-USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!(OkxWSClient, subscribe_bbo, &vec!["BTC-USDT".to_string()]); + gen_test_code!(OkxWSClient, subscribe_bbo, &["BTC-USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -57,7 +55,7 @@ mod okx_spot { gen_test_code!( OkxWSClient, subscribe_orderbook, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } @@ -66,14 +64,14 @@ mod okx_spot { gen_test_code!( OkxWSClient, subscribe_orderbook_topk, - &vec!["BTC-USDT".to_string()] + &["BTC-USDT".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(OkxWSClient, &vec![("BTC-USDT".to_string(), 60)]); - gen_test_subscribe_candlestick!(OkxWSClient, &vec![("BTC-USDT".to_string(), 604800)]); + gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USDT".to_string(), 60)]); + gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USDT".to_string(), 604800)]); } } @@ -86,7 +84,7 @@ mod okx_future { gen_test_code!( OkxWSClient, subscribe, - &vec![("trades".to_string(), "BTC-USDT-220930".to_string())] + &[("trades".to_string(), "BTC-USDT-220930".to_string())] ); } @@ -95,7 +93,7 @@ mod okx_future { gen_test_code!( OkxWSClient, subscribe_trade, - &vec!["BTC-USDT-220930".to_string()] + &["BTC-USDT-220930".to_string()] ); } @@ -104,7 +102,7 @@ mod okx_future { gen_test_code!( OkxWSClient, subscribe_ticker, - &vec!["BTC-USDT-220930".to_string()] + &["BTC-USDT-220930".to_string()] ); } @@ -113,7 +111,7 @@ mod okx_future { gen_test_code!( OkxWSClient, subscribe_bbo, - &vec!["BTC-USDT-220930".to_string()] + &["BTC-USDT-220930".to_string()] ); } @@ -122,7 +120,7 @@ mod okx_future { gen_test_code!( OkxWSClient, subscribe_orderbook, - &vec!["BTC-USDT-220930".to_string()] + &["BTC-USDT-220930".to_string()] ); } @@ -131,16 +129,16 @@ mod okx_future { gen_test_code!( OkxWSClient, subscribe_orderbook_topk, - &vec!["BTC-USDT-220930".to_string()] + &["BTC-USDT-220930".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(OkxWSClient, &vec![("BTC-USDT-220930".to_string(), 60)]); + gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USDT-220930".to_string(), 60)]); gen_test_subscribe_candlestick!( OkxWSClient, - &vec![("BTC-USDT-220930".to_string(), 604800)] + &[("BTC-USDT-220930".to_string(), 604800)] ); } } @@ -154,7 +152,7 @@ mod okx_swap { gen_test_code!( OkxWSClient, subscribe, - &vec![("trades".to_string(), "BTC-USDT-SWAP".to_string())] + &[("trades".to_string(), "BTC-USDT-SWAP".to_string())] ); } @@ -163,7 +161,7 @@ mod okx_swap { gen_test_code!( OkxWSClient, subscribe_trade, - &vec!["BTC-USDT-SWAP".to_string()] + &["BTC-USDT-SWAP".to_string()] ); } @@ -172,7 +170,7 @@ mod okx_swap { gen_test_code!( OkxWSClient, subscribe_ticker, - &vec!["BTC-USDT-SWAP".to_string()] + &["BTC-USDT-SWAP".to_string()] ); } @@ -181,7 +179,7 @@ mod okx_swap { gen_test_code!( OkxWSClient, subscribe_bbo, - &vec!["BTC-USDT-SWAP".to_string()] + &["BTC-USDT-SWAP".to_string()] ); } @@ -190,7 +188,7 @@ mod okx_swap { gen_test_code!( OkxWSClient, subscribe_orderbook, - &vec!["BTC-USDT-SWAP".to_string()] + &["BTC-USDT-SWAP".to_string()] ); } @@ -199,14 +197,14 @@ mod okx_swap { gen_test_code!( OkxWSClient, subscribe_orderbook_topk, - &vec!["BTC-USDT-SWAP".to_string()] + &["BTC-USDT-SWAP".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(OkxWSClient, &vec![("BTC-USDT-SWAP".to_string(), 60)]); - gen_test_subscribe_candlestick!(OkxWSClient, &vec![("BTC-USDT-SWAP".to_string(), 604800)]); + gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USDT-SWAP".to_string(), 60)]); + gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USDT-SWAP".to_string(), 604800)]); } #[tokio::test(flavor = "multi_thread")] @@ -214,7 +212,7 @@ mod okx_swap { gen_test_code!( OkxWSClient, subscribe, - &vec![("funding-rate".to_string(), "BTC-USDT-SWAP".to_string())] + &[("funding-rate".to_string(), "BTC-USDT-SWAP".to_string())] ); } } @@ -229,7 +227,7 @@ mod okx_option { gen_test_code!( OkxWSClient, subscribe_trade, - &vec!["BTC-USD-220930-50000-C".to_string()] + &["BTC-USD-220930-50000-C".to_string()] ); } @@ -238,7 +236,7 @@ mod okx_option { gen_test_code!( OkxWSClient, subscribe_ticker, - &vec!["BTC-USD-220930-50000-C".to_string()] + &["BTC-USD-220930-50000-C".to_string()] ); } @@ -247,7 +245,7 @@ mod okx_option { gen_test_code!( OkxWSClient, subscribe_bbo, - &vec!["BTC-USD-220930-50000-C".to_string()] + &["BTC-USD-220930-50000-C".to_string()] ); } @@ -256,7 +254,7 @@ mod okx_option { gen_test_code!( OkxWSClient, subscribe_orderbook, - &vec!["BTC-USD-220930-50000-C".to_string()] + &["BTC-USD-220930-50000-C".to_string()] ); } @@ -265,7 +263,7 @@ mod okx_option { gen_test_code!( OkxWSClient, subscribe_orderbook_topk, - &vec!["BTC-USD-220930-50000-C".to_string()] + &["BTC-USD-220930-50000-C".to_string()] ); } @@ -274,11 +272,11 @@ mod okx_option { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( OkxWSClient, - &vec![("BTC-USD-220930-50000-C".to_string(), 60)] + &[("BTC-USD-220930-50000-C".to_string(), 60)] ); gen_test_subscribe_candlestick!( OkxWSClient, - &vec![("BTC-USD-220930-50000-C".to_string(), 604800)] + &[("BTC-USD-220930-50000-C".to_string(), 604800)] ); } } diff --git a/crypto-ws-client/tests/zb.rs b/crypto-ws-client/tests/zb.rs index 98464cfc..b8d0a96a 100644 --- a/crypto-ws-client/tests/zb.rs +++ b/crypto-ws-client/tests/zb.rs @@ -10,7 +10,7 @@ mod zb_spot { gen_test_code!( ZbSpotWSClient, subscribe, - &vec![("trades".to_string(), "btc_usdt".to_string())] + &[("trades".to_string(), "btc_usdt".to_string())] ); } @@ -19,7 +19,7 @@ mod zb_spot { gen_test_code!( ZbSpotWSClient, send, - &vec![r#"{"event":"addChannel","channel":"btcusdt_trades"}"#.to_string()] + &[r#"{"event":"addChannel","channel":"btcusdt_trades"}"#.to_string()] ); } @@ -28,7 +28,7 @@ mod zb_spot { gen_test_code!( ZbSpotWSClient, subscribe_trade, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } @@ -37,7 +37,7 @@ mod zb_spot { gen_test_code!( ZbSpotWSClient, subscribe_orderbook_topk, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } @@ -46,14 +46,14 @@ mod zb_spot { gen_test_code!( ZbSpotWSClient, subscribe_ticker, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(ZbSpotWSClient, &vec![("btc_usdt".to_string(), 60)]); - gen_test_subscribe_candlestick!(ZbSpotWSClient, &vec![("btc_usdt".to_string(), 604800)]); + gen_test_subscribe_candlestick!(ZbSpotWSClient, &[("btc_usdt".to_string(), 60)]); + gen_test_subscribe_candlestick!(ZbSpotWSClient, &[("btc_usdt".to_string(), 604800)]); } } @@ -66,10 +66,8 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, subscribe, - &vec![ - ("Trade".to_string(), "BTC_USDT".to_string()), - ("Depth".to_string(), "BTC_USDT".to_string()), - ] + &[("Trade".to_string(), "BTC_USDT".to_string()), + ("Depth".to_string(), "BTC_USDT".to_string())] ); } @@ -78,10 +76,8 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, send, - &vec![ - r#"{"action":"subscribe", "channel":"BTC_USDT.Trade", "size":100}"#.to_string(), - r#"{"action":"subscribe", "channel":"BTC_USDT.Depth", "size":200}"#.to_string() - ] + &[r#"{"action":"subscribe", "channel":"BTC_USDT.Trade", "size":100}"#.to_string(), + r#"{"action":"subscribe", "channel":"BTC_USDT.Depth", "size":200}"#.to_string()] ); } @@ -90,7 +86,7 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, subscribe_trade, - &vec!["BTC_USDT".to_string(), "ETH_USDT".to_string()] + &["BTC_USDT".to_string(), "ETH_USDT".to_string()] ); } @@ -99,7 +95,7 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, subscribe_orderbook, - &vec!["BTC_USDT".to_string(), "ETH_USDT".to_string()] + &["BTC_USDT".to_string(), "ETH_USDT".to_string()] ); } @@ -108,7 +104,7 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, subscribe_orderbook_topk, - &vec!["BTC_USDT".to_string(), "ETH_USDT".to_string()] + &["BTC_USDT".to_string(), "ETH_USDT".to_string()] ); } @@ -117,7 +113,7 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, subscribe_ticker, - &vec!["BTC_USDT".to_string(), "ETH_USDT".to_string()] + &["BTC_USDT".to_string(), "ETH_USDT".to_string()] ); } @@ -125,7 +121,7 @@ mod zb_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( ZbSwapWSClient, - &vec![("BTC_USDT".to_string(), 60), ("ETH_USDT".to_string(), 60)] + &[("BTC_USDT".to_string(), 60), ("ETH_USDT".to_string(), 60)] ); } } diff --git a/crypto-ws-client/tests/zbg.rs b/crypto-ws-client/tests/zbg.rs index c2c45f6f..f8fd1b6d 100644 --- a/crypto-ws-client/tests/zbg.rs +++ b/crypto-ws-client/tests/zbg.rs @@ -10,7 +10,7 @@ mod zbg_spot { gen_test_code!( ZbgSpotWSClient, subscribe, - &vec![("TRADE".to_string(), "btc_usdt".to_string())] + &[("TRADE".to_string(), "btc_usdt".to_string())] ); } @@ -19,7 +19,7 @@ mod zbg_spot { gen_test_code!( ZbgSpotWSClient, send, - &vec![r#"{"action":"ADD", "dataType":329_TRADE_BTC_USDT}"#.to_string()] + &[r#"{"action":"ADD", "dataType":329_TRADE_BTC_USDT}"#.to_string()] ); } @@ -28,7 +28,7 @@ mod zbg_spot { gen_test_code!( ZbgSpotWSClient, subscribe_trade, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } @@ -37,7 +37,7 @@ mod zbg_spot { gen_test_code!( ZbgSpotWSClient, subscribe_orderbook, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } @@ -46,7 +46,7 @@ mod zbg_spot { gen_test_code!( ZbgSpotWSClient, subscribe_ticker, - &vec!["btc_usdt".to_string()] + &["btc_usdt".to_string()] ); } @@ -56,14 +56,14 @@ mod zbg_spot { gen_test_code!( ZbgSpotWSClient, send, - &vec![r#"{"action":"ADD", "dataType":"ALL_TRADE_STATISTIC_24H"}"#.to_string()] + &[r#"{"action":"ADD", "dataType":"ALL_TRADE_STATISTIC_24H"}"#.to_string()] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!(ZbgSpotWSClient, &vec![("btc_usdt".to_string(), 60)]); - gen_test_subscribe_candlestick!(ZbgSpotWSClient, &vec![("btc_usdt".to_string(), 604800)]); + gen_test_subscribe_candlestick!(ZbgSpotWSClient, &[("btc_usdt".to_string(), 60)]); + gen_test_subscribe_candlestick!(ZbgSpotWSClient, &[("btc_usdt".to_string(), 604800)]); } } @@ -77,10 +77,8 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, subscribe, - &vec![ - ("future_tick".to_string(), "1000001".to_string()), - ("future_tick".to_string(), "1000003".to_string()), - ] + &[("future_tick".to_string(), "1000001".to_string()), + ("future_tick".to_string(), "1000003".to_string())] ); } @@ -90,10 +88,8 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, send, - &vec![ - r#"{"action":"sub", "topic":"future_tick-1000001"}"#.to_string(), - r#"{"action":"sub", "topic":"future_tick-1000003"}"#.to_string() - ] + &[r#"{"action":"sub", "topic":"future_tick-1000001"}"#.to_string(), + r#"{"action":"sub", "topic":"future_tick-1000003"}"#.to_string()] ); } @@ -103,7 +99,7 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, subscribe_trade, - &vec!["BTC_USD-R".to_string(), "ETH_USD-R".to_string()] + &["BTC_USD-R".to_string(), "ETH_USD-R".to_string()] ); } @@ -113,7 +109,7 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, subscribe_orderbook, - &vec!["BTC_USD-R".to_string(), "ETH_USD-R".to_string()] + &["BTC_USD-R".to_string(), "ETH_USD-R".to_string()] ); } @@ -123,7 +119,7 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, subscribe_ticker, - &vec!["BTC_USD-R".to_string(), "ETH_USD-R".to_string()] + &["BTC_USD-R".to_string(), "ETH_USD-R".to_string()] ); } @@ -133,7 +129,7 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, send, - &vec![r#"{"action":"sub", "topic":"future_all_indicator"}"#.to_string()] + &[r#"{"action":"sub", "topic":"future_all_indicator"}"#.to_string()] ); } @@ -142,14 +138,12 @@ mod zbg_inverse_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( ZbgSwapWSClient, - &vec![("BTC_USD-R".to_string(), 60), ("ETH_USD-R".to_string(), 60)] + &[("BTC_USD-R".to_string(), 60), ("ETH_USD-R".to_string(), 60)] ); gen_test_subscribe_candlestick!( ZbgSwapWSClient, - &vec![ - ("BTC_USD-R".to_string(), 604800), - ("ETH_USD-R".to_string(), 604800) - ] + &[("BTC_USD-R".to_string(), 604800), + ("ETH_USD-R".to_string(), 604800)] ); } } @@ -164,10 +158,8 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, subscribe, - &vec![ - ("future_tick".to_string(), "1000000".to_string()), - ("future_tick".to_string(), "1000002".to_string()), - ] + &[("future_tick".to_string(), "1000000".to_string()), + ("future_tick".to_string(), "1000002".to_string())] ); } @@ -177,10 +169,8 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, send, - &vec![ - r#"{"action":"sub", "topic":"future_tick-1000000"}"#.to_string(), - r#"{"action":"sub", "topic":"future_tick-1000002"}"#.to_string() - ] + &[r#"{"action":"sub", "topic":"future_tick-1000000"}"#.to_string(), + r#"{"action":"sub", "topic":"future_tick-1000002"}"#.to_string()] ); } @@ -190,7 +180,7 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, subscribe_trade, - &vec!["BTC_USDT".to_string(), "ETH_USDT".to_string()] + &["BTC_USDT".to_string(), "ETH_USDT".to_string()] ); } @@ -200,7 +190,7 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, subscribe_orderbook, - &vec!["BTC_USDT".to_string(), "ETH_USDT".to_string()] + &["BTC_USDT".to_string(), "ETH_USDT".to_string()] ); } @@ -210,7 +200,7 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, subscribe_ticker, - &vec!["BTC_USDT".to_string(), "ETH_USDT".to_string()] + &["BTC_USDT".to_string(), "ETH_USDT".to_string()] ); } @@ -220,7 +210,7 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, send, - &vec![r#"{"action":"sub", "topic":"future_all_indicator"}"#.to_string()] + &[r#"{"action":"sub", "topic":"future_all_indicator"}"#.to_string()] ); } @@ -229,14 +219,12 @@ mod zbg_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( ZbgSwapWSClient, - &vec![("BTC_USDT".to_string(), 60), ("ETH_USDT".to_string(), 60)] + &[("BTC_USDT".to_string(), 60), ("ETH_USDT".to_string(), 60)] ); gen_test_subscribe_candlestick!( ZbgSwapWSClient, - &vec![ - ("BTC_USDT".to_string(), 604800), - ("ETH_USDT".to_string(), 604800) - ] + &[("BTC_USDT".to_string(), 604800), + ("ETH_USDT".to_string(), 604800)] ); } } From 53a4f011de3287122d2b595b118cb3dda0e8a96c Mon Sep 17 00:00:00 2001 From: pan93412 Date: Fri, 8 Jul 2022 22:34:53 +0800 Subject: [PATCH 2/2] style: cargo fmt --- crypto-pair/tests/kraken.rs | 5 +- crypto-ws-client/src/clients/binance.rs | 6 +- .../src/clients/binance_option.rs | 6 +- crypto-ws-client/src/clients/bitfinex.rs | 6 +- crypto-ws-client/src/clients/bitget/utils.rs | 10 +- crypto-ws-client/src/clients/bithumb.rs | 12 ++- crypto-ws-client/src/clients/bitmex.rs | 10 +- crypto-ws-client/src/clients/bitstamp.rs | 12 +-- crypto-ws-client/src/clients/bybit/utils.rs | 6 +- crypto-ws-client/src/clients/coinbase_pro.rs | 12 ++- crypto-ws-client/src/clients/deribit.rs | 6 +- .../src/clients/dydx/dydx_swap.rs | 12 +-- crypto-ws-client/src/clients/ftx.rs | 6 +- crypto-ws-client/src/clients/gate/utils.rs | 36 ++++--- crypto-ws-client/src/clients/huobi.rs | 12 +-- .../src/clients/kraken/kraken_futures.rs | 6 +- .../src/clients/kraken/kraken_spot.rs | 10 +- .../src/clients/kucoin/kucoin_spot.rs | 18 ++-- .../src/clients/kucoin/kucoin_swap.rs | 18 ++-- .../src/clients/mexc/mexc_spot.rs | 10 +- .../src/clients/mexc/mexc_swap.rs | 10 +- crypto-ws-client/src/clients/okx.rs | 6 +- crypto-ws-client/src/clients/zb/zb_spot.rs | 6 +- crypto-ws-client/src/clients/zb/zb_swap.rs | 6 +- crypto-ws-client/src/clients/zbg/zbg_spot.rs | 6 +- crypto-ws-client/src/clients/zbg/zbg_swap.rs | 12 +-- crypto-ws-client/tests/binance.rs | 96 ++++++++++++------- crypto-ws-client/tests/binance_option.rs | 42 +++++--- crypto-ws-client/tests/bitfinex.rs | 23 ++--- crypto-ws-client/tests/bitget.rs | 6 +- crypto-ws-client/tests/bithumb.rs | 6 +- crypto-ws-client/tests/bitmex.rs | 36 +++---- crypto-ws-client/tests/bitstamp.rs | 12 ++- crypto-ws-client/tests/bitz.rs | 12 +-- crypto-ws-client/tests/bybit.rs | 10 +- crypto-ws-client/tests/coinbase_pro.rs | 6 +- crypto-ws-client/tests/deribit.rs | 17 ++-- crypto-ws-client/tests/dydx.rs | 6 +- crypto-ws-client/tests/ftx.rs | 24 +---- crypto-ws-client/tests/gate.rs | 34 +++---- crypto-ws-client/tests/huobi.rs | 53 ++++------ crypto-ws-client/tests/kraken.rs | 24 +++-- crypto-ws-client/tests/kucoin.rs | 54 +++++------ crypto-ws-client/tests/mexc.rs | 60 ++++++------ crypto-ws-client/tests/okx.rs | 40 ++------ crypto-ws-client/tests/zb.rs | 24 ++--- crypto-ws-client/tests/zbg.rs | 48 +++++----- 47 files changed, 464 insertions(+), 434 deletions(-) diff --git a/crypto-pair/tests/kraken.rs b/crypto-pair/tests/kraken.rs index e3e184f9..2bf8d73a 100644 --- a/crypto-pair/tests/kraken.rs +++ b/crypto-pair/tests/kraken.rs @@ -75,9 +75,8 @@ struct FuturesResponse { fn fetch_futures_markets_raw() -> Vec { let txt = http_get("https://futures.kraken.com/derivatives/api/v3/instruments").unwrap(); let obj = serde_json::from_str::>(&txt).unwrap(); - - obj - .instruments + + obj.instruments .into_iter() .filter(|x| x.tradeable) .filter(|m| m.symbol.starts_with("pi_") || m.symbol.starts_with("fi_")) diff --git a/crypto-ws-client/src/clients/binance.rs b/crypto-ws-client/src/clients/binance.rs index 78e5adf2..ce475238 100644 --- a/crypto-ws-client/src/clients/binance.rs +++ b/crypto-ws-client/src/clients/binance.rs @@ -311,8 +311,10 @@ mod tests { let translator = super::BinanceCommandTranslator { market_type: 'S' }; let commands = translator.translate_to_commands( true, - &[("aggTrade".to_string(), "BTCUSDT".to_string()), - ("ticker".to_string(), "BTCUSDT".to_string())], + &[ + ("aggTrade".to_string(), "BTCUSDT".to_string()), + ("ticker".to_string(), "BTCUSDT".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/binance_option.rs b/crypto-ws-client/src/clients/binance_option.rs index c3ba1d0f..118c86d5 100644 --- a/crypto-ws-client/src/clients/binance_option.rs +++ b/crypto-ws-client/src/clients/binance_option.rs @@ -174,8 +174,10 @@ mod tests { let translator = super::BinanceOptionCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trade".to_string(), "BTC-220429-50000-C".to_string()), - ("ticker".to_string(), "BTC-220429-50000-C".to_string())], + &[ + ("trade".to_string(), "BTC-220429-50000-C".to_string()), + ("ticker".to_string(), "BTC-220429-50000-C".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bitfinex.rs b/crypto-ws-client/src/clients/bitfinex.rs index ae42ad8e..543b5c36 100644 --- a/crypto-ws-client/src/clients/bitfinex.rs +++ b/crypto-ws-client/src/clients/bitfinex.rs @@ -315,10 +315,8 @@ mod tests { #[test] fn test_swap_command() { let translator = super::BitfinexCommandTranslator {}; - let commands = translator.translate_to_commands( - true, - &[("trades".to_string(), "tBTCF0:USTF0".to_string())], - ); + let commands = translator + .translate_to_commands(true, &[("trades".to_string(), "tBTCF0:USTF0".to_string())]); assert_eq!(1, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/bitget/utils.rs b/crypto-ws-client/src/clients/bitget/utils.rs index f1a7e436..df56efa3 100644 --- a/crypto-ws-client/src/clients/bitget/utils.rs +++ b/crypto-ws-client/src/clients/bitget/utils.rs @@ -157,8 +157,8 @@ mod tests { #[test] fn test_one_topic() { let translator = super::BitgetCommandTranslator::<'S'> {}; - let commands = translator - .translate_to_commands(true, &[("trade".to_string(), "BTCUSDT".to_string())]); + let commands = + translator.translate_to_commands(true, &[("trade".to_string(), "BTCUSDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -172,8 +172,10 @@ mod tests { let translator = super::BitgetCommandTranslator::<'S'> {}; let commands = translator.translate_to_commands( true, - &[("trade".to_string(), "BTCUSDT".to_string()), - ("books".to_string(), "ETHUSDT".to_string())], + &[ + ("trade".to_string(), "BTCUSDT".to_string()), + ("books".to_string(), "ETHUSDT".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bithumb.rs b/crypto-ws-client/src/clients/bithumb.rs index 373164e2..8aef759d 100644 --- a/crypto-ws-client/src/clients/bithumb.rs +++ b/crypto-ws-client/src/clients/bithumb.rs @@ -131,8 +131,10 @@ mod tests { let translator = super::BithumbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("TRADE".to_string(), "BTC-USDT".to_string()), - ("TRADE".to_string(), "ETH-USDT".to_string())], + &[ + ("TRADE".to_string(), "BTC-USDT".to_string()), + ("TRADE".to_string(), "ETH-USDT".to_string()), + ], ); assert_eq!(1, commands.len()); @@ -147,8 +149,10 @@ mod tests { let translator = super::BithumbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("TRADE".to_string(), "BTC-USDT".to_string()), - ("ORDERBOOK".to_string(), "BTC-USDT".to_string())], + &[ + ("TRADE".to_string(), "BTC-USDT".to_string()), + ("ORDERBOOK".to_string(), "BTC-USDT".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bitmex.rs b/crypto-ws-client/src/clients/bitmex.rs index a3de3b3e..a7460743 100644 --- a/crypto-ws-client/src/clients/bitmex.rs +++ b/crypto-ws-client/src/clients/bitmex.rs @@ -177,8 +177,8 @@ mod tests { #[test] fn test_one_topic() { let translator = super::BitmexCommandTranslator {}; - let commands = translator - .translate_to_commands(true, &[("trade".to_string(), "XBTUSD".to_string())]); + let commands = + translator.translate_to_commands(true, &[("trade".to_string(), "XBTUSD".to_string())]); assert_eq!(1, commands.len()); assert_eq!(r#"{"op":"subscribe","args":["trade:XBTUSD"]}"#, commands[0]); @@ -189,10 +189,12 @@ mod tests { let translator = super::BitmexCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trade".to_string(), "XBTUSD".to_string()), + &[ + ("trade".to_string(), "XBTUSD".to_string()), ("quote".to_string(), "XBTUSD".to_string()), ("orderBookL2_25".to_string(), "XBTUSD".to_string()), - ("tradeBin1m".to_string(), "XBTUSD".to_string())], + ("tradeBin1m".to_string(), "XBTUSD".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/bitstamp.rs b/crypto-ws-client/src/clients/bitstamp.rs index 40b4f405..85973fe3 100644 --- a/crypto-ws-client/src/clients/bitstamp.rs +++ b/crypto-ws-client/src/clients/bitstamp.rs @@ -131,10 +131,8 @@ mod tests { #[test] fn test_one_topic() { let translator = super::BitstampCommandTranslator {}; - let commands = translator.translate_to_commands( - true, - &[("live_trades".to_string(), "btcusd".to_string())], - ); + let commands = translator + .translate_to_commands(true, &[("live_trades".to_string(), "btcusd".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -148,8 +146,10 @@ mod tests { let translator = super::BitstampCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("live_trades".to_string(), "btcusd".to_string()), - ("diff_order_book".to_string(), "btcusd".to_string())], + &[ + ("live_trades".to_string(), "btcusd".to_string()), + ("diff_order_book".to_string(), "btcusd".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/bybit/utils.rs b/crypto-ws-client/src/clients/bybit/utils.rs index 732fbeb6..a5711a45 100644 --- a/crypto-ws-client/src/clients/bybit/utils.rs +++ b/crypto-ws-client/src/clients/bybit/utils.rs @@ -72,9 +72,11 @@ mod tests { #[test] fn test_multiple_channels() { let command = super::topics_to_command( - &[("trade".to_string(), "BTCUSD".to_string()), + &[ + ("trade".to_string(), "BTCUSD".to_string()), ("orderBookL2_25".to_string(), "BTCUSD".to_string()), - ("instrument_info.100ms".to_string(), "BTCUSD".to_string())], + ("instrument_info.100ms".to_string(), "BTCUSD".to_string()), + ], true, ); diff --git a/crypto-ws-client/src/clients/coinbase_pro.rs b/crypto-ws-client/src/clients/coinbase_pro.rs index 7b1a7f88..a551161c 100644 --- a/crypto-ws-client/src/clients/coinbase_pro.rs +++ b/crypto-ws-client/src/clients/coinbase_pro.rs @@ -162,8 +162,10 @@ mod tests { let translator = super::CoinbaseProCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("matches".to_string(), "BTC-USD".to_string()), - ("matches".to_string(), "ETH-USD".to_string())], + &[ + ("matches".to_string(), "BTC-USD".to_string()), + ("matches".to_string(), "ETH-USD".to_string()), + ], ); assert_eq!(1, commands.len()); @@ -178,8 +180,10 @@ mod tests { let translator = super::CoinbaseProCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("matches".to_string(), "BTC-USD".to_string()), - ("level2".to_string(), "BTC-USD".to_string())], + &[ + ("matches".to_string(), "BTC-USD".to_string()), + ("level2".to_string(), "BTC-USD".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/deribit.rs b/crypto-ws-client/src/clients/deribit.rs index cbf814f1..f27e3ec9 100644 --- a/crypto-ws-client/src/clients/deribit.rs +++ b/crypto-ws-client/src/clients/deribit.rs @@ -206,8 +206,10 @@ mod tests { let translator = super::DeribitCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trades.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string()), - ("ticker.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string())], + &[ + ("trades.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string()), + ("ticker.SYMBOL.100ms".to_string(), "BTC-26MAR21".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/dydx/dydx_swap.rs b/crypto-ws-client/src/clients/dydx/dydx_swap.rs index cd4ca176..da789e84 100644 --- a/crypto-ws-client/src/clients/dydx/dydx_swap.rs +++ b/crypto-ws-client/src/clients/dydx/dydx_swap.rs @@ -131,10 +131,8 @@ mod tests { #[test] fn test_one_topic() { let translator = super::DydxCommandTranslator {}; - let commands = translator.translate_to_commands( - true, - &[("v3_trades".to_string(), "BTC-USD".to_string())], - ); + let commands = translator + .translate_to_commands(true, &[("v3_trades".to_string(), "BTC-USD".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -148,8 +146,10 @@ mod tests { let translator = super::DydxCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("v3_trades".to_string(), "BTC-USD".to_string()), - ("v3_orderbook".to_string(), "BTC-USD".to_string())], + &[ + ("v3_trades".to_string(), "BTC-USD".to_string()), + ("v3_orderbook".to_string(), "BTC-USD".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/ftx.rs b/crypto-ws-client/src/clients/ftx.rs index 79796a0c..84140b0e 100644 --- a/crypto-ws-client/src/clients/ftx.rs +++ b/crypto-ws-client/src/clients/ftx.rs @@ -142,8 +142,10 @@ mod tests { let translator = super::FtxCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trades".to_string(), "BTC/USD".to_string()), - ("orderbook".to_string(), "BTC/USD".to_string())], + &[ + ("trades".to_string(), "BTC/USD".to_string()), + ("orderbook".to_string(), "BTC/USD".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/gate/utils.rs b/crypto-ws-client/src/clients/gate/utils.rs index 56296375..8845a73e 100644 --- a/crypto-ws-client/src/clients/gate/utils.rs +++ b/crypto-ws-client/src/clients/gate/utils.rs @@ -214,15 +214,19 @@ mod tests { r#"{"channel":"spot.trades", "event":"subscribe", "payload":["BTC_USDT","ETH_USDT"]}"#, translator.translate_to_commands( true, - &[("trades".to_string(), "BTC_USDT".to_string()), - ("trades".to_string(), "ETH_USDT".to_string())] + &[ + ("trades".to_string(), "BTC_USDT".to_string()), + ("trades".to_string(), "ETH_USDT".to_string()) + ] )[0] ); let commands = translator.translate_to_commands( true, - &[("order_book".to_string(), "BTC_USDT".to_string()), - ("order_book".to_string(), "ETH_USDT".to_string())], + &[ + ("order_book".to_string(), "BTC_USDT".to_string()), + ("order_book".to_string(), "ETH_USDT".to_string()), + ], ); assert_eq!(2, commands.len()); assert_eq!( @@ -236,8 +240,10 @@ mod tests { let commands = translator.translate_to_commands( true, - &[("order_book_update".to_string(), "BTC_USDT".to_string()), - ("order_book_update".to_string(), "ETH_USDT".to_string())], + &[ + ("order_book_update".to_string(), "BTC_USDT".to_string()), + ("order_book_update".to_string(), "ETH_USDT".to_string()), + ], ); assert_eq!(2, commands.len()); assert_eq!( @@ -258,15 +264,19 @@ mod tests { r#"{"channel":"futures.trades", "event":"subscribe", "payload":["BTC_USD","ETH_USD"]}"#, translator.translate_to_commands( true, - &[("trades".to_string(), "BTC_USD".to_string()), - ("trades".to_string(), "ETH_USD".to_string())] + &[ + ("trades".to_string(), "BTC_USD".to_string()), + ("trades".to_string(), "ETH_USD".to_string()) + ] )[0] ); let commands = translator.translate_to_commands( true, - &[("order_book".to_string(), "BTC_USD".to_string()), - ("order_book".to_string(), "ETH_USD".to_string())], + &[ + ("order_book".to_string(), "BTC_USD".to_string()), + ("order_book".to_string(), "ETH_USD".to_string()), + ], ); assert_eq!(2, commands.len()); assert_eq!( @@ -280,8 +290,10 @@ mod tests { let commands = translator.translate_to_commands( true, - &[("order_book_update".to_string(), "BTC_USD".to_string()), - ("order_book_update".to_string(), "ETH_USD".to_string())], + &[ + ("order_book_update".to_string(), "BTC_USD".to_string()), + ("order_book_update".to_string(), "ETH_USD".to_string()), + ], ); assert_eq!(2, commands.len()); assert_eq!( diff --git a/crypto-ws-client/src/clients/huobi.rs b/crypto-ws-client/src/clients/huobi.rs index ac4bcf58..812b618e 100644 --- a/crypto-ws-client/src/clients/huobi.rs +++ b/crypto-ws-client/src/clients/huobi.rs @@ -333,10 +333,8 @@ mod tests { #[test] fn test_one_topic() { let translator = super::HuobiCommandTranslator {}; - let commands = translator.translate_to_commands( - true, - &[("trade.detail".to_string(), "btcusdt".to_string())], - ); + let commands = translator + .translate_to_commands(true, &[("trade.detail".to_string(), "btcusdt".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -350,8 +348,10 @@ mod tests { let translator = super::HuobiCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trade.detail".to_string(), "btcusdt".to_string()), - ("bbo".to_string(), "btcusdt".to_string())], + &[ + ("trade.detail".to_string(), "btcusdt".to_string()), + ("bbo".to_string(), "btcusdt".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/kraken/kraken_futures.rs b/crypto-ws-client/src/clients/kraken/kraken_futures.rs index 677e2620..e7cb6841 100644 --- a/crypto-ws-client/src/clients/kraken/kraken_futures.rs +++ b/crypto-ws-client/src/clients/kraken/kraken_futures.rs @@ -166,8 +166,10 @@ mod tests { let translator = super::KrakenCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trade".to_string(), "PI_XBTUSD".to_string()), - ("trade".to_string(), "PI_ETHUSD".to_string())], + &[ + ("trade".to_string(), "PI_XBTUSD".to_string()), + ("trade".to_string(), "PI_ETHUSD".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/kraken/kraken_spot.rs b/crypto-ws-client/src/clients/kraken/kraken_spot.rs index 57c3a53d..93c745e4 100644 --- a/crypto-ws-client/src/clients/kraken/kraken_spot.rs +++ b/crypto-ws-client/src/clients/kraken/kraken_spot.rs @@ -250,8 +250,8 @@ mod tests { #[test] fn test_one_symbol() { let translator = super::KrakenCommandTranslator {}; - let commands = translator - .translate_to_commands(true, &[("trade".to_string(), "XBT/USD".to_string())]); + let commands = + translator.translate_to_commands(true, &[("trade".to_string(), "XBT/USD".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -265,8 +265,10 @@ mod tests { let translator = super::KrakenCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trade".to_string(), "XBT/USD".to_string()), - ("trade".to_string(), "ETH/USD".to_string())], + &[ + ("trade".to_string(), "XBT/USD".to_string()), + ("trade".to_string(), "ETH/USD".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs b/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs index 8ea44245..7663cdcb 100644 --- a/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs +++ b/crypto-ws-client/src/clients/kucoin/kucoin_spot.rs @@ -132,8 +132,10 @@ mod tests { let commands = translator.translate_to_commands( true, - &[("/market/match".to_string(), "BTC-USDT".to_string()), - ("/market/match".to_string(), "ETH-USDT".to_string())], + &[ + ("/market/match".to_string(), "BTC-USDT".to_string()), + ("/market/match".to_string(), "ETH-USDT".to_string()), + ], ); assert_eq!(1, commands.len()); @@ -148,8 +150,10 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("/market/match".to_string(), "BTC-USDT".to_string()), - ("/market/level2".to_string(), "ETH-USDT".to_string())], + &[ + ("/market/match".to_string(), "BTC-USDT".to_string()), + ("/market/level2".to_string(), "ETH-USDT".to_string()), + ], ); assert_eq!(2, commands.len()); @@ -164,10 +168,12 @@ mod tests { let commands = translator.translate_to_commands( true, - &[("/market/match".to_string(), "BTC-USDT".to_string()), + &[ + ("/market/match".to_string(), "BTC-USDT".to_string()), ("/market/match".to_string(), "ETH-USDT".to_string()), ("/market/level2".to_string(), "BTC-USDT".to_string()), - ("/market/level2".to_string(), "ETH-USDT".to_string())], + ("/market/level2".to_string(), "ETH-USDT".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs b/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs index eff0a5a5..3469cf4d 100644 --- a/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs +++ b/crypto-ws-client/src/clients/kucoin/kucoin_swap.rs @@ -131,14 +131,16 @@ mod tests { let commands = translator.translate_to_commands( true, - &[( + &[ + ( "/contractMarket/execution".to_string(), "BTC_USD".to_string(), ), ( "/contractMarket/execution".to_string(), "ETH_USD".to_string(), - )], + ), + ], ); assert_eq!(1, commands.len()); @@ -153,11 +155,13 @@ mod tests { let translator = super::KucoinCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[( + &[ + ( "/contractMarket/execution".to_string(), "BTC_USD".to_string(), ), - ("/contractMarket/level2".to_string(), "ETH_USD".to_string())], + ("/contractMarket/level2".to_string(), "ETH_USD".to_string()), + ], ); assert_eq!(2, commands.len()); @@ -172,7 +176,8 @@ mod tests { let commands = translator.translate_to_commands( true, - &[( + &[ + ( "/contractMarket/execution".to_string(), "BTC_USD".to_string(), ), @@ -181,7 +186,8 @@ mod tests { "ETH_USD".to_string(), ), ("/contractMarket/level2".to_string(), "BTC_USD".to_string()), - ("/contractMarket/level2".to_string(), "ETH_USD".to_string())], + ("/contractMarket/level2".to_string(), "ETH_USD".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/mexc/mexc_spot.rs b/crypto-ws-client/src/clients/mexc/mexc_spot.rs index 5cf2a95e..a26d852d 100644 --- a/crypto-ws-client/src/clients/mexc/mexc_spot.rs +++ b/crypto-ws-client/src/clients/mexc/mexc_spot.rs @@ -166,8 +166,8 @@ mod tests { #[test] fn test_one_topic() { let translator = super::MexcCommandTranslator {}; - let commands = translator - .translate_to_commands(true, &[("deal".to_string(), "BTC_USDT".to_string())]); + let commands = + translator.translate_to_commands(true, &[("deal".to_string(), "BTC_USDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!(r#"{"op":"sub.deal","symbol":"BTC_USDT"}"#, commands[0]); @@ -178,8 +178,10 @@ mod tests { let translator = super::MexcCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("deal".to_string(), "BTC_USDT".to_string()), - ("depth".to_string(), "ETH_USDT".to_string())], + &[ + ("deal".to_string(), "BTC_USDT".to_string()), + ("depth".to_string(), "ETH_USDT".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/mexc/mexc_swap.rs b/crypto-ws-client/src/clients/mexc/mexc_swap.rs index 79d19f34..49b139d6 100644 --- a/crypto-ws-client/src/clients/mexc/mexc_swap.rs +++ b/crypto-ws-client/src/clients/mexc/mexc_swap.rs @@ -153,8 +153,8 @@ mod tests { #[test] fn test_one_topic() { let translator = super::MexcCommandTranslator {}; - let commands = translator - .translate_to_commands(true, &[("deal".to_string(), "BTC_USDT".to_string())]); + let commands = + translator.translate_to_commands(true, &[("deal".to_string(), "BTC_USDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -168,8 +168,10 @@ mod tests { let translator = super::MexcCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("deal".to_string(), "BTC_USDT".to_string()), - ("depth".to_string(), "ETH_USDT".to_string())], + &[ + ("deal".to_string(), "BTC_USDT".to_string()), + ("depth".to_string(), "ETH_USDT".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/okx.rs b/crypto-ws-client/src/clients/okx.rs index 9d4fde7c..7cc8ec11 100644 --- a/crypto-ws-client/src/clients/okx.rs +++ b/crypto-ws-client/src/clients/okx.rs @@ -231,8 +231,10 @@ mod tests { let translator = super::OkxCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trades".to_string(), "BTC-USDT".to_string()), - ("tickers".to_string(), "BTC-USDT".to_string())], + &[ + ("trades".to_string(), "BTC-USDT".to_string()), + ("tickers".to_string(), "BTC-USDT".to_string()), + ], ); assert_eq!(1, commands.len()); diff --git a/crypto-ws-client/src/clients/zb/zb_spot.rs b/crypto-ws-client/src/clients/zb/zb_spot.rs index 2e2fc481..e02364f8 100644 --- a/crypto-ws-client/src/clients/zb/zb_spot.rs +++ b/crypto-ws-client/src/clients/zb/zb_spot.rs @@ -171,8 +171,10 @@ mod tests { let translator = super::ZbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("trades".to_string(), "btc_usdt".to_string()), - ("depth".to_string(), "eth_usdt".to_string())], + &[ + ("trades".to_string(), "btc_usdt".to_string()), + ("depth".to_string(), "eth_usdt".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/zb/zb_swap.rs b/crypto-ws-client/src/clients/zb/zb_swap.rs index 85255652..775ebdac 100644 --- a/crypto-ws-client/src/clients/zb/zb_swap.rs +++ b/crypto-ws-client/src/clients/zb/zb_swap.rs @@ -192,8 +192,10 @@ mod tests { let translator = super::ZbCommandTranslator {}; let commands = translator.translate_to_commands( true, - &[("Trade".to_string(), "BTC_USDT".to_string()), - ("Depth".to_string(), "ETH_USDT".to_string())], + &[ + ("Trade".to_string(), "BTC_USDT".to_string()), + ("Depth".to_string(), "ETH_USDT".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/zbg/zbg_spot.rs b/crypto-ws-client/src/clients/zbg/zbg_spot.rs index c30e8bf3..893a8197 100644 --- a/crypto-ws-client/src/clients/zbg/zbg_spot.rs +++ b/crypto-ws-client/src/clients/zbg/zbg_spot.rs @@ -167,8 +167,10 @@ mod tests { let translator = super::ZbgCommandTranslator::new().await; let commands = translator.translate_to_commands( true, - &[("TRADE".to_string(), "btc_usdt".to_string()), - ("ENTRUST_ADD".to_string(), "eth_usdt".to_string())], + &[ + ("TRADE".to_string(), "btc_usdt".to_string()), + ("ENTRUST_ADD".to_string(), "eth_usdt".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/src/clients/zbg/zbg_swap.rs b/crypto-ws-client/src/clients/zbg/zbg_swap.rs index bfc8ff80..b4790591 100644 --- a/crypto-ws-client/src/clients/zbg/zbg_swap.rs +++ b/crypto-ws-client/src/clients/zbg/zbg_swap.rs @@ -149,10 +149,8 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn test_one_topic() { let translator = super::ZbgCommandTranslator::new().await; - let commands = translator.translate_to_commands( - true, - &[("future_tick".to_string(), "BTC_USDT".to_string())], - ); + let commands = translator + .translate_to_commands(true, &[("future_tick".to_string(), "BTC_USDT".to_string())]); assert_eq!(1, commands.len()); assert_eq!( @@ -166,8 +164,10 @@ mod tests { let translator = super::ZbgCommandTranslator::new().await; let commands = translator.translate_to_commands( true, - &[("future_tick".to_string(), "BTC_USDT".to_string()), - ("future_snapshot_depth".to_string(), "ETH_USDT".to_string())], + &[ + ("future_tick".to_string(), "BTC_USDT".to_string()), + ("future_snapshot_depth".to_string(), "ETH_USDT".to_string()), + ], ); assert_eq!(2, commands.len()); diff --git a/crypto-ws-client/tests/binance.rs b/crypto-ws-client/tests/binance.rs index b11ac421..35f0dffc 100644 --- a/crypto-ws-client/tests/binance.rs +++ b/crypto-ws-client/tests/binance.rs @@ -10,8 +10,10 @@ mod binance_spot { gen_test_code!( BinanceSpotWSClient, subscribe, - &[("aggTrade".to_string(), "BTCUSDT".to_string()), - ("ticker".to_string(), "BTCUSDT".to_string())] + &[ + ("aggTrade".to_string(), "BTCUSDT".to_string()), + ("ticker".to_string(), "BTCUSDT".to_string()) + ] ); } @@ -95,8 +97,10 @@ mod binance_spot { ); gen_test_subscribe_candlestick!( BinanceSpotWSClient, - &[("BTCUSDT".to_string(), 2592000), - ("ETHUSDT".to_string(), 2592000)] + &[ + ("BTCUSDT".to_string(), 2592000), + ("ETHUSDT".to_string(), 2592000) + ] ); } } @@ -110,9 +114,11 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe, - &[("aggTrade".to_string(), "BTCUSD_220930".to_string()), + &[ + ("aggTrade".to_string(), "BTCUSD_220930".to_string()), ("aggTrade".to_string(), "ETHUSD_220930".to_string()), - ("aggTrade".to_string(), "BNBUSD_220930".to_string())] + ("aggTrade".to_string(), "BNBUSD_220930".to_string()) + ] ); } @@ -130,9 +136,11 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_trade, - &["BTCUSD_220930".to_string(), + &[ + "BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string()] + "BNBUSD_220930".to_string() + ] ); } @@ -141,9 +149,11 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_ticker, - &["BTCUSD_220930".to_string(), + &[ + "BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string()] + "BNBUSD_220930".to_string() + ] ); } @@ -161,9 +171,11 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_bbo, - &["BTCUSD_220930".to_string(), + &[ + "BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string()] + "BNBUSD_220930".to_string() + ] ); } @@ -172,9 +184,11 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_orderbook, - &["BTCUSD_220930".to_string(), + &[ + "BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string()] + "BNBUSD_220930".to_string() + ] ); } @@ -183,9 +197,11 @@ mod binance_inverse_future { gen_test_code!( BinanceInverseWSClient, subscribe_orderbook_topk, - &["BTCUSD_220930".to_string(), + &[ + "BTCUSD_220930".to_string(), "ETHUSD_220930".to_string(), - "BNBUSD_220930".to_string()] + "BNBUSD_220930".to_string() + ] ); } @@ -193,15 +209,19 @@ mod binance_inverse_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &[("BTCUSD_220930".to_string(), 60), + &[ + ("BTCUSD_220930".to_string(), 60), ("ETHUSD_220930".to_string(), 60), - ("BNBUSD_220930".to_string(), 60)] + ("BNBUSD_220930".to_string(), 60) + ] ); gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &[("BTCUSD_220930".to_string(), 2592000), + &[ + ("BTCUSD_220930".to_string(), 2592000), ("ETHUSD_220930".to_string(), 2592000), - ("BNBUSD_220930".to_string(), 2592000)] + ("BNBUSD_220930".to_string(), 2592000) + ] ); } } @@ -215,8 +235,10 @@ mod binance_linear_future { gen_test_code!( BinanceLinearWSClient, subscribe, - &[("aggTrade".to_string(), "BTCUSDT_220930".to_string()), - ("aggTrade".to_string(), "ETHUSDT_220930".to_string())] + &[ + ("aggTrade".to_string(), "BTCUSDT_220930".to_string()), + ("aggTrade".to_string(), "ETHUSDT_220930".to_string()) + ] ); } @@ -287,13 +309,17 @@ mod binance_linear_future { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceLinearWSClient, - &[("BTCUSDT_220930".to_string(), 60), - ("ETHUSDT_220930".to_string(), 60)] + &[ + ("BTCUSDT_220930".to_string(), 60), + ("ETHUSDT_220930".to_string(), 60) + ] ); gen_test_subscribe_candlestick!( BinanceLinearWSClient, - &[("BTCUSDT_220930".to_string(), 2592000), - ("ETHUSDT_220930".to_string(), 2592000)] + &[ + ("BTCUSDT_220930".to_string(), 2592000), + ("ETHUSDT_220930".to_string(), 2592000) + ] ); } } @@ -378,13 +404,17 @@ mod binance_inverse_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &[("btcusd_perp".to_string(), 60), - ("ethusd_perp".to_string(), 60)] + &[ + ("btcusd_perp".to_string(), 60), + ("ethusd_perp".to_string(), 60) + ] ); gen_test_subscribe_candlestick!( BinanceInverseWSClient, - &[("btcusd_perp".to_string(), 2592000), - ("ethusd_perp".to_string(), 2592000)] + &[ + ("btcusd_perp".to_string(), 2592000), + ("ethusd_perp".to_string(), 2592000) + ] ); } @@ -491,8 +521,10 @@ mod binance_linear_swap { ); gen_test_subscribe_candlestick!( BinanceLinearWSClient, - &[("BTCUSDT".to_string(), 2592000), - ("ETHUSDT".to_string(), 2592000)] + &[ + ("BTCUSDT".to_string(), 2592000), + ("ETHUSDT".to_string(), 2592000) + ] ); } diff --git a/crypto-ws-client/tests/binance_option.rs b/crypto-ws-client/tests/binance_option.rs index f3abc753..23da77a3 100644 --- a/crypto-ws-client/tests/binance_option.rs +++ b/crypto-ws-client/tests/binance_option.rs @@ -9,9 +9,11 @@ async fn subscribe() { gen_test_code!( BinanceOptionWSClient, subscribe, - &[("TICKER_ALL".to_string(), "BTCUSDT".to_string()), + &[ + ("TICKER_ALL".to_string(), "BTCUSDT".to_string()), ("TRADE_ALL".to_string(), "BTCUSDT_C".to_string()), - ("TRADE_ALL".to_string(), "BTCUSDT_P".to_string())] + ("TRADE_ALL".to_string(), "BTCUSDT_P".to_string()) + ] ); } @@ -21,8 +23,10 @@ async fn subscribe_trade() { gen_test_code!( BinanceOptionWSClient, subscribe_trade, - &["BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string()] + &[ + "BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string() + ] ); } @@ -32,8 +36,10 @@ async fn subscribe_ticker() { gen_test_code!( BinanceOptionWSClient, subscribe_ticker, - &["BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string()] + &[ + "BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string() + ] ); } @@ -53,8 +59,10 @@ async fn subscribe_orderbook() { gen_test_code!( BinanceOptionWSClient, subscribe_orderbook, - &["BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string()] + &[ + "BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string() + ] ); } @@ -64,8 +72,10 @@ async fn subscribe_orderbook_topk() { gen_test_code!( BinanceOptionWSClient, subscribe_orderbook_topk, - &["BTC-220325-40000-C".to_string(), - "BTC-220325-35000-P".to_string()] + &[ + "BTC-220325-40000-C".to_string(), + "BTC-220325-35000-P".to_string() + ] ); } @@ -74,12 +84,16 @@ async fn subscribe_orderbook_topk() { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( BinanceOptionWSClient, - &[("BTC-220325-40000-C".to_string(), 60), - ("BTC-220325-35000-P".to_string(), 60)] + &[ + ("BTC-220325-40000-C".to_string(), 60), + ("BTC-220325-35000-P".to_string(), 60) + ] ); gen_test_subscribe_candlestick!( BinanceOptionWSClient, - &[("BTC-220325-40000-C".to_string(), 60), - ("BTC-220325-35000-P".to_string(), 60)] + &[ + ("BTC-220325-40000-C".to_string(), 60), + ("BTC-220325-35000-P".to_string(), 60) + ] ); } diff --git a/crypto-ws-client/tests/bitfinex.rs b/crypto-ws-client/tests/bitfinex.rs index 6ce1edd8..9d34fdfb 100644 --- a/crypto-ws-client/tests/bitfinex.rs +++ b/crypto-ws-client/tests/bitfinex.rs @@ -10,8 +10,10 @@ mod bitfinex_spot { gen_test_code!( BitfinexWSClient, subscribe, - &[("trades".to_string(), "tBTCUST".to_string()), - ("trades".to_string(), "tETHUST".to_string())] + &[ + ("trades".to_string(), "tBTCUST".to_string()), + ("trades".to_string(), "tETHUST".to_string()) + ] ); } @@ -36,20 +38,12 @@ mod bitfinex_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_ticker() { - gen_test_code!( - BitfinexWSClient, - subscribe_ticker, - &["tBTCUST".to_string()] - ); + gen_test_code!(BitfinexWSClient, subscribe_ticker, &["tBTCUST".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - BitfinexWSClient, - subscribe_bbo, - &["tBTCUST".to_string()] - ); + gen_test_code!(BitfinexWSClient, subscribe_bbo, &["tBTCUST".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -138,9 +132,6 @@ mod bitfinex_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { gen_test_subscribe_candlestick!(BitfinexWSClient, &[("tBTCF0:USTF0".to_string(), 60)]); - gen_test_subscribe_candlestick!( - BitfinexWSClient, - &[("tBTCF0:USTF0".to_string(), 2592000)] - ); + gen_test_subscribe_candlestick!(BitfinexWSClient, &[("tBTCF0:USTF0".to_string(), 2592000)]); } } diff --git a/crypto-ws-client/tests/bitget.rs b/crypto-ws-client/tests/bitget.rs index aecd20cc..ad42242b 100644 --- a/crypto-ws-client/tests/bitget.rs +++ b/crypto-ws-client/tests/bitget.rs @@ -72,11 +72,7 @@ mod bitget_inverse_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - BitgetSwapWSClient, - subscribe_trade, - &["BTCUSD".to_string()] - ); + gen_test_code!(BitgetSwapWSClient, subscribe_trade, &["BTCUSD".to_string()]); } #[tokio::test(flavor = "multi_thread")] diff --git a/crypto-ws-client/tests/bithumb.rs b/crypto-ws-client/tests/bithumb.rs index 871ce08f..7be2ca89 100644 --- a/crypto-ws-client/tests/bithumb.rs +++ b/crypto-ws-client/tests/bithumb.rs @@ -9,8 +9,10 @@ async fn subscribe() { gen_test_code!( BithumbWSClient, subscribe, - &[("TRADE".to_string(), "BTC-USDT".to_string()), - ("TRADE".to_string(), "ETH-USDT".to_string())] + &[ + ("TRADE".to_string(), "BTC-USDT".to_string()), + ("TRADE".to_string(), "ETH-USDT".to_string()) + ] ); } diff --git a/crypto-ws-client/tests/bitmex.rs b/crypto-ws-client/tests/bitmex.rs index a3a016fa..e391dd77 100644 --- a/crypto-ws-client/tests/bitmex.rs +++ b/crypto-ws-client/tests/bitmex.rs @@ -21,8 +21,10 @@ mod bitmex_inverse_swap { gen_test_code!( BitmexWSClient, subscribe, - &[("trade".to_string(), "XBTUSD".to_string()), - ("quote".to_string(), "XBTUSD".to_string())] + &[ + ("trade".to_string(), "XBTUSD".to_string()), + ("quote".to_string(), "XBTUSD".to_string()) + ] ); } @@ -47,11 +49,7 @@ mod bitmex_inverse_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_orderbook() { - gen_test_code!( - BitmexWSClient, - subscribe_orderbook, - &["XBTUSD".to_string()] - ); + gen_test_code!(BitmexWSClient, subscribe_orderbook, &["XBTUSD".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -107,8 +105,10 @@ mod bitmex_inverse_future { gen_test_code!( BitmexWSClient, subscribe, - &[("trade".to_string(), "XBTU22".to_string()), - ("quote".to_string(), "XBTU22".to_string())] + &[ + ("trade".to_string(), "XBTU22".to_string()), + ("quote".to_string(), "XBTU22".to_string()) + ] ); } @@ -177,11 +177,7 @@ mod bitmex_quanto_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_orderbook() { - gen_test_code!( - BitmexWSClient, - subscribe_orderbook, - &["ETHUSD".to_string()] - ); + gen_test_code!(BitmexWSClient, subscribe_orderbook, &["ETHUSD".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -219,9 +215,11 @@ mod bitmex_linear_future { gen_test_code!( BitmexWSClient, subscribe_trade, - &["XBTUSDTU22".to_string(), + &[ + "XBTUSDTU22".to_string(), "ETHU22".to_string(), - "ETHUSDTU22".to_string()] + "ETHUSDTU22".to_string() + ] ); } @@ -232,11 +230,7 @@ mod bitmex_linear_future { #[tokio::test(flavor = "multi_thread")] async fn subscribe_orderbook() { - gen_test_code!( - BitmexWSClient, - subscribe_orderbook, - &["ETHU22".to_string()] - ); + gen_test_code!(BitmexWSClient, subscribe_orderbook, &["ETHU22".to_string()]); } #[tokio::test(flavor = "multi_thread")] diff --git a/crypto-ws-client/tests/bitstamp.rs b/crypto-ws-client/tests/bitstamp.rs index 08209d28..0885b704 100644 --- a/crypto-ws-client/tests/bitstamp.rs +++ b/crypto-ws-client/tests/bitstamp.rs @@ -8,8 +8,10 @@ async fn subscribe() { gen_test_code!( BitstampWSClient, subscribe, - &[("live_trades".to_string(), "btcusd".to_string()), - ("diff_order_book".to_string(), "btcusd".to_string())] + &[ + ("live_trades".to_string(), "btcusd".to_string()), + ("diff_order_book".to_string(), "btcusd".to_string()) + ] ); } @@ -18,8 +20,10 @@ async fn subscribe_raw_json() { gen_test_code!( BitstampWSClient, send, - &[r#"{"event":"bts:subscribe","data":{"channel":"live_trades_btcusd"}}"#.to_string(), - r#"{"event":"bts:subscribe","data":{"channel":"live_trades_ethusd"}}"#.to_string()] + &[ + r#"{"event":"bts:subscribe","data":{"channel":"live_trades_btcusd"}}"#.to_string(), + r#"{"event":"bts:subscribe","data":{"channel":"live_trades_ethusd"}}"#.to_string() + ] ); } diff --git a/crypto-ws-client/tests/bitz.rs b/crypto-ws-client/tests/bitz.rs index 428fec69..95c5985c 100644 --- a/crypto-ws-client/tests/bitz.rs +++ b/crypto-ws-client/tests/bitz.rs @@ -12,9 +12,11 @@ mod bitz_spot { gen_test_code!( BitzSpotWSClient, subscribe, - &[("market".to_string(), "btc_usdt".to_string()), + &[ + ("market".to_string(), "btc_usdt".to_string()), ("depth".to_string(), "btc_usdt".to_string()), - ("order".to_string(), "btc_usdt".to_string())] + ("order".to_string(), "btc_usdt".to_string()) + ] ); } @@ -37,11 +39,7 @@ mod bitz_spot { #[tokio::test(flavor = "multi_thread")] #[ignore = "bitz.com has shutdown since October 2021"] async fn subscribe_trade() { - gen_test_code!( - BitzSpotWSClient, - subscribe_trade, - &["btc_usdt".to_string()] - ); + gen_test_code!(BitzSpotWSClient, subscribe_trade, &["btc_usdt".to_string()]); } #[tokio::test(flavor = "multi_thread")] diff --git a/crypto-ws-client/tests/bybit.rs b/crypto-ws-client/tests/bybit.rs index 401d48ea..e37c12ab 100644 --- a/crypto-ws-client/tests/bybit.rs +++ b/crypto-ws-client/tests/bybit.rs @@ -112,10 +112,7 @@ mod bybit_inverse_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { gen_test_subscribe_candlestick!(BybitInverseWSClient, &[("BTCUSD".to_string(), 60)]); - gen_test_subscribe_candlestick!( - BybitInverseWSClient, - &[("BTCUSD".to_string(), 2592000)] - ); + gen_test_subscribe_candlestick!(BybitInverseWSClient, &[("BTCUSD".to_string(), 2592000)]); } } @@ -152,10 +149,7 @@ mod bybit_linear_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!( - BybitLinearSwapWSClient, - &[("BTCUSDT".to_string(), 60)] - ); + gen_test_subscribe_candlestick!(BybitLinearSwapWSClient, &[("BTCUSDT".to_string(), 60)]); gen_test_subscribe_candlestick!( BybitLinearSwapWSClient, &[("BTCUSDT".to_string(), 2592000)] diff --git a/crypto-ws-client/tests/coinbase_pro.rs b/crypto-ws-client/tests/coinbase_pro.rs index f503277b..0e1f9a43 100644 --- a/crypto-ws-client/tests/coinbase_pro.rs +++ b/crypto-ws-client/tests/coinbase_pro.rs @@ -8,8 +8,10 @@ async fn subscribe() { gen_test_code!( CoinbaseProWSClient, subscribe, - &[("matches".to_string(), "BTC-USD".to_string()), - ("heartbeat".to_string(), "BTC-USD".to_string())] + &[ + ("matches".to_string(), "BTC-USD".to_string()), + ("heartbeat".to_string(), "BTC-USD".to_string()) + ] ); } diff --git a/crypto-ws-client/tests/deribit.rs b/crypto-ws-client/tests/deribit.rs index 173a1a79..35f17d1e 100644 --- a/crypto-ws-client/tests/deribit.rs +++ b/crypto-ws-client/tests/deribit.rs @@ -9,8 +9,10 @@ async fn deribit_all_trades() { DeribitWSClient, subscribe, // https://docs.deribit.com/?javascript#trades-kind-currency-interval - &[("trades.future.SYMBOL.100ms".to_string(), "any".to_string()), - ("trades.option.SYMBOL.100ms".to_string(), "any".to_string())] + &[ + ("trades.future.SYMBOL.100ms".to_string(), "any".to_string()), + ("trades.option.SYMBOL.100ms".to_string(), "any".to_string()) + ] ); } @@ -66,11 +68,7 @@ mod deribit_inverse_future { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - DeribitWSClient, - subscribe_bbo, - &["BTC-30SEP22".to_string()] - ); + gen_test_code!(DeribitWSClient, subscribe_bbo, &["BTC-30SEP22".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -144,10 +142,7 @@ mod deribit_inverse_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { gen_test_subscribe_candlestick!(DeribitWSClient, &[("BTC-PERPETUAL".to_string(), 60)]); - gen_test_subscribe_candlestick!( - DeribitWSClient, - &[("BTC-PERPETUAL".to_string(), 86400)] - ); + gen_test_subscribe_candlestick!(DeribitWSClient, &[("BTC-PERPETUAL".to_string(), 86400)]); } } diff --git a/crypto-ws-client/tests/dydx.rs b/crypto-ws-client/tests/dydx.rs index f3190d7f..46b55b40 100644 --- a/crypto-ws-client/tests/dydx.rs +++ b/crypto-ws-client/tests/dydx.rs @@ -10,8 +10,10 @@ mod dydx_linear_swap { gen_test_code!( DydxSwapWSClient, send, - &[r#"{"type": "subscribe", "channel": "v3_trades", "id": "BTC-USD"}"#.to_string(), - r#"{"type": "subscribe", "channel": "v3_trades", "id": "ETH-USD"}"#.to_string()] + &[ + r#"{"type": "subscribe", "channel": "v3_trades", "id": "BTC-USD"}"#.to_string(), + r#"{"type": "subscribe", "channel": "v3_trades", "id": "ETH-USD"}"#.to_string() + ] ); } diff --git a/crypto-ws-client/tests/ftx.rs b/crypto-ws-client/tests/ftx.rs index 5c40d15d..6897db7a 100644 --- a/crypto-ws-client/tests/ftx.rs +++ b/crypto-ws-client/tests/ftx.rs @@ -35,11 +35,7 @@ mod ftx_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_orderbook() { - gen_test_code!( - FtxWSClient, - subscribe_orderbook, - &["BTC/USD".to_string()] - ); + gen_test_code!(FtxWSClient, subscribe_orderbook, &["BTC/USD".to_string()]); } } @@ -91,11 +87,7 @@ mod ftx_linear_future { #[tokio::test(flavor = "multi_thread")] async fn subscribe_orderbook() { - gen_test_code!( - FtxWSClient, - subscribe_orderbook, - &["BTC-0930".to_string()] - ); + gen_test_code!(FtxWSClient, subscribe_orderbook, &["BTC-0930".to_string()]); } } @@ -115,11 +107,7 @@ mod ftx_move { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - FtxWSClient, - subscribe_bbo, - &["BTC-MOVE-2022Q4".to_string()] - ); + gen_test_code!(FtxWSClient, subscribe_bbo, &["BTC-MOVE-2022Q4".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -149,10 +137,6 @@ mod ftx_bvol { #[tokio::test(flavor = "multi_thread")] async fn subscribe_orderbook() { - gen_test_code!( - FtxWSClient, - subscribe_orderbook, - &["BVOL/USD".to_string()] - ); + gen_test_code!(FtxWSClient, subscribe_orderbook, &["BVOL/USD".to_string()]); } } diff --git a/crypto-ws-client/tests/gate.rs b/crypto-ws-client/tests/gate.rs index 021405e4..096aa5cb 100644 --- a/crypto-ws-client/tests/gate.rs +++ b/crypto-ws-client/tests/gate.rs @@ -10,8 +10,10 @@ mod gate_spot { gen_test_code!( GateSpotWSClient, subscribe, - &[("trades".to_string(), "BTC_USDT".to_string()), - ("trades".to_string(), "ETH_USDT".to_string())] + &[ + ("trades".to_string(), "BTC_USDT".to_string()), + ("trades".to_string(), "ETH_USDT".to_string()) + ] ); } @@ -26,11 +28,7 @@ mod gate_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - GateSpotWSClient, - subscribe_trade, - &["BTC_USDT".to_string()] - ); + gen_test_code!(GateSpotWSClient, subscribe_trade, &["BTC_USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -53,11 +51,7 @@ mod gate_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - GateSpotWSClient, - subscribe_bbo, - &["BTC_USDT".to_string()] - ); + gen_test_code!(GateSpotWSClient, subscribe_bbo, &["BTC_USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -87,10 +81,12 @@ mod gate_inverse_swap { gen_test_code!( GateInverseSwapWSClient, subscribe, - &[("trades".to_string(), "BTC_USD".to_string()), + &[ + ("trades".to_string(), "BTC_USD".to_string()), ("trades".to_string(), "ETH_USD".to_string()), ("trades".to_string(), "BNB_USD".to_string()), - ("trades".to_string(), "XRP_USD".to_string())] + ("trades".to_string(), "XRP_USD".to_string()) + ] ); } @@ -154,10 +150,7 @@ mod gate_inverse_swap { #[ignore] #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!( - GateInverseSwapWSClient, - &[("BTC_USD".to_string(), 10)] - ); + gen_test_subscribe_candlestick!(GateInverseSwapWSClient, &[("BTC_USD".to_string(), 10)]); gen_test_subscribe_candlestick!( GateInverseSwapWSClient, &[("BTC_USD".to_string(), 604800)] @@ -217,10 +210,7 @@ mod gate_linear_swap { #[ignore] #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!( - GateLinearSwapWSClient, - &[("BTC_USDT".to_string(), 10)] - ); + gen_test_subscribe_candlestick!(GateLinearSwapWSClient, &[("BTC_USDT".to_string(), 10)]); gen_test_subscribe_candlestick!( GateLinearSwapWSClient, &[("BTC_USDT".to_string(), 604800)] diff --git a/crypto-ws-client/tests/huobi.rs b/crypto-ws-client/tests/huobi.rs index ddabc719..1fe84ab4 100644 --- a/crypto-ws-client/tests/huobi.rs +++ b/crypto-ws-client/tests/huobi.rs @@ -25,11 +25,7 @@ mod huobi_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - HuobiSpotWSClient, - subscribe_trade, - &["btcusdt".to_string()] - ); + gen_test_code!(HuobiSpotWSClient, subscribe_trade, &["btcusdt".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -43,11 +39,7 @@ mod huobi_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - HuobiSpotWSClient, - subscribe_bbo, - &["btcusdt".to_string()] - ); + gen_test_code!(HuobiSpotWSClient, subscribe_bbo, &["btcusdt".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -63,7 +55,9 @@ mod huobi_spot { ws_client.close(); }); - rx.into_iter().next().expect("should has at least 1 element"); + rx.into_iter() + .next() + .expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] @@ -115,11 +109,7 @@ mod huobi_inverse_future { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - HuobiFutureWSClient, - subscribe_bbo, - &["BTC_CQ".to_string()] - ); + gen_test_code!(HuobiFutureWSClient, subscribe_bbo, &["BTC_CQ".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -143,10 +133,7 @@ mod huobi_inverse_future { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { gen_test_subscribe_candlestick!(HuobiFutureWSClient, &[("BTC_CQ".to_string(), 60)]); - gen_test_subscribe_candlestick!( - HuobiFutureWSClient, - &[("BTC_CQ".to_string(), 2592000)] - ); + gen_test_subscribe_candlestick!(HuobiFutureWSClient, &[("BTC_CQ".to_string(), 2592000)]); } } @@ -210,10 +197,7 @@ mod huobi_linear_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!( - HuobiLinearSwapWSClient, - &[("BTC-USDT".to_string(), 60)] - ); + gen_test_subscribe_candlestick!(HuobiLinearSwapWSClient, &[("BTC-USDT".to_string(), 60)]); gen_test_subscribe_candlestick!( HuobiLinearSwapWSClient, &[("BTC-USDT".to_string(), 2592000)] @@ -237,7 +221,9 @@ mod huobi_linear_swap { ws_client.close(); }); - rx.into_iter().next().expect("should has at least 1 element"); + rx.into_iter() + .next() + .expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] @@ -257,7 +243,9 @@ mod huobi_linear_swap { ws_client.close(); }); - rx.into_iter().next().expect("should has at least 1 element"); + rx.into_iter() + .next() + .expect("should has at least 1 element"); } } @@ -321,10 +309,7 @@ mod huobi_inverse_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!( - HuobiInverseSwapWSClient, - &[("BTC-USD".to_string(), 60)] - ); + gen_test_subscribe_candlestick!(HuobiInverseSwapWSClient, &[("BTC-USD".to_string(), 60)]); gen_test_subscribe_candlestick!( HuobiInverseSwapWSClient, &[("BTC-USD".to_string(), 2592000)] @@ -346,7 +331,9 @@ mod huobi_inverse_swap { ws_client.close(); }); - rx.into_iter().next().expect("should has at least 1 element"); + rx.into_iter() + .next() + .expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] @@ -364,7 +351,9 @@ mod huobi_inverse_swap { ws_client.close(); }); - rx.into_iter().next().expect("should has at least 1 element"); + rx.into_iter() + .next() + .expect("should has at least 1 element"); } #[tokio::test(flavor = "multi_thread")] diff --git a/crypto-ws-client/tests/kraken.rs b/crypto-ws-client/tests/kraken.rs index 707767fb..7d506d35 100644 --- a/crypto-ws-client/tests/kraken.rs +++ b/crypto-ws-client/tests/kraken.rs @@ -10,10 +10,12 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, subscribe, - &[("trade".to_string(), "XBT/USD".to_string()), + &[ + ("trade".to_string(), "XBT/USD".to_string()), ("ticker".to_string(), "XBT/USD".to_string()), ("spread".to_string(), "XBT/USD".to_string()), - ("book".to_string(), "XBT/USD".to_string())] + ("book".to_string(), "XBT/USD".to_string()) + ] ); } @@ -22,8 +24,10 @@ mod kraken_spot { gen_test_code!( KrakenSpotWSClient, send, - &[r#"{"event":"subscribe","pair":["XBT/USD"],"subscription":{"name":"trade"}}"# - .to_string()] + &[ + r#"{"event":"subscribe","pair":["XBT/USD"],"subscription":{"name":"trade"}}"# + .to_string() + ] ); } @@ -72,8 +76,10 @@ mod kraken_spot { gen_test_subscribe_candlestick!( KrakenSpotWSClient, - &[("XBT/USD".to_string(), 1296000), - ("ETH/USD".to_string(), 1296000)] + &[ + ("XBT/USD".to_string(), 1296000), + ("ETH/USD".to_string(), 1296000) + ] ); } } @@ -128,8 +134,10 @@ mod kraken_inverse_future { gen_test_code!( KrakenFuturesWSClient, send, - &[r#"{"event":"subscribe","feed":"trade","product_ids":["FI_XBTUSD_220930"]}"# - .to_string()] + &[ + r#"{"event":"subscribe","feed":"trade","product_ids":["FI_XBTUSD_220930"]}"# + .to_string() + ] ); } diff --git a/crypto-ws-client/tests/kucoin.rs b/crypto-ws-client/tests/kucoin.rs index 10e4ff48..029e1667 100644 --- a/crypto-ws-client/tests/kucoin.rs +++ b/crypto-ws-client/tests/kucoin.rs @@ -43,11 +43,7 @@ mod kucoin_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - KuCoinSpotWSClient, - subscribe_bbo, - &["BTC-USDT".to_string()] - ); + gen_test_code!(KuCoinSpotWSClient, subscribe_bbo, &["BTC-USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -90,8 +86,10 @@ mod kucoin_spot { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KuCoinSpotWSClient, - &[("BTC-USDT".to_string(), 60), - ("BTC-USDT".to_string(), 604800)] + &[ + ("BTC-USDT".to_string(), 60), + ("BTC-USDT".to_string(), 604800) + ] ); } } @@ -105,7 +103,8 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe, - &[( + &[ + ( "/contractMarket/execution".to_string(), "XBTUSDM".to_string() ), @@ -120,7 +119,8 @@ mod kucoin_inverse_swap { ( "/contractMarket/execution".to_string(), "XRPUSDM".to_string() - )] + ) + ] ); } @@ -138,20 +138,18 @@ mod kucoin_inverse_swap { gen_test_code!( KuCoinSwapWSClient, subscribe_trade, - &["XBTUSDM".to_string(), + &[ + "XBTUSDM".to_string(), "ETHUSDM".to_string(), "DOTUSDM".to_string(), - "XRPUSDM".to_string()] + "XRPUSDM".to_string() + ] ); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - KuCoinSwapWSClient, - subscribe_bbo, - &["XBTUSDM".to_string()] - ); + gen_test_code!(KuCoinSwapWSClient, subscribe_bbo, &["XBTUSDM".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -195,10 +193,12 @@ mod kucoin_inverse_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KuCoinSwapWSClient, - &[("XBTUSDM".to_string(), 60), + &[ + ("XBTUSDM".to_string(), 60), ("ETHUSDM".to_string(), 60), ("XBTUSDM".to_string(), 604800), - ("ETHUSDM".to_string(), 604800)] + ("ETHUSDM".to_string(), 604800) + ] ); } } @@ -239,11 +239,7 @@ mod kucoin_linear_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - KuCoinSwapWSClient, - subscribe_bbo, - &["XBTUSDTM".to_string()] - ); + gen_test_code!(KuCoinSwapWSClient, subscribe_bbo, &["XBTUSDTM".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -287,10 +283,12 @@ mod kucoin_linear_swap { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( KuCoinSwapWSClient, - &[("XBTUSDTM".to_string(), 60), + &[ + ("XBTUSDTM".to_string(), 60), ("ETHUSDTM".to_string(), 60), ("XBTUSDTM".to_string(), 604800), - ("ETHUSDTM".to_string(), 604800)] + ("ETHUSDTM".to_string(), 604800) + ] ); } } @@ -335,11 +333,7 @@ mod kucoin_inverse_future { #[ignore] #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - KuCoinSwapWSClient, - subscribe_bbo, - &["XBTMU22".to_string()] - ); + gen_test_code!(KuCoinSwapWSClient, subscribe_bbo, &["XBTMU22".to_string()]); } #[tokio::test(flavor = "multi_thread")] diff --git a/crypto-ws-client/tests/mexc.rs b/crypto-ws-client/tests/mexc.rs index 72134662..fe9e8a26 100644 --- a/crypto-ws-client/tests/mexc.rs +++ b/crypto-ws-client/tests/mexc.rs @@ -10,9 +10,11 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, subscribe, - &[("deal".to_string(), "BTC_USDT".to_string()), + &[ + ("deal".to_string(), "BTC_USDT".to_string()), ("deal".to_string(), "ETH_USDT".to_string()), - ("deal".to_string(), "MX_USDT".to_string())] + ("deal".to_string(), "MX_USDT".to_string()) + ] ); } @@ -21,9 +23,11 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, send, - &[r#"{"op":"sub.deal","symbol":"BTC_USDT"}"#.to_string(), + &[ + r#"{"op":"sub.deal","symbol":"BTC_USDT"}"#.to_string(), r#"{"op":"sub.deal","symbol":"ETH_USDT"}"#.to_string(), - r#"{"op":"sub.deal","symbol":"MX_USDT"}"#.to_string()] + r#"{"op":"sub.deal","symbol":"MX_USDT"}"#.to_string() + ] ); } @@ -32,9 +36,11 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, subscribe_trade, - &["BTC_USDT".to_string(), + &[ + "BTC_USDT".to_string(), "ETH_USDT".to_string(), - "MX_USDT".to_string()] + "MX_USDT".to_string() + ] ); } @@ -43,9 +49,11 @@ mod mexc_spot { gen_test_code!( MexcSpotWSClient, subscribe_orderbook, - &["BTC_USDT".to_string(), + &[ + "BTC_USDT".to_string(), "ETH_USDT".to_string(), - "MX_USDT".to_string()] + "MX_USDT".to_string() + ] ); } @@ -62,15 +70,19 @@ mod mexc_spot { async fn subscribe_candlestick() { gen_test_subscribe_candlestick!( MexcSpotWSClient, - &[("BTC_USDT".to_string(), 60), + &[ + ("BTC_USDT".to_string(), 60), ("ETH_USDT".to_string(), 60), - ("MX_USDT".to_string(), 60)] + ("MX_USDT".to_string(), 60) + ] ); gen_test_subscribe_candlestick!( MexcSpotWSClient, - &[("BTC_USDT".to_string(), 2592000), + &[ + ("BTC_USDT".to_string(), 2592000), ("ETH_USDT".to_string(), 2592000), - ("MX_USDT".to_string(), 2592000)] + ("MX_USDT".to_string(), 2592000) + ] ); } @@ -93,8 +105,10 @@ mod mexc_linear_swap { gen_test_code!( MexcSwapWSClient, subscribe, - &[("deal".to_string(), "BTC_USDT".to_string()), - ("deal".to_string(), "ETH_USDT".to_string())] + &[ + ("deal".to_string(), "BTC_USDT".to_string()), + ("deal".to_string(), "ETH_USDT".to_string()) + ] ); } @@ -109,11 +123,7 @@ mod mexc_linear_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - MexcSwapWSClient, - subscribe_trade, - &["BTC_USDT".to_string()] - ); + gen_test_code!(MexcSwapWSClient, subscribe_trade, &["BTC_USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -156,20 +166,12 @@ mod mexc_inverse_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - MexcSwapWSClient, - subscribe_trade, - &["BTC_USD".to_string()] - ); + gen_test_code!(MexcSwapWSClient, subscribe_trade, &["BTC_USD".to_string()]); } #[tokio::test(flavor = "multi_thread")] async fn subscribe_ticker() { - gen_test_code!( - MexcSwapWSClient, - subscribe_ticker, - &["BTC_USD".to_string()] - ); + gen_test_code!(MexcSwapWSClient, subscribe_ticker, &["BTC_USD".to_string()]); } #[tokio::test(flavor = "multi_thread")] diff --git a/crypto-ws-client/tests/okx.rs b/crypto-ws-client/tests/okx.rs index 5d60f602..fd2163be 100644 --- a/crypto-ws-client/tests/okx.rs +++ b/crypto-ws-client/tests/okx.rs @@ -30,8 +30,10 @@ mod okx_spot { gen_test_code!( OkxWSClient, send, - &[r#"{"op":"subscribe","args":[{"channel":"trades","instId":"BTC-USDT"}]}"# - .to_string()] + &[ + r#"{"op":"subscribe","args":[{"channel":"trades","instId":"BTC-USDT"}]}"# + .to_string() + ] ); } @@ -52,11 +54,7 @@ mod okx_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_orderbook() { - gen_test_code!( - OkxWSClient, - subscribe_orderbook, - &["BTC-USDT".to_string()] - ); + gen_test_code!(OkxWSClient, subscribe_orderbook, &["BTC-USDT".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -108,11 +106,7 @@ mod okx_future { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - OkxWSClient, - subscribe_bbo, - &["BTC-USDT-220930".to_string()] - ); + gen_test_code!(OkxWSClient, subscribe_bbo, &["BTC-USDT-220930".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -136,10 +130,7 @@ mod okx_future { #[tokio::test(flavor = "multi_thread")] async fn subscribe_candlestick() { gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USDT-220930".to_string(), 60)]); - gen_test_subscribe_candlestick!( - OkxWSClient, - &[("BTC-USDT-220930".to_string(), 604800)] - ); + gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USDT-220930".to_string(), 604800)]); } } @@ -158,11 +149,7 @@ mod okx_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - OkxWSClient, - subscribe_trade, - &["BTC-USDT-SWAP".to_string()] - ); + gen_test_code!(OkxWSClient, subscribe_trade, &["BTC-USDT-SWAP".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -176,11 +163,7 @@ mod okx_swap { #[tokio::test(flavor = "multi_thread")] async fn subscribe_bbo() { - gen_test_code!( - OkxWSClient, - subscribe_bbo, - &["BTC-USDT-SWAP".to_string()] - ); + gen_test_code!(OkxWSClient, subscribe_bbo, &["BTC-USDT-SWAP".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -270,10 +253,7 @@ mod okx_option { #[tokio::test(flavor = "multi_thread")] #[ignore = "lack of liquidity"] async fn subscribe_candlestick() { - gen_test_subscribe_candlestick!( - OkxWSClient, - &[("BTC-USD-220930-50000-C".to_string(), 60)] - ); + gen_test_subscribe_candlestick!(OkxWSClient, &[("BTC-USD-220930-50000-C".to_string(), 60)]); gen_test_subscribe_candlestick!( OkxWSClient, &[("BTC-USD-220930-50000-C".to_string(), 604800)] diff --git a/crypto-ws-client/tests/zb.rs b/crypto-ws-client/tests/zb.rs index b8d0a96a..c00ddcbc 100644 --- a/crypto-ws-client/tests/zb.rs +++ b/crypto-ws-client/tests/zb.rs @@ -25,11 +25,7 @@ mod zb_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - ZbSpotWSClient, - subscribe_trade, - &["btc_usdt".to_string()] - ); + gen_test_code!(ZbSpotWSClient, subscribe_trade, &["btc_usdt".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -43,11 +39,7 @@ mod zb_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_ticker() { - gen_test_code!( - ZbSpotWSClient, - subscribe_ticker, - &["btc_usdt".to_string()] - ); + gen_test_code!(ZbSpotWSClient, subscribe_ticker, &["btc_usdt".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -66,8 +58,10 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, subscribe, - &[("Trade".to_string(), "BTC_USDT".to_string()), - ("Depth".to_string(), "BTC_USDT".to_string())] + &[ + ("Trade".to_string(), "BTC_USDT".to_string()), + ("Depth".to_string(), "BTC_USDT".to_string()) + ] ); } @@ -76,8 +70,10 @@ mod zb_linear_swap { gen_test_code!( ZbSwapWSClient, send, - &[r#"{"action":"subscribe", "channel":"BTC_USDT.Trade", "size":100}"#.to_string(), - r#"{"action":"subscribe", "channel":"BTC_USDT.Depth", "size":200}"#.to_string()] + &[ + r#"{"action":"subscribe", "channel":"BTC_USDT.Trade", "size":100}"#.to_string(), + r#"{"action":"subscribe", "channel":"BTC_USDT.Depth", "size":200}"#.to_string() + ] ); } diff --git a/crypto-ws-client/tests/zbg.rs b/crypto-ws-client/tests/zbg.rs index f8fd1b6d..3a7053a1 100644 --- a/crypto-ws-client/tests/zbg.rs +++ b/crypto-ws-client/tests/zbg.rs @@ -25,11 +25,7 @@ mod zbg_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_trade() { - gen_test_code!( - ZbgSpotWSClient, - subscribe_trade, - &["btc_usdt".to_string()] - ); + gen_test_code!(ZbgSpotWSClient, subscribe_trade, &["btc_usdt".to_string()]); } #[tokio::test(flavor = "multi_thread")] @@ -43,11 +39,7 @@ mod zbg_spot { #[tokio::test(flavor = "multi_thread")] async fn subscribe_ticker() { - gen_test_code!( - ZbgSpotWSClient, - subscribe_ticker, - &["btc_usdt".to_string()] - ); + gen_test_code!(ZbgSpotWSClient, subscribe_ticker, &["btc_usdt".to_string()]); } #[ignore] @@ -77,8 +69,10 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, subscribe, - &[("future_tick".to_string(), "1000001".to_string()), - ("future_tick".to_string(), "1000003".to_string())] + &[ + ("future_tick".to_string(), "1000001".to_string()), + ("future_tick".to_string(), "1000003".to_string()) + ] ); } @@ -88,8 +82,10 @@ mod zbg_inverse_swap { gen_test_code!( ZbgSwapWSClient, send, - &[r#"{"action":"sub", "topic":"future_tick-1000001"}"#.to_string(), - r#"{"action":"sub", "topic":"future_tick-1000003"}"#.to_string()] + &[ + r#"{"action":"sub", "topic":"future_tick-1000001"}"#.to_string(), + r#"{"action":"sub", "topic":"future_tick-1000003"}"#.to_string() + ] ); } @@ -142,8 +138,10 @@ mod zbg_inverse_swap { ); gen_test_subscribe_candlestick!( ZbgSwapWSClient, - &[("BTC_USD-R".to_string(), 604800), - ("ETH_USD-R".to_string(), 604800)] + &[ + ("BTC_USD-R".to_string(), 604800), + ("ETH_USD-R".to_string(), 604800) + ] ); } } @@ -158,8 +156,10 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, subscribe, - &[("future_tick".to_string(), "1000000".to_string()), - ("future_tick".to_string(), "1000002".to_string())] + &[ + ("future_tick".to_string(), "1000000".to_string()), + ("future_tick".to_string(), "1000002".to_string()) + ] ); } @@ -169,8 +169,10 @@ mod zbg_linear_swap { gen_test_code!( ZbgSwapWSClient, send, - &[r#"{"action":"sub", "topic":"future_tick-1000000"}"#.to_string(), - r#"{"action":"sub", "topic":"future_tick-1000002"}"#.to_string()] + &[ + r#"{"action":"sub", "topic":"future_tick-1000000"}"#.to_string(), + r#"{"action":"sub", "topic":"future_tick-1000002"}"#.to_string() + ] ); } @@ -223,8 +225,10 @@ mod zbg_linear_swap { ); gen_test_subscribe_candlestick!( ZbgSwapWSClient, - &[("BTC_USDT".to_string(), 604800), - ("ETH_USDT".to_string(), 604800)] + &[ + ("BTC_USDT".to_string(), 604800), + ("ETH_USDT".to_string(), 604800) + ] ); } }