lamarge 0.7.0

Client for the LaMarge API: sign-in, takes, transfers, withdrawals and market making, each request checked before it is signed.
Documentation
use serde_json::{Value, json};

use super::*;

fn chain() -> Value {
    crate::testing::json::fixture("health/chains/0")
}

#[test]
fn block_numbers_are_decimal_strings() {
    let health: ChainHealth = serde_json::from_value(chain()).unwrap();
    let (block, finalized) = (health.block.map(BlockNumber::get), health.finalized_block);
    assert_eq!((block, finalized), (Some(18_100_000), Some(BlockNumber::new(18_099_990))));
    let text = serde_json::to_value(&health).unwrap();
    assert_eq!(text["block"], json!("18100000"));
    let mut unread = chain();
    unread["block"] = Value::Null;
    let unread: ChainHealth = serde_json::from_value(unread).unwrap();
    assert_eq!(unread.block, None);
    assert_eq!(serde_json::to_value(&unread).unwrap()["block"], Value::Null);
    for bad in [json!(18_100_000), json!("0x1"), json!("-1")] {
        let mut value = chain();
        value["block"] = bad;
        assert!(serde_json::from_value::<ChainHealth>(value).is_err());
    }
}