From b738aebc82bb0eacc31ef1b6dcd76342600fd893 Mon Sep 17 00:00:00 2001
From: 0xaptosj <129789810+0xaptosj@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:55:37 -0700
Subject: [PATCH] update test and rename
---
core_v2/sources/domain_e2e_tests.move | 4 ++--
core_v2/sources/domains.move | 14 +++++---------
core_v2/sources/migrate_helper.move | 1 -
core_v2/sources/test_helper.move | 13 +++++++++++++
4 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/core_v2/sources/domain_e2e_tests.move b/core_v2/sources/domain_e2e_tests.move
index 5cb9b894..17b76399 100644
--- a/core_v2/sources/domain_e2e_tests.move
+++ b/core_v2/sources/domain_e2e_tests.move
@@ -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(),
@@ -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(),
diff --git a/core_v2/sources/domains.move b/core_v2/sources/domains.move
index 951051a9..d336bc58 100644
--- a/core_v2/sources/domains.move
+++ b/core_v2/sources/domains.move
@@ -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
) 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) acquires CollectionCapabilityV2, NameRecordV2 {
@@ -1126,18 +1126,14 @@ module aptos_names_v2::domains {
#[view]
public fun get_reverse_lookup_name(
account_addr: address
- ): Option acquires ReverseRecord, NameRecordV2 {
+ ): (Option, Option) 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())
}
}
diff --git a/core_v2/sources/migrate_helper.move b/core_v2/sources/migrate_helper.move
index 9e3cc2fc..cdb465eb 100644
--- a/core_v2/sources/migrate_helper.move
+++ b/core_v2/sources/migrate_helper.move
@@ -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(
diff --git a/core_v2/sources/test_helper.move b/core_v2/sources/test_helper.move
index d9f28588..70cab3fd 100644
--- a/core_v2/sources/test_helper.move
+++ b/core_v2/sources/test_helper.move
@@ -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
@@ -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);