Skip to content

Commit

Permalink
followup to a TODO for a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ziaptos authored and sherry-x committed Dec 2, 2024
1 parent 14cd388 commit c522181
Showing 1 changed file with 28 additions and 41 deletions.
69 changes: 28 additions & 41 deletions api/types/src/move_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,40 +1260,30 @@ mod tests {
fn test_serialize_move_resource() {
use AnnotatedMoveValue::*;

let res = MoveResource::try_from(annotated_move_struct(
"Values",
vec![
(identifier("field_u8"), U8(7)),
(identifier("field_u64"), U64(7)),
(identifier("field_u128"), U128(7)),
(identifier("field_bool"), Bool(true)),
(identifier("field_address"), Address(address("0xdd"))),
(
identifier("field_vector"),
Vector(TypeTag::U128, vec![U128(128)]),
),
(identifier("field_bytes"), Bytes(vec![9, 9])),
(
identifier("field_struct"),
Struct(annotated_move_struct(
"Nested",
vec![(
identifier("nested_vector"),
Vector(
TypeTag::Struct(Box::new(type_struct("Host"))),
vec![Struct(annotated_move_struct(
"String",
vec![
(identifier("address1"), Address(address("0x0"))),
(identifier("address2"), Address(address("0x123"))),
],
))],
),
)],
)),
),
],
))
let res = MoveResource::try_from(annotated_move_struct("Values", vec![
(identifier("field_u8"), U8(7)),
(identifier("field_u64"), U64(7)),
(identifier("field_u128"), U128(7)),
(identifier("field_bool"), Bool(true)),
(identifier("field_address"), Address(address("0xdd"))),
(
identifier("field_vector"),
Vector(TypeTag::U128, vec![U128(128)]),
),
(identifier("field_bytes"), Bytes(vec![9, 9])),
(
identifier("field_struct"),
Struct(annotated_move_struct("Nested", vec![(
identifier("nested_vector"),
Vector(TypeTag::Struct(Box::new(type_struct("Host"))), vec![
Struct(annotated_move_struct("String", vec![
(identifier("address1"), Address(address("0x0"))),
(identifier("address2"), Address(address("0x123"))),
])),
]),
)])),
),
]))
.unwrap();
let value = to_value(&res).unwrap();
assert_json(
Expand All @@ -1318,13 +1308,10 @@ mod tests {

#[test]
fn test_serialize_move_resource_with_address_0x0() {
let res = MoveResource::try_from(annotated_move_struct(
"Values",
vec![(
identifier("address_0x0"),
AnnotatedMoveValue::Address(address("0x0")),
)],
))
let res = MoveResource::try_from(annotated_move_struct("Values", vec![(
identifier("address_0x0"),
AnnotatedMoveValue::Address(address("0x0")),
)]))
.unwrap();
let value = to_value(&res).unwrap();
assert_json(
Expand Down

0 comments on commit c522181

Please sign in to comment.