Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disabled to UT #172

Merged
merged 6 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/sources/domains.move
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ module aptos_names::domains {
};
}

/// Clears the user's reverse lookup.
public fun force_clear_reverse_lookup(
admin: &signer,
account_addr: address,
) acquires ReverseLookupRegistryV1, SetReverseLookupEventsV1 {
config::assert_signer_is_admin(admin);
clear_reverse_lookup_internal(account_addr);
}

/// Checks for the name not existing, or being expired
/// Returns true if the name is available for registration
/// if this is a subdomain, and the domain doesn't exist, returns false
Expand Down
5 changes: 3 additions & 2 deletions router/sources/router.move
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,10 @@ module router::router {
} else if (mode == MODE_V1_AND_V2) {
migrate_if_eligible(user, domain_name, subdomain_name);
// Clear primary name in v1 if exists so we do not have primary name in both v1 and v2
let (_, v1_primary_domain_name) = get_v1_primary_name(signer::address_of(user));
let user_addr = signer::address_of(user);
let (_, v1_primary_domain_name) = get_v1_primary_name(user_addr);
if (option::is_some(&v1_primary_domain_name)) {
domains::clear_reverse_lookup(user);
domains::force_clear_reverse_lookup(get_router_signer(), user_addr);
};
v2_1_domains::set_reverse_lookup(
user,
Expand Down
34 changes: 34 additions & 0 deletions router/sources/tests/registration_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,40 @@ module router::registration_tests {
router::register_domain(user, domain_name, SECONDS_PER_YEAR, option::none(), option::none());
}

#[test(
router = @router,
aptos_names = @aptos_names,
aptos_names_v2_1 = @aptos_names_v2_1,
user1 = @0x077,
user2 = @0x266f,
aptos = @0x1,
foundation = @0xf01d
)]
fun test_register_diff_domain_in_v1_and_v2(
router: &signer,
aptos_names: &signer,
aptos_names_v2_1: &signer,
user1: signer,
user2: signer,
aptos: signer,
foundation: signer
) {
router::init_module_for_test(router);
let users = router_test_helper::e2e_test_setup(aptos_names, aptos_names_v2_1, user1, &aptos, user2, &foundation);
let user = vector::borrow(&users, 0);
let domain_name = utf8(b"test1");

// Register with v1
router::register_domain(user, domain_name, SECONDS_PER_YEAR, option::none(), option::none());

// Bump mode and disable v1
aptos_names::config::set_is_enabled(aptos_names, false);
router::set_mode(router, 1);

let domain_name = utf8(b"test2");
router::register_domain(user, domain_name, SECONDS_PER_YEAR, option::none(), option::none());
}

#[test(
router = @router,
aptos_names = @aptos_names,
Expand Down