Skip to content

Commit

Permalink
update test and rename
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaptosj committed Aug 4, 2023
1 parent 8924742 commit b738aeb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core_v2/sources/domain_e2e_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ module aptos_names_v2::domain_e2e_tests {
aptos_names::domains::name_is_registerable(option::none(), test_helper::domain_name()) == false,
1,
);
let (is_owner, _) = aptos_names::domains::is_owner_of_name(
let is_owner = aptos_names::domains::is_owner_of_name(
aptos_names_v2::domains::get_burn_signer_address(),
option::none(),
test_helper::domain_name(),
Expand Down Expand Up @@ -640,7 +640,7 @@ module aptos_names_v2::domain_e2e_tests {
aptos_names::domains::name_is_registerable(option::none(), test_helper::domain_name()) == false,
1,
);
let (is_owner, _) = aptos_names::domains::is_owner_of_name(
let is_owner = aptos_names::domains::is_owner_of_name(
aptos_names_v2::domains::get_burn_signer_address(),
option::none(),
test_helper::domain_name(),
Expand Down
14 changes: 5 additions & 9 deletions core_v2/sources/domains.move
Original file line number Diff line number Diff line change
Expand Up @@ -1109,14 +1109,14 @@ module aptos_names_v2::domains {
}

#[view]
public fun get_name_record_v1_props_for_domain(
public fun get_domain_props(
domain: String,
): (u64, Option<address>) acquires CollectionCapabilityV2, NameRecordV2 {
get_name_record_v1_props_for_name(option::none(), domain)
}

#[view]
public fun get_name_record_v1_props_for_subdomain(
public fun get_subdomain_props(
subdomain: String,
domain: String,
): (u64, Option<address>) acquires CollectionCapabilityV2, NameRecordV2 {
Expand All @@ -1126,18 +1126,14 @@ module aptos_names_v2::domains {
#[view]
public fun get_reverse_lookup_name(
account_addr: address
): Option<String> acquires ReverseRecord, NameRecordV2 {
): (Option<String>, Option<String>) acquires ReverseRecord, NameRecordV2 {
let reverse_record_address = get_reverse_lookup(account_addr);
if (option::is_some(&reverse_record_address)) {
let address = option::borrow(&reverse_record_address);
let (subdomain_name, domain_name) = get_record_props_from_token_addr(*address);
if (is_subdomain(subdomain_name)) {
option::some(token_helper::get_fully_qualified_domain_name(subdomain_name, domain_name))
} else {
option::some(domain_name)
}
(subdomain_name, option::some(domain_name))
} else {
option::none()
(option::none(), option::none())
}
}

Expand Down
1 change: 0 additions & 1 deletion core_v2/sources/migrate_helper.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module aptos_names_v2::migrate_helper {

// Get the v1 token info
let (
_property_version,
expiration_time_sec,
target_addr
) = aptos_names::domains::get_name_record_v1_props_for_name(
Expand Down
13 changes: 13 additions & 0 deletions core_v2/sources/test_helper.move
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,26 @@ module aptos_names_v2::test_helper {
assert!(time_helper::seconds_to_days(expiration_time_sec - timestamp::now_seconds()) == 365, 10);

if (is_subdomain) {
let subdomain_name_copy = subdomain_name;
let (expiration_time_sec_lookup_result, target_address_lookup_result) = domains::get_subdomain_props(*option::borrow(&subdomain_name_copy), domain_name);
assert!(time_helper::seconds_to_days(expiration_time_sec_lookup_result - timestamp::now_seconds()) == 365, 100);

if (option::is_none(&user_reverse_lookup_before)) {
// Should automatically point to the users address
assert!(target_address == option::some(user_addr), 11);
assert!(target_address_lookup_result == option::some(user_addr), 111);
} else {
// We haven't set a target address yet!
assert!(target_address == option::none(), 11);
assert!(target_address_lookup_result == option::none(), 111);
}
} else {
let (expiration_time_sec_lookup_result, target_address_lookup_result) = domains::get_domain_props(domain_name);
assert!(time_helper::seconds_to_days(expiration_time_sec_lookup_result - timestamp::now_seconds()) == 365, 100);

// Should automatically point to the users address
assert!(target_address == option::some(user_addr), 11);
assert!(target_address_lookup_result == option::some(user_addr), 111);
};

// TODO: Re-enable / Re-write
Expand All @@ -152,9 +162,12 @@ module aptos_names_v2::test_helper {
// Reverse lookup should be set if user did not have one before
if (option::is_none(&user_reverse_lookup_before)) {
let maybe_reverse_lookup_after = domains::get_reverse_lookup(user_addr);
let (subdomain_name_lookup_result, domain_name_lookup_result) = domains::get_reverse_lookup_name(user_addr);
if (option::is_some(&maybe_reverse_lookup_after)) {
let reverse_lookup_after = option::borrow(&maybe_reverse_lookup_after);
assert!(*reverse_lookup_after == domains::token_addr(domain_name, subdomain_name), 36);
assert!(subdomain_name_lookup_result == subdomain_name, 136);
assert!(domain_name_lookup_result == option::some(domain_name), 137);
} else {
// Reverse lookup is not set, even though user did not have a reverse lookup before.
assert!(false, 37);
Expand Down

0 comments on commit b738aeb

Please sign in to comment.