Skip to content

Commit

Permalink
feat: add check for changing the domain target
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Aug 21, 2023
1 parent 94708ed commit c84ba49
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/tests/test_naming.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use array::ArrayTrait;
use array::SpanTrait;
use debug::PrintTrait;
use option::OptionTrait;
use zeroable::Zeroable;
use traits::Into;
use starknet::testing;
Expand Down Expand Up @@ -78,4 +80,18 @@ fn test_basic_usage() {
assert(naming.resolve(domain, 'starknet') == 0, 'non empty starknet field');
// so it should resolve to the starknetid owner
assert(naming.domain_to_address(domain) == caller, 'wrong domain target');

// let's try reverse resolving
identity.set_main_id(id);
assert(domain.len() == 1, 'invalid domain length');
assert(domain.at(0) == @th0rgal, 'wrong domain');

// now let's change the target
let new_target = contract_address_const::<0x456>();
identity.set_user_data(id, 'starknet', new_target.into(), 0);

// now we should have nothing written
assert(naming.resolve(domain, 'starknet') == new_target.into(), 'wrong starknet field');
// and it should resolve to the new domain target
assert(naming.domain_to_address(domain) == new_target, 'wrong domain target');
}

0 comments on commit c84ba49

Please sign in to comment.