Skip to content

Commit

Permalink
order serialization
Browse files Browse the repository at this point in the history
use cosmwasm_std functions
  • Loading branch information
dakom committed Jun 24, 2024
1 parent 997cce1 commit a6d289b
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions packages/std/src/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,25 @@ impl From<Order> for i32 {

#[cfg(test)]
mod tests {
use crate::{from_json, to_json_vec};

use super::*;

#[test]
fn order_serde() {
let ascending_bytes = br#""ascending""#;
let descending_bytes = br#""descending""#;

assert_eq!(
serde_json::to_vec(&Order::Ascending).unwrap(),
ascending_bytes
);
assert_eq!(
serde_json::to_vec(&Order::Descending).unwrap(),
descending_bytes
);
assert_eq!(to_json_vec(&Order::Ascending).unwrap(), ascending_bytes);
assert_eq!(to_json_vec(&Order::Descending).unwrap(), descending_bytes);

assert_eq!(
serde_json::from_slice::<Order>(ascending_bytes).unwrap(),
from_json::<Order>(ascending_bytes).unwrap(),
Order::Ascending
);

assert_eq!(
serde_json::from_slice::<Order>(descending_bytes).unwrap(),
from_json::<Order>(descending_bytes).unwrap(),
Order::Descending
);
}
Expand Down

0 comments on commit a6d289b

Please sign in to comment.