Skip to content

Commit 3ff973f

Browse files
authored
chore(*): Improve coverage (#485)
* improve coverage: iota-names controller * improve coverage: subnames config * review suggestions
1 parent 005cb8a commit 3ff973f

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

packages/iota-names/tests/controller_tests.move

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,17 @@ fun test_set_user_data() {
464464
assert_eq(*data.get(&DATA_KEY_AVATAR.to_string()), b"value_avatar".to_string());
465465
assert_eq(*data.get(&utf8(DATA_KEY_IPFS)), b"value_ipfs".to_string());
466466

467+
set_user_data_util(
468+
scenario,
469+
FIRST_ADDRESS,
470+
DATA_KEY_AVATAR.to_string(),
471+
b"value_new_avatar".to_string(),
472+
0,
473+
);
474+
let data = &scenario.get_user_data(NAME.to_string());
475+
assert_eq(data.size(), 2);
476+
assert_eq(*data.get(&DATA_KEY_AVATAR.to_string()), b"value_new_avatar".to_string());
477+
467478
scenario_val.end();
468479
}
469480

@@ -748,4 +759,4 @@ fun test_reverse_reset_when_target_address_changes() {
748759

749760
destroy(uid);
750761
scenario_val.end();
751-
}
762+
}

packages/subnames/tests/unit_tests.move

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module iota_names_subnames::unit_tests;
88

99
use iota_names::name::{Self, new as new_name, parent};
1010
use std::string::utf8;
11-
use iota_names_subnames::config::{assert_is_valid_subname, default};
11+
use iota_names_subnames::config::{assert_is_valid_subname, default, new as new_config};
1212

1313
// === Validity of subname | parent lengths (based on string) ===
1414
#[test]
@@ -105,16 +105,16 @@ fun test_invalid_parent_sln_failure() {
105105
fun test_invalid_child_label_size_failure() {
106106
assert_is_valid_subname(
107107
&new_name(utf8(b"sub.test.iota")),
108-
&new_name(utf8(b"ob.example.iota")),
108+
&new_name(utf8(b"ob.test.iota")),
109109
&default(),
110110
);
111111
}
112112

113113
#[test, expected_failure(abort_code = iota_names_subnames::config::ENotSupportedTLN)]
114114
fun test_not_supported_tln_failure() {
115115
assert_is_valid_subname(
116-
&new_name(utf8(b"sub.sub.example.move")),
117116
&new_name(utf8(b"sub.example.move")),
117+
&new_name(utf8(b"sub.sub.example.move")),
118118
&default(),
119119
);
120120
}
@@ -140,3 +140,12 @@ fun derive_parent_from_child() {
140140
0,
141141
);
142142
}
143+
144+
#[test]
145+
fun test_custom_config() {
146+
assert_is_valid_subname(
147+
&new_name(utf8(b"a.move")),
148+
&new_name(utf8(b"b.a.move")),
149+
&new_config(vector[b"move".to_string()], 3, 1, 60 * 60 * 1000),
150+
);
151+
}

0 commit comments

Comments
 (0)