File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-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,8 @@ 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] :
53
+ https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/enum.Order.html
51
54
[ dev-note-4] :
52
55
https://medium.com/cosmwasm/dev-note-4-u128-i128-serialization-in-cosmwasm-90cb76784d44
53
56
Original file line number Diff line number Diff line change @@ -33,3 +33,33 @@ impl From<Order> for i32 {
33
33
original as _
34
34
}
35
35
}
36
+
37
+ #[ cfg( test) ]
38
+ mod tests {
39
+ use super :: * ;
40
+
41
+ #[ test]
42
+ fn order_serde ( ) {
43
+ let ascending_bytes = br#""ascending""# ;
44
+ let descending_bytes = br#""descending""# ;
45
+
46
+ assert_eq ! (
47
+ serde_json:: to_vec( & Order :: Ascending ) . unwrap( ) ,
48
+ ascending_bytes
49
+ ) ;
50
+ assert_eq ! (
51
+ serde_json:: to_vec( & Order :: Descending ) . unwrap( ) ,
52
+ descending_bytes
53
+ ) ;
54
+
55
+ assert_eq ! (
56
+ serde_json:: from_slice:: <Order >( ascending_bytes) . unwrap( ) ,
57
+ Order :: Ascending
58
+ ) ;
59
+
60
+ assert_eq ! (
61
+ serde_json:: from_slice:: <Order >( descending_bytes) . unwrap( ) ,
62
+ Order :: Descending
63
+ ) ;
64
+ }
65
+ }
You can’t perform that action at this time.
0 commit comments