Skip to content

Commit

Permalink
fix: use lowercase for currencyunit
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Dec 5, 2023
1 parent 71e6fdc commit 71ff188
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion moksha-core/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub struct KeyResponse {

#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone)]
pub enum CurrencyUnit {
#[serde(rename = "sat")]
Sat,
}

Expand Down Expand Up @@ -176,7 +177,7 @@ pub struct PostMeltBolt11Response {
mod tests {
use crate::{
dhke::public_key_from_hex,
primitives::{MintInfoResponse, Parameter, PostSplitResponse},
primitives::{KeyResponse, MintInfoResponse, Parameter, PostSplitResponse},
};

#[test]
Expand All @@ -187,6 +188,18 @@ mod tests {
Ok(())
}

#[test]
fn test_serialize_keyresponse() -> anyhow::Result<()> {
let response = KeyResponse {
id: "test".to_string(),
unit: crate::primitives::CurrencyUnit::Sat,
keys: std::collections::HashMap::new(),
};
let serialized = serde_json::to_string(&response)?;
assert_eq!(serialized, "{\"id\":\"test\",\"unit\":\"sat\",\"keys\":{}}");
Ok(())
}

#[test]
fn test_deserialize_mint_info() -> anyhow::Result<()> {
let mint_info = MintInfoResponse {
Expand Down

0 comments on commit 71ff188

Please sign in to comment.