diff --git a/src/naming/asserts.cairo b/src/naming/asserts.cairo index 5196863..df346b0 100644 --- a/src/naming/asserts.cairo +++ b/src/naming/asserts.cairo @@ -37,7 +37,7 @@ impl AssertionsImpl of AssertionsTrait { assert(data.owner == 0 || data.expiry < now, 'unexpired domain'); // Verify expiration range - assert(days < 365 * 25, 'max purchase of 25 years'); + assert(days <= 365 * 25, 'max purchase of 25 years'); assert(days > 2 * 30, 'min purchase of 2 month'); return (hashed_domain, now, now + 86400 * days.into()); } diff --git a/src/naming/main.cairo b/src/naming/main.cairo index 24ec301..de43c95 100644 --- a/src/naming/main.cairo +++ b/src/naming/main.cairo @@ -383,8 +383,8 @@ mod Naming { domain_data.expiry + 86400 * days.into() }; // 25*365 = 9125 - assert(new_expiry <= now + 86400 * 9125, 'purchase too long'); - assert(days >= 6 * 30, 'purchase too short'); + assert(new_expiry <= now + 365 * 25 * 86400, 'max purchase of 25 years'); + assert(days >= 6 * 30, 'min purchase of 6 months'); let data = DomainData { owner: domain_data.owner, @@ -456,9 +456,8 @@ mod Naming { } else { domain_data.expiry + 86400 * days.into() }; - // 25*365 = 9125 - assert(new_expiry <= now + 86400 * 9125, 'purchase too long'); - assert(days >= 6 * 30, 'purchase too short'); + assert(new_expiry <= now + 365 * 25 * 86400, 'max purchase of 25 years'); + assert(days >= 6 * 30, 'min purchase of 6 months'); let data = DomainData { owner: domain_data.owner, @@ -707,9 +706,7 @@ mod Naming { // ADMIN - fn set_expiry( - ref self: ContractState, root_domain: felt252, expiry: u64 - ) { + fn set_expiry(ref self: ContractState, root_domain: felt252, expiry: u64) { self.ownable.assert_only_owner(); let hashed_domain = self.hash_domain(array![root_domain].span()); let domain_data = self._domain_data.read(hashed_domain); diff --git a/src/tests/naming/test_abuses.cairo b/src/tests/naming/test_abuses.cairo index 7b83f22..4f1e130 100644 --- a/src/tests/naming/test_abuses.cairo +++ b/src/tests/naming/test_abuses.cairo @@ -164,7 +164,7 @@ fn test_non_owner_cannot_transfer_domain() { #[test] #[available_gas(2000000000)] -#[should_panic(expected: ('purchase too short', 'ENTRYPOINT_FAILED'))] +#[should_panic(expected: ('min purchase of 6 months', 'ENTRYPOINT_FAILED'))] fn test_renewal_period_too_short() { // setup let (eth, pricing, identity, naming) = deploy(); @@ -190,7 +190,7 @@ fn test_renewal_period_too_short() { #[test] #[available_gas(2000000000)] -#[should_panic(expected: ('purchase too long', 'ENTRYPOINT_FAILED'))] +#[should_panic(expected: ('max purchase of 25 years', 'ENTRYPOINT_FAILED'))] fn test_renewal_period_too_long() { // setup let (eth, pricing, identity, naming) = deploy(); @@ -334,5 +334,13 @@ fn test_buy_empty_domain() { // we buy with no resolver, no sponsor, no discount and empty metadata naming - .buy(1, empty_domain, 365, ContractAddressZeroable::zero(), ContractAddressZeroable::zero(), 0, 0); + .buy( + 1, + empty_domain, + 365, + ContractAddressZeroable::zero(), + ContractAddressZeroable::zero(), + 0, + 0 + ); }