mirror of
https://github.com/floor-licker/polyfill-rs.git
synced 2026-08-01 23:07:45 +00:00
fix: fix client tests, query parameter names, http methods, side enum serialization
This commit is contained in:
+16
-17
@@ -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::<String>(&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"));
|
||||
|
||||
+4
-6
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user