fix: fix client tests, query parameter names, http methods, side enum serialization

This commit is contained in:
floor-licker
2025-11-04 23:28:21 -05:00
parent 4fdd6918ef
commit 7ab1db804f
3 changed files with 20 additions and 24 deletions
+16 -17
View File
@@ -188,7 +188,6 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::client::ApiCreds;
#[test] #[test]
fn test_unix_timestamp() { fn test_unix_timestamp() {
@@ -264,10 +263,10 @@ mod tests {
assert!(result.is_ok()); assert!(result.is_ok());
let headers = result.unwrap(); let headers = result.unwrap();
assert!(headers.contains_key("POLY_ADDRESS")); assert!(headers.contains_key("poly_address"));
assert!(headers.contains_key("POLY_SIGNATURE")); assert!(headers.contains_key("poly_signature"));
assert!(headers.contains_key("POLY_TIMESTAMP")); assert!(headers.contains_key("poly_timestamp"));
assert!(headers.contains_key("POLY_NONCE")); assert!(headers.contains_key("poly_nonce"));
} }
#[test] #[test]
@@ -283,14 +282,14 @@ mod tests {
// Different nonces should produce different signatures // Different nonces should produce different signatures
assert_ne!( assert_ne!(
headers_1.get("POLY_SIGNATURE"), headers_1.get("poly_signature"),
headers_2.get("POLY_SIGNATURE") headers_2.get("poly_signature")
); );
// But same address // But same address
assert_eq!( assert_eq!(
headers_1.get("POLY_ADDRESS"), headers_1.get("poly_address"),
headers_2.get("POLY_ADDRESS") headers_2.get("poly_address")
); );
} }
@@ -307,17 +306,17 @@ mod tests {
passphrase: "test_passphrase".to_string(), passphrase: "test_passphrase".to_string(),
}; };
let result = create_l2_headers(&signer, &api_creds, "/test", "GET", None); let result = create_l2_headers::<String>(&signer, &api_creds, "/test", "GET", None);
assert!(result.is_ok()); assert!(result.is_ok());
let headers = result.unwrap(); let headers = result.unwrap();
assert!(headers.contains_key("POLY_API_KEY")); assert!(headers.contains_key("poly_api_key"));
assert!(headers.contains_key("POLY_SIGNATURE")); assert!(headers.contains_key("poly_signature"));
assert!(headers.contains_key("POLY_TIMESTAMP")); assert!(headers.contains_key("poly_timestamp"));
assert!(headers.contains_key("POLY_PASSPHRASE")); assert!(headers.contains_key("poly_passphrase"));
assert_eq!(headers.get("POLY_API_KEY").unwrap(), "test_key"); assert_eq!(headers.get("poly_api_key").unwrap(), "test_key");
assert_eq!(headers.get("POLY_PASSPHRASE").unwrap(), "test_passphrase"); assert_eq!(headers.get("poly_passphrase").unwrap(), "test_passphrase");
} }
#[test] #[test]
@@ -333,7 +332,7 @@ mod tests {
assert!(result.is_ok()); assert!(result.is_ok());
let headers = result.unwrap(); 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 // EIP-712 signatures should be hex strings of specific length
assert!(signature.starts_with("0x")); assert!(signature.starts_with("0x"));
+4 -6
View File
@@ -1328,7 +1328,7 @@ mod tests {
let mock = server let mock = server
.mock("GET", "/sampling-markets") .mock("GET", "/sampling-markets")
.match_query(Matcher::AllOf(vec![ .match_query(Matcher::AllOf(vec![
Matcher::UrlEncoded("cursor".into(), "test_cursor".into()), Matcher::UrlEncoded("next_cursor".into(), "test_cursor".into()),
])) ]))
.with_status(200) .with_status(200)
.with_header("content-type", "application/json") .with_header("content-type", "application/json")
@@ -1439,7 +1439,7 @@ mod tests {
.mock("GET", "/price") .mock("GET", "/price")
.match_query(Matcher::AllOf(vec![ .match_query(Matcher::AllOf(vec![
Matcher::UrlEncoded("token_id".into(), "0x123".into()), Matcher::UrlEncoded("token_id".into(), "0x123".into()),
Matcher::UrlEncoded("side".into(), "buy".into()), Matcher::UrlEncoded("side".into(), "BUY".into()),
])) ]))
.with_status(200) .with_status(200)
.with_header("content-type", "application/json") .with_header("content-type", "application/json")
@@ -1557,10 +1557,8 @@ mod tests {
}"#; }"#;
let mock = server let mock = server
.mock("GET", "/midpoints") .mock("POST", "/midpoints")
.match_query(Matcher::AllOf(vec![ .with_header("content-type", "application/json")
Matcher::UrlEncoded("token_ids".into(), "0x123,0x456".into()),
]))
.with_status(200) .with_status(200)
.with_header("content-type", "application/json") .with_header("content-type", "application/json")
.with_body(mock_response) .with_body(mock_response)
-1
View File
@@ -169,7 +169,6 @@ mod tests {
use super::*; use super::*;
use rust_decimal::Decimal; use rust_decimal::Decimal;
use std::str::FromStr; use std::str::FromStr;
use alloy_primitives::U256;
#[test] #[test]
fn test_client_creation() { fn test_client_creation() {