forked from hugues31/coinnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbittrex.rs
41 lines (31 loc) · 1.26 KB
/
bittrex.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#[cfg(test)]
mod bittrex_tests {
extern crate coinnect;
use self::coinnect::bittrex::{BittrexApi, BittrexCreds};
#[test]
fn get_markets_should_return_a_result() {
let creds = BittrexCreds::new("bittrex", "", "");
let mut api = BittrexApi::new(creds).unwrap();
let result = api.get_markets().unwrap();
assert!(result.contains_key("success"))
}
#[test]
fn get_ticker_should_return_a_ticker() {
let creds = BittrexCreds::new("bittrex", "", "");
let mut api = BittrexApi::new(creds).unwrap();
let result = api.get_ticker("BTC-LTC").unwrap();
let last_price = result.get("result").unwrap().as_object().unwrap().get("Last");
assert!(last_price.is_some())
}
/// IMPORTANT: Real keys are needed in order to retrieve the balances
#[test]
#[cfg_attr(not(feature = "bittrex_private_tests"), ignore)]
fn balances_should_return_a_result() {
use std::path::PathBuf;
let path = PathBuf::from("./keys_real.json");
let creds = BittrexCreds::new_from_file("account_bittrex", path).unwrap();
let mut api = BittrexApi::new(creds).unwrap();
let result = api.get_balances().unwrap();
assert!(result.get("result").is_some())
}
}