-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix/test use reset subdomains multiple levels #63
Merged
Th0rgal
merged 8 commits into
testnet
from
fix/test_use_reset_subdomains_multiple_levels
Jun 14, 2024
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1d76b16
test: resetting subdomains multiple levels
Th0rgal 7e8dc83
Merge branch 'fix/test_use_reset_subdomains_multiple_levels' into fea…
Th0rgal 54bd7fe
Merge pull request #62 from starknet-id/feat/add_audit
Th0rgal 001e24f
fix: tests
Th0rgal ac56e65
feat: add comments to assert_is_owner
Th0rgal be20819
feat: rewrite parent key checks
Th0rgal 8202625
fix: removes custom resolver
Th0rgal 44f7c15
fix: commits
Th0rgal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,6 +311,72 @@ fn test_transfer_from_returns_false() { | |
.buy(1, aller, 365, ContractAddressZeroable::zero(), ContractAddressZeroable::zero(), 0, 0); | ||
} | ||
|
||
#[test] | ||
#[available_gas(2000000000)] | ||
//#[should_panic(expected: ('a parent domain was reset', 'ENTRYPOINT_FAILED'))] | ||
fn test_use_reset_subdomains_multiple_levels() { | ||
// setup | ||
let (eth, pricing, identity, naming) = deploy(); | ||
let alpha = contract_address_const::<0x123>(); | ||
let bravo = contract_address_const::<0x456>(); | ||
let charlie = contract_address_const::<0x789>(); | ||
// In this example we will use utf-8 encoded strings like 'toto' which is not | ||
// what is actually defined in the starknetid standard, it's just easier for testings | ||
|
||
// we mint the ids | ||
set_contract_address(alpha); | ||
identity.mint(1); | ||
set_contract_address(bravo); | ||
identity.mint(2); | ||
set_contract_address(charlie); | ||
identity.mint(3); | ||
|
||
// we check how much a domain costs | ||
let (_, price) = pricing.compute_buy_price(5, 365); | ||
|
||
// we allow the naming to take our money | ||
set_contract_address(alpha); | ||
eth.approve(naming.contract_address, price); | ||
|
||
// we buy with no resolver, no sponsor, no discount and empty metadata | ||
naming | ||
.buy( | ||
1, 'ccccc', 365, ContractAddressZeroable::zero(), ContractAddressZeroable::zero(), 0, 0 | ||
); | ||
|
||
let root_domain = array!['ccccc'].span(); | ||
let subdomain = array!['bbbbb', 'ccccc'].span(); | ||
|
||
// we transfer bb.cc.stark to id2 | ||
naming.transfer_domain(subdomain, 2); | ||
|
||
// and make sure the owner has been updated | ||
assert(naming.domain_to_id(subdomain) == 2, 'owner not updated correctly'); | ||
|
||
set_contract_address(bravo); | ||
// we transfer aa.bb.cc.stark to id3 | ||
let subsubdomain = array!['aaaaa', 'bbbbb', 'ccccc'].span(); | ||
naming.transfer_domain(subsubdomain, 3); | ||
// and make sure the owner has been updated | ||
assert(naming.domain_to_id(subsubdomain) == 3, 'owner2 not updated correctly'); | ||
|
||
// now charlie should be able to create a subbsubsubdomain (example.aa.bb.cc.stark): | ||
set_contract_address(charlie); | ||
let subsubsubdomain = array!['example', 'aaaaa', 'bbbbb', 'ccccc'].span(); | ||
naming.transfer_domain(subsubsubdomain, 4); | ||
|
||
// alpha resets subdomains of aller.stark | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be |
||
set_contract_address(alpha); | ||
naming.reset_subdomains(root_domain); | ||
|
||
// ensure root domain still resolves | ||
assert(naming.domain_to_id(root_domain) == 1, 'owner3 not updated correctly'); | ||
// ensure the subdomain was reset | ||
assert(naming.domain_to_id(subdomain) == 0, 'owner4 not updated correctly'); | ||
// ensure the subsubdomain was reset | ||
assert(naming.domain_to_id(subsubdomain) == 0, 'owner5 not updated correctly'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(2000000000)] | ||
#[should_panic(expected: ('domain can\'t be empty', 'ENTRYPOINT_FAILED'))] | ||
|
@@ -334,5 +400,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 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment can be removed