def test_name_status_unavailable(): # claim a domain domain = random_domain() occupy_name = AEName(domain) occupy_name.full_claim_blocking(keypair) # wait for the state to propagate in the block chain EpochClient().wait_for_next_block() same_name = AEName(domain) assert not same_name.is_available()
def test_revocation(): domain = random_domain() name = AEName(domain) name.full_claim_blocking(keypair) EpochClient().wait_for_next_block() name.revoke() assert name.status == AEName.Status.REVOKED EpochClient().wait_for_next_block() assert AEName(domain).is_available()
def name_register(ctx, name_ttl): # retrieve the domain from the context domain = ctx.obj.get(CTX_AET_DOMAIN) # retrieve the keypair kp, _ = _keypair() name = AEName(domain) name.update_status() if name.status != AEName.Status.AVAILABLE: print("Domain not available") exit(0) name.full_claim_blocking(kp, name_ttl=name_ttl) print(f"Name {domain} claimed") pass
def test_name_update(): client = EpochClient() # claim a domain domain = random_domain() name = AEName(domain) name.full_claim_blocking(keypair) client.wait_for_next_block() client.wait_for_next_block() assert not AEName(domain).is_available(), 'The name should be claimed now' name.update_status() transaction = name.update(keypair, target=client.get_pubkey()) client.wait_for_next_block() name.update_status() assert name.pointers != [], 'Pointers should not be empty' assert name.pointers['account_pubkey'] == client.get_pubkey()
def test_name_update(): client = EpochClient() # claim a domain domain = random_domain() print(f"domain is {domain}") name = AEName(domain) print("Claim name ", domain) name.full_claim_blocking(keypair, name_ttl=70) print("got next block") client.wait_n_blocks(2) print("got next block") assert not AEName(domain).is_available(), 'The name should be claimed now' name.update_status() client.wait_n_blocks(2) name.update_status() print("claimed name", name) assert name.pointers != [], 'Pointers should not be empty' assert name.pointers['account_pubkey'] == keypair.get_address()
def test_transfer_ownership(): client = EpochClient() name = AEName(random_domain()) name.full_claim_blocking(keypair) assert name.status == AEName.Status.CLAIMED client.wait_for_next_block() new_key_pair = KeyPair.generate() # put some coins into the account so the account is in the state tree # otherwise it couldn't become the owner of an address. client.spend(keypair, new_key_pair.get_address(), 1) client.wait_for_next_block() # now transfer the name to the other account name.transfer_ownership(keypair, new_key_pair.get_address()) assert name.status == AEName.Status.TRANSFERRED client.wait_for_next_block() # try changing the target using that new keypair name.update_status() name.update(new_key_pair, target=keypair.get_address()) client.wait_for_next_block() name.update_status() assert name.pointers != [], 'Pointers should not be empty' assert name.pointers['account_pubkey'] == new_key_pair.get_address()
def name_register(ctx, name_ttl, ttl): try: # retrieve the domain from the context domain = ctx.obj.get(CTX_AET_DOMAIN) # retrieve the keypair kp, _ = _keypair() name = AEName(domain, client=_epoch_cli()) name.update_status() if name.status != AEName.Status.AVAILABLE: print("Domain not available") exit(0) tx = name.full_claim_blocking(kp, name_ttl=name_ttl, tx_ttl=ttl) _pp([ ("Transaction hash", tx.tx_hash), ], title=f"Name {domain} claimed") except Exception as e: _ppe(e)