Skip to content

Commit

Permalink
fix: Expect pair range as camel case and expect LST to have one
Browse files Browse the repository at this point in the history
  • Loading branch information
Arrowana committed Aug 27, 2024
1 parent 39ec2db commit 04f9658
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Category {
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct CategoryOriginal {
name: String,
range: Range,
Expand All @@ -29,11 +30,13 @@ struct CategoryOriginal {
pub struct DeserializablePubkey(#[serde(with = "field_as_string")] pub Pubkey);

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DefaultSlippage {
pub range: Range,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct DynamicSlippageCategories {
categories: Vec<CategoryOriginal>,
default: DefaultSlippage,
Expand Down Expand Up @@ -75,8 +78,15 @@ mod tests {
let (_, categories) = deserialize_dynamic_slippage_config().unwrap();

assert_eq!(
categories.into_iter().map(|c| c.name).collect::<Vec<_>>(),
categories.iter().map(|c| &c.name).collect::<Vec<_>>(),
vec!["stable", "lst", "bluechip", "verified"]
);

assert!(categories
.iter()
.find(|c| c.name == "lst")
.unwrap()
.pair_range
.is_some())
}
}

0 comments on commit 04f9658

Please sign in to comment.