File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ Rust types as well as `cosmwasm_std` types and how they are encoded in JSON.
31
31
| [ Binary] | string containing base64 data | ` "MTIzCg==" ` | |
32
32
| [ HexBinary] | string containing hex data | ` "b5d7d24e428c" ` | |
33
33
| [ Timestamp] | string containing nanoseconds since epoch | ` "1677687687000000000" ` | |
34
+ | [ Order] | string containing order variant | ` "ascending" ` or ` "descending" ` | |
34
35
35
36
[ uint64 ] : https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.Uint64.html
36
37
[ uint128 ] : https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.Uint128.html
@@ -48,6 +49,7 @@ Rust types as well as `cosmwasm_std` types and how they are encoded in JSON.
48
49
https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.HexBinary.html
49
50
[ timestamp] :
50
51
https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.Timestamp.html
52
+ [ order ] : https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/enum.Order.html
51
53
[ dev-note-4] :
52
54
https://medium.com/cosmwasm/dev-note-4-u128-i128-serialization-in-cosmwasm-90cb76784d44
53
55
Original file line number Diff line number Diff line change @@ -33,3 +33,29 @@ impl From<Order> for i32 {
33
33
original as _
34
34
}
35
35
}
36
+
37
+ #[ cfg( test) ]
38
+ mod tests {
39
+ use crate :: { from_json, to_json_vec} ;
40
+
41
+ use super :: * ;
42
+
43
+ #[ test]
44
+ fn order_serde ( ) {
45
+ let ascending_bytes = br#""ascending""# ;
46
+ let descending_bytes = br#""descending""# ;
47
+
48
+ assert_eq ! ( to_json_vec( & Order :: Ascending ) . unwrap( ) , ascending_bytes) ;
49
+ assert_eq ! ( to_json_vec( & Order :: Descending ) . unwrap( ) , descending_bytes) ;
50
+
51
+ assert_eq ! (
52
+ from_json:: <Order >( ascending_bytes) . unwrap( ) ,
53
+ Order :: Ascending
54
+ ) ;
55
+
56
+ assert_eq ! (
57
+ from_json:: <Order >( descending_bytes) . unwrap( ) ,
58
+ Order :: Descending
59
+ ) ;
60
+ }
61
+ }
You can’t perform that action at this time.
0 commit comments