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::json;
use wiremock::MockServer;

use crate::{
    model::HealthStatus,
    testing::{
        http::{Expect, client, served},
        json::{fixture, list},
    },
    types::{FillId, VenueId},
};

#[tokio::test]
async fn every_read_is_anonymous_and_names_its_terms() {
    let server = MockServer::start().await;
    let client = client(&server);
    let market = client.market();
    let (hl, pm) = (VenueId::Hyperliquid, VenueId::Polymarket);
    let venues = served(&server, Expect::get("/v1/venues", list("venue")), market.venues());
    assert_eq!(venues.await.unwrap()[0].id, VenueId::Polymarket);
    let books = Expect::get("/v1/books", fixture("book"))
        .query(&[("from", "hyperliquid"), ("to", "polymarket")]);
    served(&server, books, market.book(&hl, &pm)).await.unwrap();
    served(&server, Expect::get("/v1/markets", fixture("markets")), market.markets())
        .await
        .unwrap();
    let volume = Expect::get("/v1/volume", fixture("volume"))
        .query(&[("a", "hyperliquid"), ("b", "polymarket")]);
    served(&server, volume, market.volume(&hl, &pm)).await.unwrap();
    served(&server, Expect::get("/v1/info", fixture("info")), market.info()).await.unwrap();
    let id: FillId = fixture("trade_proof")["id"].as_str().unwrap().parse().unwrap();
    let proof = Expect::get(format!("/v1/trades/{id}/proof"), fixture("trade_proof"));
    assert_eq!(served(&server, proof, market.trade_proof(id)).await.unwrap().id, id);
}

#[tokio::test]
async fn health_reads_a_503_as_an_answer() {
    let server = MockServer::start().await;
    let client = client(&server);
    let mut body = fixture("health");
    body["status"] = json!("degraded");
    let degraded = Expect::get("/health", body).status(503);
    let health = served(&server, degraded, client.market().health()).await.unwrap();
    assert_eq!(health.status, HealthStatus::Degraded);
}