Skip to content

Commit

Permalink
fixup: add sub-domain expiry test
Browse files Browse the repository at this point in the history
  • Loading branch information
amnn committed Feb 12, 2025
1 parent 7960716 commit 92e3e51
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion crates/sui-indexer-alt-e2e-tests/tests/name_service_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async fn test_resolve_subdomain() {

/// Like the parent domain case, but a sub-domain's expiry is controlled by its parent's expiry
#[sim_test]
async fn test_resolve_subdomain_expiry() {
async fn test_resolve_subdomain_parent_expiry() {
let mut c = SuiNSCluster::new().await;

let nft = ObjectID::random();
Expand All @@ -194,6 +194,36 @@ async fn test_resolve_subdomain_expiry() {
c.cluster.stopped().await;
}

/// A sub-domain that has its own expiry, in addition to (and before) the parent's expiry.
#[sim_test]
async fn test_resolve_subdomain_expiry() {
let mut c = SuiNSCluster::new().await;

let nft = ObjectID::random();
let target = SuiAddress::random_for_testing_only();
let parent_expiry_ms = 10000;
let expiry_ms = 1000;

c.add_domain(nft, &["sui", "foo"], None, parent_expiry_ms)
.await
.expect("Failed to add parent domain");

c.add_domain(nft, &["sui", "foo", "bar"], Some(target), expiry_ms)
.await
.expect("Failed to add subdomain");

c.cluster.create_checkpoint().await.unwrap();

assert_resolved!(target, c.resolve_address("bar.foo.sui").await.unwrap());

c.cluster.advance_clock(Duration::from_millis(expiry_ms));
c.cluster.create_checkpoint().await.unwrap();

assert_invalid_params!(c.resolve_address("bar.foo.sui").await.unwrap());

c.cluster.stopped().await;
}

/// A sub-domain where the parent domain's NFT is different from the sub-domain's NFT, is
/// considered expired -- its parent has been bought by someone else.
#[sim_test]
Expand Down

0 comments on commit 92e3e51

Please sign in to comment.