Skip to content

Commit

Permalink
broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leecchh committed Oct 21, 2024
1 parent ece06b3 commit 1395c76
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions packages/suins/tests/controller_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module suins::controller_tests {
use sui::{test_scenario::{Self, Scenario, ctx}, clock::{Self, Clock}, test_utils::assert_eq, dynamic_field, vec_map::VecMap};

use suins::{
register_sample::Register,
constants::{mist_per_sui, year_ms},
suins::{Self, SuiNS, AdminCap},
suins_registration::SuinsRegistration,
register_sample::Register,
constants::{mist_per_sui, year_ms},
suins::{Self, SuiNS, AdminCap},
suins_registration::SuinsRegistration,
register_sample_tests::register_util,
controller::{
Self, Controller, set_target_address_for_testing, set_reverse_lookup_for_testing,
Self, Controller, set_target_address_for_testing, set_reverse_lookup_for_testing,
unset_reverse_lookup_for_testing, set_user_data_for_testing, unset_user_data_for_testing
},
registry::{Self, Registry, lookup, reverse_lookup},
Expand Down Expand Up @@ -53,7 +53,7 @@ module suins::controller_tests {
}

fun setup(scenario: &mut Scenario, sender: address, clock_tick: u64) {
let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), clock_tick);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), clock_tick);
transfer::public_transfer(nft, sender);
}

Expand Down
44 changes: 22 additions & 22 deletions packages/suins/tests/register_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module suins::register_sample_tests {
scenario_val
}

public fun register_util(
public fun register_util<T>(
scenario: &mut Scenario,
domain_name: String,
no_years: u8,
Expand All @@ -61,7 +61,7 @@ module suins::register_sample_tests {
let mut clock = test_scenario::take_shared<Clock>(scenario);

clock.increment_for_testing(clock_tick);
let nft = register(&mut suins, domain_name, no_years, payment, &clock, ctx(scenario));
let nft = register<T>(&mut suins, domain_name, no_years, payment, &clock, ctx(scenario));

test_scenario::return_shared(clock);
test_scenario::return_shared(suins);
Expand Down Expand Up @@ -92,19 +92,19 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
assert_balance(scenario, 1200 * mist_per_sui());
assert!(nft.domain() == domain::new(utf8(DOMAIN_NAME)), 0);
assert!(nft.expiration_timestamp_ms() == year_ms() + 10, 0);
nft.burn_for_testing();

let nft = register_util(scenario, utf8(b"abcd.sui"), 2, 400 * mist_per_sui(), 20);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"abcd.sui"), 2, 400 * mist_per_sui(), 20);
assert_balance(scenario, 1600 * mist_per_sui());
assert!(nft.domain() == domain::new(utf8(b"abcd.sui")), 0);
assert!(nft.expiration_timestamp_ms() == 2 * year_ms() + 30, 0);
nft.burn_for_testing();

let nft = register_util(scenario, utf8(b"abce-f12.sui"), 3, 150 * mist_per_sui(), 30);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"abce-f12.sui"), 3, 150 * mist_per_sui(), 30);
assert_balance(scenario, 1750 * mist_per_sui());
assert!(nft.domain() == domain::new(utf8(b"abce-f12.sui")), 0);
assert!(nft.expiration_timestamp_ms() == 3 * year_ms() + 60, 0);
Expand All @@ -118,7 +118,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(b"abc.move"), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"abc.move"), 1, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -129,7 +129,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1210 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1210 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -140,7 +140,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 90 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 90 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -151,7 +151,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(DOMAIN_NAME), 6, 6 * 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 6, 6 * 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -162,7 +162,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(DOMAIN_NAME), 0, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 0, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -173,13 +173,13 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
assert_balance(scenario, 1200 * mist_per_sui());
assert!(nft.domain() == domain::new(utf8(DOMAIN_NAME)), 0);
assert!(nft.expiration_timestamp_ms() == year_ms() + 10, 0);
nft.burn_for_testing();

