def test_name_auction(chain_fixture): if chain_fixture.NODE_CLI.get_consensus_protocol_version() < PROTOCOL_LIMA: skip("name auction is only supported after Lima HF") return try: domain = random_domain(length=12) node_cli = chain_fixture.NODE_CLI name = node_cli.AEName(domain) assert name.status == AEName.Status.UNKNOWN name.update_status() assert name.status == AEName.Status.AVAILABLE preclaim = name.preclaim(chain_fixture.ALICE) assert name.status == AEName.Status.PRECLAIMED node_cli.wait_for_confirmation(preclaim.hash) claim_tx = name.claim(preclaim.hash, chain_fixture.ALICE, preclaim.metadata.salt) print(claim_tx) assert name.status == AEName.Status.CLAIMED # bob will make another bid name2 = node_cli.AEName(domain) bid = AEName.compute_bid_fee(domain) bid_tx = name2.bid(chain_fixture.BOB, bid) print("BID TX", bid_tx) # get the tx height bid_h = node_cli.wait_for_transaction(bid_tx.hash) print(f"BOB BID Height is {bid_h}") # now we should wait to see that bob gets the name bid_ends = AEName.compute_auction_end_block(domain, bid_h) # print(f"BID STARTED AT {bid_h} WILL END AT {bid_ends}") except Exception as e: print(e) assert e is None
def test_spend_by_name(chain_fixture): # claim a domain domain = random_domain( tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version() >= PROTOCOL_LIMA else 'test', length=20) print(f"domain is {domain}") name = chain_fixture.NODE_CLI.AEName(domain) print("Claim name ", domain) # generate a new address target_address = Account.generate().get_address() print(f"Target address {target_address}") name.full_claim_blocking(chain_fixture.ALICE, target_address) # domain claimed name.update_status() assert not chain_fixture.NODE_CLI.AEName( domain).is_available(), 'The name should be claimed now' name.update_status() print(f"domain is {name.domain} name_id {name.name_id}") print("pointers", name.pointers) tx = chain_fixture.NODE_CLI.spend(chain_fixture.ALICE, domain, '1AE') print("DATA ", tx) recipient_account = chain_fixture.NODE_CLI.get_account_by_pubkey( pubkey=target_address) print( f"recipient address {target_address}, balance {recipient_account.balance}" ) assert recipient_account.balance == 1000000000000000000
def test_cli_name_claim(chain_fixture, tempdir): account_alice_path = _account_path(tempdir, chain_fixture.ALICE) # get a domain that is not under auction scheme domain = random_domain( length=13, tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version() >= identifiers.PROTOCOL_LIMA else 'test') # let alice preclaim a name j = call_aecli('name', 'pre-claim', '--password', 'aeternity_bc', account_alice_path, domain, '--wait') # retrieve the salt and the transaction hash salt = j.get("metadata", {}).get("salt") preclaim_hash = j.get("hash") # test that they are what we expect to be assert (isinstance(salt, int)) assert (salt > 0) assert (utils.is_valid_hash(preclaim_hash, identifiers.TRANSACTION_HASH)) # wait for confirmation chain_fixture.NODE_CLI.wait_for_confirmation(preclaim_hash) # now run the claim j = call_aecli('name', 'claim', account_alice_path, domain, '--password', 'aeternity_bc', '--name-salt', f"{salt}", '--preclaim-tx-hash', preclaim_hash, '--wait') assert (utils.is_valid_hash(j.get("hash"), identifiers.TRANSACTION_HASH)) # now run the name update j = call_aecli('name', 'update', '--password', 'aeternity_bc', account_alice_path, domain, chain_fixture.ALICE.get_address()) assert (utils.is_valid_hash(j.get("hash"), identifiers.TRANSACTION_HASH)) # now inspect the name j = call_aecli('inspect', domain) pointers = j.get('pointers', []) assert (len(pointers) == 1) assert (pointers[0]['id'] == chain_fixture.ALICE.get_address())
def test_name_update(chain_fixture): # avoid auctions domain = random_domain( length=13, tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version() >= PROTOCOL_LIMA else 'test') print(f"domain is {domain}") name = chain_fixture.NODE_CLI.AEName(domain) print("Claim name ", domain) name.full_claim_blocking(chain_fixture.ALICE, chain_fixture.ALICE.get_address()) # domain claimed name.update_status() assert not chain_fixture.NODE_CLI.AEName( domain).is_available(), 'The name should be claimed now' name.update_status() print("claimed name", name) print("pointers", name.pointers) assert len(name.pointers) > 0, 'Pointers should not be empty' assert name.pointers[0].id == chain_fixture.ALICE.get_address() assert name.pointers[0].key == "account_pubkey" # run another update name.update(chain_fixture.ALICE, chain_fixture.BOB.get_address(), ("origin", chain_fixture.ALICE.get_address())) name.update_status() assert len(name.pointers) == 2, 'Pointers should not be empty' assert name.pointers[0].id == chain_fixture.BOB.get_address() assert name.pointers[0].key == "account_pubkey" assert name.pointers[1].id == chain_fixture.ALICE.get_address() assert name.pointers[1].key == "origin"
def test_name_revocation(chain_fixture): # avoid auctions domain = random_domain(length=13) name = chain_fixture.NODE_CLI.AEName(domain) name.full_claim_blocking(chain_fixture.ALICE) name.revoke(chain_fixture.ALICE) assert name.status == AEName.Status.REVOKED assert chain_fixture.NODE_CLI.AEName(domain).is_available()
def test_cli_name_auction(chain_fixture, tempdir): if chain_fixture.NODE_CLI.get_consensus_protocol_version( ) < identifiers.PROTOCOL_LIMA: pytest.skip("name auction is only supported after Lima HF") return node_cli = chain_fixture.NODE_CLI account_alice_path = _account_path(tempdir, chain_fixture.ALICE) account_bob_path = _account_path(tempdir, chain_fixture.BOB) # get a domain that is under auction scheme domain = random_domain( length=9, tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version() >= identifiers.PROTOCOL_LIMA else 'test') # let alice preclaim a name j = call_aecli('name', 'pre-claim', '--password', 'aeternity_bc', account_alice_path, domain, '--wait') # retrieve the salt and the transaction hash salt = j.get("metadata", {}).get("salt") preclaim_hash = j.get("hash") # test that they are what we expect to be assert (isinstance(salt, int)) assert (salt > 0) assert (utils.is_valid_hash(preclaim_hash, identifiers.TRANSACTION_HASH)) # wait for confirmation chain_fixture.NODE_CLI.wait_for_confirmation(preclaim_hash) # now run the claim j = call_aecli('name', 'claim', account_alice_path, domain, '--password', 'aeternity_bc', '--name-salt', f"{salt}", '--preclaim-tx-hash', preclaim_hash, '--wait') assert (utils.is_valid_hash(j.get("hash"), identifiers.TRANSACTION_HASH)) # check that the tx was mined claim_height = chain_fixture.NODE_CLI.get_transaction_by_hash( hash=j.get('hash')).block_height assert (isinstance(claim_height, int) and claim_height > 0) # now we have a first claim # this is the name fee and the end block name_fee = AEName.compute_bid_fee(domain) aucion_end = AEName.compute_auction_end_block(domain, claim_height) print( f"Name {domain}, name_fee {name_fee}, claim height: {claim_height}, auction_end: {aucion_end}" ) # now make another bid # first compute the new name fee name_fee = AEName.compute_bid_fee(domain, name_fee) j = call_aecli('name', 'bid', account_bob_path, domain, f'{name_fee}', '--password', 'aeternity_bc', '--wait') assert (utils.is_valid_hash(j.get("hash"), identifiers.TRANSACTION_HASH)) # check that the tx was mined claim_height = chain_fixture.NODE_CLI.get_transaction_by_hash( hash=j.get('hash')).block_height assert (isinstance(claim_height, int) and claim_height > 0) aucion_end = AEName.compute_auction_end_block(domain, claim_height) print( f"Name {domain}, name_fee {name_fee}, claim height: {claim_height}, auction_end: {aucion_end}" ) name = chain_fixture.NODE_CLI.AEName(domain) # name should still be available assert (name.is_available())
def test_name_status_available(chain_fixture): domain = random_domain( length=13, tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version() >= PROTOCOL_LIMA else 'test') name = chain_fixture.NODE_CLI.AEName(domain) assert name.status == AEName.Status.UNKNOWN name.update_status() assert name.status == AEName.Status.AVAILABLE
def test_name_status_unavailable(chain_fixture): # avoid auctions domain = random_domain(length=13) print(f"domain is {domain}") occupy_name = chain_fixture.NODE_CLI.AEName(domain) occupy_name.full_claim_blocking(chain_fixture.ALICE) # try to get the same name same_name = chain_fixture.NODE_CLI.AEName(domain) assert not same_name.is_available()
def test_name_revocation(chain_fixture): # avoid auctions domain = random_domain( length=13, tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version() >= PROTOCOL_LIMA else 'test') name = chain_fixture.NODE_CLI.AEName(domain) name.full_claim_blocking(chain_fixture.ALICE) name.revoke(chain_fixture.ALICE) assert name.status == AEName.Status.REVOKED assert chain_fixture.NODE_CLI.AEName(domain).is_available()
def test_name_status_unavailable(chain_fixture): # avoid auctions domain = random_domain( length=13, tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version() >= PROTOCOL_LIMA else 'test') print(f"domain is {domain}") occupy_name = chain_fixture.NODE_CLI.AEName(domain) occupy_name.full_claim_blocking(chain_fixture.ALICE) # try to get the same name same_name = chain_fixture.NODE_CLI.AEName(domain) assert not same_name.is_available()
def test_node_contract_signature_delegation(compiler_fixture, chain_fixture): compiler = compiler_fixture.COMPILER account = chain_fixture.ALICE bob = chain_fixture.BOB contract_native = ContractNative(client=chain_fixture.NODE_CLI, source=contractAens, compiler=compiler, account=account) contract_native.deploy() assert (contract_native.address is not None) # the contract_id contract_id = contract_native.address # node client ae_cli = contract_native.client # example name name = random_domain(length=15) c_id, salt = hashing.commitment_id(name, 9876) name_ttl = 500000 client_ttl = 36000 name_fee = utils.amount_to_aettos("20AE") print(f"name is {name}, commitment_id: {c_id}") # aens calls signature = ae_cli.delegate_name_preclaim_signature(account, contract_id) call, r = contract_native.signedPreclaim(account.get_address(), c_id, signature) assert (call.return_type == 'ok') ae_cli.wait_for_confirmation(call.tx_hash) signature = ae_cli.delegate_name_claim_signature(account, contract_id, name) call, _ = contract_native.signedClaim(account.get_address(), name, salt, name_fee, signature) assert (call.return_type == 'ok') signature = ae_cli.delegate_name_transfer_signature( account, contract_id, name) call, _ = contract_native.signedTransfer(account.get_address(), bob.get_address(), name, signature) assert (call.return_type == 'ok') signature = ae_cli.delegate_name_revoke_signature(bob, contract_id, name) call, _ = contract_native.signedRevoke(bob.get_address(), name, signature) assert (call.return_type == 'ok')
def test_name_claim_lifecycle(chain_fixture): try: # avoid auctions domain = random_domain(length=13) node_cli = chain_fixture.NODE_CLI name = node_cli.AEName(domain) assert name.status == AEName.Status.UNKNOWN name.update_status() assert name.status == AEName.Status.AVAILABLE preclaim = name.preclaim(chain_fixture.ALICE) assert name.status == AEName.Status.PRECLAIMED node_cli.wait_for_confirmation(preclaim.hash) name.claim(preclaim.hash, chain_fixture.ALICE, preclaim.metadata.salt) assert name.status == AEName.Status.CLAIMED except Exception as e: print(e) assert e is None
def __fullclaim_domain(chain_fixture, tempdir, recipient_address): account_path = _account_path(tempdir, chain_fixture.ALICE) domain = random_domain(length=13) # let alice preclaim a name j = call_aecli('name', 'pre-claim', '--password', 'aeternity_bc', account_path, domain, '--wait') # retrieve the salt and the transaction hash salt = j.get("metadata", {}).get("salt") preclaim_hash = j.get("hash") # wait for confirmation chain_fixture.NODE_CLI.wait_for_confirmation(preclaim_hash) # now run the claim j = call_aecli('name', 'claim', account_path, domain, '--password', 'aeternity_bc', '--name-salt', f"{salt}", '--preclaim-tx-hash', preclaim_hash, '--wait') # now run the name update j = call_aecli('name', 'update', '--password', 'aeternity_bc', account_path, domain, recipient_address) return domain
def test_name_transfer_ownership(chain_fixture): # avoid auctions domain = random_domain(length=13) name = chain_fixture.NODE_CLI.AEName(domain) name.full_claim_blocking(chain_fixture.ALICE) assert name.status == AEName.Status.CLAIMED name.update_status() assert len(name.pointers) == 0, "Pointers should be empty" # now transfer the name to the other account name.transfer_ownership(chain_fixture.ALICE, chain_fixture.BOB.get_address()) assert name.status == AEName.Status.TRANSFERRED # try changing the target using that new account name.update_status() name.update(chain_fixture.BOB, chain_fixture.BOB.get_address()) name.update_status() assert len(name.pointers) > 0, 'Pointers should not be empty' assert name.pointers[0].id == chain_fixture.BOB.get_address() assert name.pointers[0].key == "account_pubkey"
def test_name_is_available(chain_fixture): domain = random_domain() name = chain_fixture.NODE_CLI.AEName(domain) assert name.is_available()
def test_name_is_available(chain_fixture): domain = random_domain( tld='chain' if chain_fixture.NODE_CLI.get_consensus_protocol_version( ) >= PROTOCOL_LIMA else 'test') name = chain_fixture.NODE_CLI.AEName(domain) assert name.is_available()
def test_name_status_available(chain_fixture): domain = random_domain(length=13) name = chain_fixture.NODE_CLI.AEName(domain) assert name.status == AEName.Status.UNKNOWN name.update_status() assert name.status == AEName.Status.AVAILABLE