Skip to content

Commit

Permalink
fixed operator skipped tests (#391)
Browse files Browse the repository at this point in the history
* fixed operator skipped tests

* Update test_revision.py

* fix mark

* Update test_revision.py

* Update test_revision.py
  • Loading branch information
kristinaNikolaevaa authored Aug 1, 2024
1 parent da29183 commit 6917072
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 54 deletions.
3 changes: 0 additions & 3 deletions integration/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ def pytest_collection_modifyitems(config, items):
else:
deselected_marks.append("only_devnet")

if network_name != "night-stand":
deselected_marks.append("slow")

envs_file = config.getoption("--envs")
with open(pathlib.Path().parent.parent / envs_file, "r+") as f:
environments = json.load(f)
Expand Down
27 changes: 16 additions & 11 deletions integration/tests/economy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def counter_contract(account_with_all_tokens, client_and_price, web3_client_sol,
def client_and_price(web3_client, web3_client_sol, request, pytestconfig):
client = {
"neon": web3_client,
"sol": web3_client_sol if "sol" in pytestconfig.environment.network_ids else None
"sol": web3_client_sol if "sol" in pytestconfig.environment.network_ids else None,
}.get(request.param)

if client:
Expand Down Expand Up @@ -74,21 +74,26 @@ def erc721_neon_chain(web3_client: NeonChainWeb3Client, faucet, pytestconfig: Co


@pytest.fixture(scope="class")
def erc721(
erc721_neon_chain,
client_and_price,
faucet,
account_with_all_tokens
):
def erc721(erc721_neon_chain, client_and_price, faucet, account_with_all_tokens):
client, _ = client_and_price
contract = ERC721ForMetaplex(client, faucet, account=account_with_all_tokens,
contract_address=erc721_neon_chain.contract.address)
contract = ERC721ForMetaplex(
client, faucet, account=account_with_all_tokens, contract_address=erc721_neon_chain.contract.address
)

return contract


@pytest.fixture(scope="class")
def alt_contract(accounts, web3_client):
contract, _ = web3_client.deploy_and_get_contract(
"common/ALT", "0.8.10", account=accounts[0], constructor_args=[8]
contract, _ = web3_client.deploy_and_get_contract("common/ALT", "0.8.10", account=accounts[0], constructor_args=[8])
return contract


@pytest.fixture(scope="class")
def mapping_actions_contract(account_with_all_tokens, client_and_price, web3_client_sol, web3_client):
w3_client = client_and_price[0]
make_nonce_the_biggest_for_chain(account_with_all_tokens, w3_client, [web3_client, web3_client_sol])
contract, _ = w3_client.deploy_and_get_contract(
contract="common/Common", version="0.8.12", contract_name="MappingActions", account=account_with_all_tokens
)
return contract
4 changes: 1 addition & 3 deletions integration/tests/economy/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def check_alt_on(web3_client, sol_client, receipt, accounts_quantity):
max_supported_transaction_version=0,
)
alt = trx.value.transaction.transaction.message.address_table_lookups
accounts = alt[0].writable_indexes + alt[0].readonly_indexes
assert len(accounts) == accounts_quantity - 2

assert alt

@allure.step("Check block for not using ALT")
def check_alt_off(block):
Expand Down
45 changes: 13 additions & 32 deletions integration/tests/economy/test_economics.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ def test_withdraw_neon_existing_ata(
trx = Transaction()
trx.add(create_associated_token_account(sol_user.public_key, sol_user.public_key, neon_mint))

opts = TxOpts(skip_preflight=True, skip_confirmation=False)
sol_client.send_transaction(trx, sol_user, opts=opts)
sol_client.send_tx_and_check_status_ok(trx, sol_user)

dest_token_acc = get_associated_token_address(sol_user.public_key, neon_mint)

Expand Down Expand Up @@ -632,59 +631,44 @@ def test_deploy_contract_to_exist_unpayed(
get_gas_used_percent(w3_client, contract_deploy_tx)

@pytest.mark.slow
@pytest.mark.skip
@pytest.mark.timeout(16 * Time.MINUTE)
def test_deploy_contract_alt_on(
self, sol_client, neon_price, sol_price, operator, web3_client, accounts, alt_contract, faucet
self, sol_client, neon_price, sol_price, operator, web3_client, accounts, alt_contract
):
"""Trigger transaction than requires more than 30 accounts"""
sender_account = accounts[0]
faucet.request_neon(sender_account.address, 10000)
accounts_quantity = random.randint(31, 45)
accounts_quantity = 45
sol_balance_before = operator.get_solana_balance()
neon_balance_before = operator.get_token_balance(web3_client)
tx = web3_client.make_raw_tx(sender_account)

instr = alt_contract.functions.fill(accounts_quantity).build_transaction(tx)

receipt = web3_client.send_transaction(sender_account, instr)
check_alt_on(web3_client, sol_client, receipt, accounts_quantity)

sol_trx_with_alt = get_sol_trx_with_alt(web3_client, sol_client, receipt)
assert sol_trx_with_alt is not None, "There are no lookup table for alt transaction"
operator_key = PublicKey(sol_trx_with_alt.value.transaction.transaction.message.account_keys[0])

alt_address = sol_trx_with_alt.value.transaction.transaction.message.address_table_lookups[0].account_key
alt_balance = sol_client.get_balance(PublicKey(alt_address)).value
operator_balance = sol_client.get_balance(operator_key).value

wait_condition(
lambda: operator.get_solana_balance() != sol_balance_before,
timeout_sec=120,
lambda: not sol_client.account_exists(alt_address),
timeout_sec=10 * Time.MINUTE,
delay=3,
)

sol_balance_after = operator.get_solana_balance()
neon_balance_after = operator.get_token_balance(web3_client)

assert sol_balance_before > sol_balance_after
assert neon_balance_after > neon_balance_before
neon_diff = web3_client.to_main_currency(neon_balance_after - neon_balance_before)
assert_profit(
sol_balance_before - sol_balance_after - alt_balance,
sol_balance_before - sol_balance_after,
sol_price,
neon_diff,
neon_price,
web3_client.native_token_name,
)
# the charge for alt creating should be returned
wait_condition(
lambda: sol_client.get_balance(operator_key).value > operator_balance,
timeout_sec=15 * Time.MINUTE,
delay=3,
)

assert (
operator_balance + alt_balance - TX_COST * 2 == sol_client.get_balance(operator_key).value
), "Operator balance after the return of the alt creation fee is not correct"
get_gas_used_percent(web3_client, receipt)

def test_deploy_contract_alt_off(
Expand Down Expand Up @@ -735,9 +719,9 @@ def test_deploy_big_contract_with_structures(self, client_and_price, account_wit
)
get_gas_used_percent(w3_client, receipt)

@pytest.mark.skip(reason="work incorrect very often")
@pytest.mark.timeout(30 * Time.MINUTE)
@pytest.mark.parametrize("value", [20, 25, 55])
@pytest.mark.slow
@pytest.mark.parametrize("value", [20, 30])
def test_call_contract_with_mapping_updating(
self,
client_and_price,
Expand All @@ -748,19 +732,16 @@ def test_call_contract_with_mapping_updating(
sol_client,
value,
operator,
mapping_actions_contract
):
w3_client, token_price = client_and_price
make_nonce_the_biggest_for_chain(account_with_all_tokens, w3_client, [web3_client, web3_client_sol])
contract, _ = w3_client.deploy_and_get_contract(
contract="common/Common", version="0.8.12", contract_name="MappingActions", account=account_with_all_tokens
)

sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(w3_client)

tx = w3_client.make_raw_tx(account_with_all_tokens.address)

instruction_tx = contract.functions.replaceValues(value).build_transaction(tx)
instruction_tx = mapping_actions_contract.functions.replaceValues(value).build_transaction(tx)
receipt = w3_client.send_transaction(account_with_all_tokens, instruction_tx)
assert receipt["status"] == 1
wait_condition(lambda: sol_balance_before != operator.get_solana_balance())
Expand All @@ -770,7 +751,7 @@ def test_call_contract_with_mapping_updating(
alt_address = sol_trx_with_alt.value.transaction.transaction.message.address_table_lookups[0].account_key
wait_condition(
lambda: not sol_client.account_exists(alt_address),
timeout_sec=10 * Time.MINUTE,
timeout_sec=11 * Time.MINUTE,
delay=3,
)

Expand Down
16 changes: 11 additions & 5 deletions integration/tests/neon_evm/test_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ def test_insufficient_balance_for_2_parallel_trx(
operator_keypair,
)

@pytest.mark.skip(reason="Isn't implemented yet")
def test_parallel_change_balance_in_one_trx_and_check_in_second_trx(
self, operator_keypair, treasury_pool, neon_api_client, sender_with_tokens, evm_loader, holder_acc
):
Expand All @@ -539,7 +538,6 @@ def test_parallel_change_balance_in_one_trx_and_check_in_second_trx(
evm_loader.send_transaction_step_from_account(
operator_keypair,
operator_balance_pubkey,
evm_loader,
treasury_pool,
holder_acc,
accounts,
Expand All @@ -554,9 +552,17 @@ def test_parallel_change_balance_in_one_trx_and_check_in_second_trx(
)
check_transaction_logs_have_text(resp, "exit_status=0x11")

resp = evm_loader.send_transaction_step_from_account(
operator_keypair, operator_balance_pubkey, treasury_pool, holder_acc, accounts, EVM_STEPS, operator_keypair
)
for _ in range(2):
resp = evm_loader.send_transaction_step_from_account(
operator_keypair,
operator_balance_pubkey,
treasury_pool,
holder_acc,
accounts,
EVM_STEPS,
operator_keypair,
)

check_transaction_logs_have_text(resp, "exit_status=0x11")
check_holder_account_tag(holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE)

Expand Down

0 comments on commit 6917072

Please sign in to comment.