let nft = register_util(
let nft = register_util<SuinsRegistration>(
scenario,
utf8(DOMAIN_NAME),
1,
Expand All @@ -202,13 +202,13 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
assert_balance(scenario, 1200 * mist_per_sui());
assert!(nft.domain() == domain::new(utf8(DOMAIN_NAME)), 0);
assert!(nft.expiration_timestamp_ms() == year_ms() + 10, 0);
nft.burn_for_testing();

let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 20);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 20);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -219,7 +219,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(b"-ab.sui"), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"-ab.sui"), 1, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -230,7 +230,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(b"ab-.sui"), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"ab-.sui"), 1, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -241,7 +241,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(b"Abc.com"), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"Abc.com"), 1, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -252,7 +252,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(b"ab.sui"), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"ab.sui"), 1, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -263,7 +263,7 @@ module suins::register_sample_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let nft = register_util(scenario, utf8(b"abc.xyz.sui"), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(b"abc.xyz.sui"), 1, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -276,7 +276,7 @@ module suins::register_sample_tests {
auction::init_for_testing(ctx(scenario));

auction_tests::normal_auction_flow(scenario);
let nft = register_util(scenario, utf8(AUCTIONED_DOMAIN_NAME), 1, 50 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(AUCTIONED_DOMAIN_NAME), 1, 50 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand All @@ -289,7 +289,7 @@ module suins::register_sample_tests {
auction::init_for_testing(ctx(scenario));

auction_tests::normal_auction_flow(scenario);
let nft = register_util(
let nft = register_util<SuinsRegistration>(
scenario,
utf8(AUCTIONED_DOMAIN_NAME),
1,
Expand All @@ -309,7 +309,7 @@ module suins::register_sample_tests {
let scenario = &mut scenario_val;

deauthorize_app_util(scenario);
let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
nft.burn_for_testing();

scenario_val.end();
Expand Down
18 changes: 9 additions & 9 deletions packages/suins/tests/renew_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ module suins::renew_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let mut nft = register_util(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0);
assert!(nft.expiration_timestamp_ms() == year_ms(), 0);
renew_util(scenario, &mut nft, 1, 200 * mist_per_sui(), 0);
assert_balance(scenario, 400 * mist_per_sui());
nft.burn_for_testing();

let mut nft = register_util(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0);
assert!(nft.expiration_timestamp_ms() == year_ms(), 0);
renew_util(scenario, &mut nft, 1, 50 * mist_per_sui(), 0);
assert_balance(scenario, 500 * mist_per_sui());
nft.burn_for_testing();

let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
assert!(nft.expiration_timestamp_ms() == year_ms() + 10, 0);
renew_util(scenario, &mut nft, 1, 1200 * mist_per_sui(), 0);
assert_balance(scenario, 2900 * mist_per_sui());
Expand All @@ -109,7 +109,7 @@ module suins::renew_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
renew_util(scenario, &mut nft, 1, 1210 * mist_per_sui(), 0);
nft.burn_for_testing();

Expand All @@ -121,7 +121,7 @@ module suins::renew_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
renew_util(scenario, &mut nft, 1, 10 * mist_per_sui(), 0);
nft.burn_for_testing();

Expand All @@ -133,7 +133,7 @@ module suins::renew_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10);
renew_util(scenario, &mut nft, 1, 1200 * mist_per_sui(), 2 * year_ms() + 20);
nft.burn_for_testing();

Expand All @@ -145,7 +145,7 @@ module suins::renew_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0);
renew_util(scenario, &mut nft, 6, 7200 * mist_per_sui(), 0);
nft.burn_for_testing();

Expand All @@ -157,7 +157,7 @@ module suins::renew_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0);
renew_util(scenario, &mut nft, 2, 2400 * mist_per_sui(), 0);
renew_util(scenario, &mut nft, 4, 4800 * mist_per_sui(), 0);
nft.burn_for_testing();
Expand All @@ -170,7 +170,7 @@ module suins::renew_tests {
let mut scenario_val = test_init();
let scenario = &mut scenario_val;

let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0);
let mut nft = register_util<SuinsRegistration>(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0);
deauthorize_app_util(scenario);
renew_util(scenario, &mut nft, 2, 2400 * mist_per_sui(), 0);
nft.burn_for_testing();
Expand Down

0 comments on commit 1395c76

Please sign in to comment.