#![forbid(anonymous_parameters, unsafe_code)]
#![warn(clippy::pedantic)]
#![deny(
clippy::all,
variant_size_differences,
unused,
unused_qualifications,
unused_import_braces,
unused_lifetimes,
unreachable_pub,
trivial_numeric_casts,
trivial_casts,
missing_docs,
rustdoc,
missing_debug_implementations,
missing_copy_implementations,
deprecated_in_future,
meta_variable_misuse,
non_ascii_idents,
rust_2018_compatibility,
rust_2018_idioms,
future_incompatible,
nonstandard_style,
//warnings
)]
use bittrex::Client;
use chrono::{Datelike, Timelike};
use dotenv::dotenv;
use std::env;
#[test]
fn it_get_markets() {
Client::get_markets().unwrap();
}
#[test]
fn it_date_time_parsing() {
let markets = Client::get_markets().unwrap();
for market in markets {
if market.market_name() == "BTC-LTC" {
let creation = market.created();
assert_eq!(creation.year(), 2014);
assert_eq!(creation.month(), 2);
assert_eq!(creation.day(), 13);
assert_eq!(creation.hour(), 0);
assert_eq!(creation.minute(), 0);
assert_eq!(creation.second(), 0);
assert_eq!(creation.nanosecond(), 0);
} else if market.market_currency() == "BTC-BYC" {
let creation = market.created();
assert_eq!(creation.year(), 2014);
assert_eq!(creation.month(), 11);
assert_eq!(creation.day(), 3);
assert_eq!(creation.hour(), 19);
assert_eq!(creation.minute(), 2);
assert_eq!(creation.second(), 45);
assert_eq!(creation.nanosecond(), 960_000_000);
}
}
}
#[test]
fn it_get_currencies() {
Client::get_currencies().unwrap();
}
#[test]
fn it_get_ticker() {
Client::get_ticker("BTC-LTC").unwrap();
Client::get_ticker("BTC-ETH").unwrap();
Client::get_ticker("BTC-ZEC").unwrap();
assert!(Client::get_ticker("Invalid market").is_err());
}
#[test]
fn it_get_market_summaries() {
Client::get_market_summaries().unwrap();
}
#[test]
fn it_get_market_summary() {
Client::get_market_summary("BTC-LTC").unwrap();
Client::get_market_summary("BTC-ETH").unwrap();
Client::get_market_summary("BTC-ZEC").unwrap();
assert!(Client::get_market_summary("Invalid market").is_err());
}
#[test]
fn it_get_order_book() {
use bittrex::OrderBookType;
Client::get_order_book("BTC-LTC", OrderBookType::Buy, 20).unwrap();
Client::get_order_book("BTC-ETH", OrderBookType::Sell, 0).unwrap();
Client::get_order_book("BTC-ZEC", OrderBookType::Both, 50).unwrap();
assert!(Client::get_order_book("Invalid market", OrderBookType::Both, 50).is_err());
}
#[test]
#[should_panic]
fn it_get_order_book_panic() {
use bittrex::OrderBookType;
Client::get_order_book("BTC-LTC", OrderBookType::Both, 100).unwrap();
}
#[test]
#[ignore]
fn it_get_balances() {
dotenv().ok().unwrap();
let api_key = env::var("API_KEY").unwrap();
let api_secret = env::var("API_SECRET").unwrap();
let mut client = Client::default();
client.login(api_key, api_secret);
client.get_balances().unwrap();
}