From 7ab1db804fc4c542c0ce71dec2d8795b03a91c22 Mon Sep 17 00:00:00 2001 From: floor-licker Date: Tue, 4 Nov 2025 23:28:21 -0500 Subject: [PATCH] fix: fix client tests, query parameter names, http methods, side enum serialization --- src/auth.rs | 33 ++++++++++++++++----------------- src/client.rs | 10 ++++------ src/lib.rs | 1 - 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index a3e64c2..c4e15ac 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -188,7 +188,6 @@ where #[cfg(test)] mod tests { use super::*; - use crate::client::ApiCreds; #[test] fn test_unix_timestamp() { @@ -264,10 +263,10 @@ mod tests { assert!(result.is_ok()); let headers = result.unwrap(); - assert!(headers.contains_key("POLY_ADDRESS")); - assert!(headers.contains_key("POLY_SIGNATURE")); - assert!(headers.contains_key("POLY_TIMESTAMP")); - assert!(headers.contains_key("POLY_NONCE")); + assert!(headers.contains_key("poly_address")); + assert!(headers.contains_key("poly_signature")); + assert!(headers.contains_key("poly_timestamp")); + assert!(headers.contains_key("poly_nonce")); } #[test] @@ -283,14 +282,14 @@ mod tests { // Different nonces should produce different signatures assert_ne!( - headers_1.get("POLY_SIGNATURE"), - headers_2.get("POLY_SIGNATURE") + headers_1.get("poly_signature"), + headers_2.get("poly_signature") ); // But same address assert_eq!( - headers_1.get("POLY_ADDRESS"), - headers_2.get("POLY_ADDRESS") + headers_1.get("poly_address"), + headers_2.get("poly_address") ); } @@ -307,17 +306,17 @@ mod tests { passphrase: "test_passphrase".to_string(), }; - let result = create_l2_headers(&signer, &api_creds, "/test", "GET", None); + let result = create_l2_headers::(&signer, &api_creds, "/test", "GET", None); assert!(result.is_ok()); let headers = result.unwrap(); - assert!(headers.contains_key("POLY_API_KEY")); - assert!(headers.contains_key("POLY_SIGNATURE")); - assert!(headers.contains_key("POLY_TIMESTAMP")); - assert!(headers.contains_key("POLY_PASSPHRASE")); + assert!(headers.contains_key("poly_api_key")); + assert!(headers.contains_key("poly_signature")); + assert!(headers.contains_key("poly_timestamp")); + assert!(headers.contains_key("poly_passphrase")); - assert_eq!(headers.get("POLY_API_KEY").unwrap(), "test_key"); - assert_eq!(headers.get("POLY_PASSPHRASE").unwrap(), "test_passphrase"); + assert_eq!(headers.get("poly_api_key").unwrap(), "test_key"); + assert_eq!(headers.get("poly_passphrase").unwrap(), "test_passphrase"); } #[test] @@ -333,7 +332,7 @@ mod tests { assert!(result.is_ok()); let headers = result.unwrap(); - let signature = headers.get("POLY_SIGNATURE").unwrap(); + let signature = headers.get("poly_signature").unwrap(); // EIP-712 signatures should be hex strings of specific length assert!(signature.starts_with("0x")); diff --git a/src/client.rs b/src/client.rs index 22216cd..2b1ceec 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1328,7 +1328,7 @@ mod tests { let mock = server .mock("GET", "/sampling-markets") .match_query(Matcher::AllOf(vec![ - Matcher::UrlEncoded("cursor".into(), "test_cursor".into()), + Matcher::UrlEncoded("next_cursor".into(), "test_cursor".into()), ])) .with_status(200) .with_header("content-type", "application/json") @@ -1439,7 +1439,7 @@ mod tests { .mock("GET", "/price") .match_query(Matcher::AllOf(vec![ Matcher::UrlEncoded("token_id".into(), "0x123".into()), - Matcher::UrlEncoded("side".into(), "buy".into()), + Matcher::UrlEncoded("side".into(), "BUY".into()), ])) .with_status(200) .with_header("content-type", "application/json") @@ -1557,10 +1557,8 @@ mod tests { }"#; let mock = server - .mock("GET", "/midpoints") - .match_query(Matcher::AllOf(vec![ - Matcher::UrlEncoded("token_ids".into(), "0x123,0x456".into()), - ])) + .mock("POST", "/midpoints") + .with_header("content-type", "application/json") .with_status(200) .with_header("content-type", "application/json") .with_body(mock_response) diff --git a/src/lib.rs b/src/lib.rs index 1ffdb3d..a719f2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,7 +169,6 @@ mod tests { use super::*; use rust_decimal::Decimal; use std::str::FromStr; - use alloy_primitives::U256; #[test] fn test_client_creation() {