Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions e2e-tests/tests/committee/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def initialize_permissioned_candidates(api: BlockchainApi, db: Session, current_


@fixture
def candidate(request, initialize_candidates, api: BlockchainApi, config: ApiConfig, db: Session) -> Candidates:
@mark.usefixtures("initialize_candidates")
def candidate(request, api: BlockchainApi, config: ApiConfig, db: Session) -> Candidates:
"""Parameterized fixture to get the first 'active' or 'inactive' candidate.

Use @pytest.mark.candidate_status() to pass data ('active' or 'inactive' only).
Expand Down Expand Up @@ -153,8 +154,8 @@ def candidate(request, initialize_candidates, api: BlockchainApi, config: ApiCon


@fixture
def permissioned_candidates(
initialize_permissioned_candidates, api: BlockchainApi, config: ApiConfig
@mark.usefixtures("initialize_permissioned_candidates")
def permissioned_candidates(api: BlockchainApi, config: ApiConfig
) -> Tuple[dict[str, Node], str]:
"""
Creates a tuple of new permissioned candidates to set and the name of the candidate to remove.
Expand Down
8 changes: 5 additions & 3 deletions e2e-tests/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import subprocess
from omegaconf import OmegaConf
from pytest import fixture, skip, Config, Metafunc, UsageError
from pytest import fixture, skip, mark, Config, Metafunc, UsageError
from src.log_filter import sensitive_filter
from src.blockchain_api import BlockchainApi, Wallet
from src.blockchain_types import BlockchainTypes
Expand Down Expand Up @@ -334,7 +334,8 @@ def secrets_ci(secrets, decrypt, ci_path):


@fixture(scope="session", autouse=True)
def decrypt_keys(tmp_path_factory, config, blockchain, nodes_env, decrypt, ci_run):
@mark.usefixtures("ci_run")
def decrypt_keys(tmp_path_factory, config, blockchain, nodes_env, decrypt):
if decrypt:
root_tmp_dir = tmp_path_factory.getbasetemp().parent
fn = root_tmp_dir / "secrets"
Expand Down Expand Up @@ -421,7 +422,8 @@ def teardown(request, api: BlockchainApi):


@fixture(scope="session", autouse=True)
def check_mc_sync_progress(api: BlockchainApi, decrypt_keys) -> Wallet:
@mark.usefixtures("decrypt_keys")
def check_mc_sync_progress(api: BlockchainApi) -> Wallet:
logging.info("Checking if cardano node is fully synced")
sync_progress = api.get_mc_sync_progress()
if float(sync_progress) != 100.00:
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/tests/governed_map/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def random_string(length=10):


@fixture(scope="session")
def payment_key(config: ApiConfig, governance_skey_with_cli):
@mark.usefixtures("governance_skey_with_cli")
def payment_key(config: ApiConfig):
return config.nodes_config.governance_authority.mainchain_key


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ def test_list_whole_map(self, api: BlockchainApi, genesis_utxo, random_key, rand

class TestInsertTwice:
@fixture(scope="class")
def insert_twice_with_the_same_value(self, api: BlockchainApi, insert_data, genesis_utxo, random_key, random_value, payment_key):
@mark.usefixtures("insert_data")
def insert_twice_with_the_same_value(self, api: BlockchainApi, genesis_utxo, random_key, random_value, payment_key):
hex_data = string_to_hex_bytes(random_value)
result = api.partner_chains_node.smart_contracts.governed_map.insert(genesis_utxo, random_key, hex_data, payment_key)
return result

@fixture(scope="class")
@mark.usefixtures("insert_data")
def insert_twice_with_different_value(
self, api: BlockchainApi, insert_data, genesis_utxo, random_key, new_value_hex_bytes, payment_key
self, api: BlockchainApi, genesis_utxo, random_key, new_value_hex_bytes, payment_key
):
hex_data = string_to_hex_bytes(new_value_hex_bytes)
result = api.partner_chains_node.smart_contracts.governed_map.insert(genesis_utxo, random_key, hex_data, payment_key)
Expand All @@ -54,8 +56,9 @@ def test_insert_with_the_same_value(self, insert_twice_with_the_same_value):
assert 0 == result.returncode
assert {} == result.json

@mark.usefixtures("insert_twice_with_the_same_value")
def test_value_remains_the_same(
self, api: BlockchainApi, insert_twice_with_the_same_value, genesis_utxo, random_key, random_value
self, api: BlockchainApi, genesis_utxo, random_key, random_value
):
get_result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
value = hex_bytes_to_string(get_result.json)
Expand All @@ -66,8 +69,9 @@ def test_insert_with_different_value(self, insert_twice_with_different_value):
assert 1 == result.returncode
assert "There is already a value stored for key" in result.stderr

@mark.usefixtures("insert_twice_with_different_value")
def test_value_was_not_updated(
self, api: BlockchainApi, insert_twice_with_different_value, genesis_utxo, random_key, random_value
self, api: BlockchainApi, genesis_utxo, random_key, random_value
):
get_result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
value = hex_bytes_to_string(get_result.json)
Expand All @@ -77,14 +81,16 @@ def test_value_was_not_updated(

class TestRemove:
@fixture(scope="class")
def remove_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key, payment_key):
@mark.usefixtures("insert_data")
def remove_data(self, api: BlockchainApi, genesis_utxo, random_key, payment_key):
result = api.partner_chains_node.smart_contracts.governed_map.remove(genesis_utxo, random_key, payment_key)
return result

def test_remove_returncode(self, remove_data):
assert 0 == remove_data.returncode

def test_get_after_remove(self, api: BlockchainApi, remove_data, genesis_utxo, random_key):
@mark.usefixtures("remove_data")
def test_get_after_remove(self, api: BlockchainApi, genesis_utxo, random_key):
result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
assert {} == result.json
assert 0 == result.returncode
Expand Down
15 changes: 10 additions & 5 deletions e2e-tests/tests/governed_map/smart_contracts/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

class TestUpdate:
@fixture(scope="class", autouse=True)
def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key, new_value_hex_bytes, payment_key):
@mark.usefixtures("insert_data")
def update_data(self, api: BlockchainApi, genesis_utxo, random_key, new_value_hex_bytes, payment_key):
result = api.partner_chains_node.smart_contracts.governed_map.update(
genesis_utxo,
random_key,
Expand All @@ -26,7 +27,8 @@ def test_update_value(self, api: BlockchainApi, genesis_utxo, random_key, new_va

class TestUpdateWithTheSameValue:
@fixture(scope="class", autouse=True)
def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key, random_value, payment_key):
@mark.usefixtures("insert_data")
def update_data(self, api: BlockchainApi, genesis_utxo, random_key, random_value, payment_key):
result = api.partner_chains_node.smart_contracts.governed_map.update(
genesis_utxo,
random_key,
Expand All @@ -46,7 +48,8 @@ def test_value_remains_the_same(self, api: BlockchainApi, genesis_utxo, random_k

class TestUpdateWithExpectedCurrentValue:
@fixture(scope="class", autouse=True)
def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key, random_value, new_value_hex_bytes, payment_key):
@mark.usefixtures("insert_data")
def update_data(self, api: BlockchainApi, genesis_utxo, random_key, random_value, new_value_hex_bytes, payment_key):
result = api.partner_chains_node.smart_contracts.governed_map.update(
genesis_utxo,
random_key,
Expand All @@ -66,7 +69,8 @@ def test_update_value(self, api: BlockchainApi, genesis_utxo, random_key, new_va

class TestUpdateWithExpectedCurrentValueAndTheSameValue:
@fixture(scope="class", autouse=True)
def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key, random_value, payment_key):
@mark.usefixtures("insert_data")
def update_data(self, api: BlockchainApi, genesis_utxo, random_key, random_value, payment_key):
result = api.partner_chains_node.smart_contracts.governed_map.update(
genesis_utxo,
random_key,
Expand All @@ -87,7 +91,8 @@ def test_value_remains_the_same(self, api: BlockchainApi, genesis_utxo, random_k

class TestUpdateWithNonMatchingCurrentValue:
@fixture(scope="class", autouse=True)
def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key, new_value_hex_bytes, payment_key):
@mark.usefixtures("insert_data")
def update_data(self, api: BlockchainApi, genesis_utxo, random_key, new_value_hex_bytes, payment_key):
result = api.partner_chains_node.smart_contracts.governed_map.update(
genesis_utxo,
random_key,
Expand Down
21 changes: 14 additions & 7 deletions e2e-tests/tests/governed_map/test_observability.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def set_governed_map_scripts(api: BlockchainApi, addresses, policy_ids, sudo):


@fixture(scope="session", autouse=True)
def observe_governed_map_initialization(api: BlockchainApi, set_governed_map_scripts):
@mark.usefixtures("set_governed_map_scripts")
def observe_governed_map_initialization(api: BlockchainApi):
result = api.subscribe_governed_map_initialization()
return result

Expand Down Expand Up @@ -56,22 +57,25 @@ def test_map_is_equal_to_main_chain_data(self, api: BlockchainApi, genesis_utxo,


class TestObserveMapChanges:
def test_new_data_is_observed(self, insert_data, api: BlockchainApi, random_key, random_value):
@mark.usefixtures("insert_data")
def test_new_data_is_observed(self, api: BlockchainApi, random_key, random_value):
registered_change = api.subscribe_governed_map_change(key_value=(random_key, random_value))
logging.info(f"Registered change: {registered_change}")
actual_value = api.get_governed_map_key(random_key)
assert random_value == actual_value

@mark.usefixtures("insert_data")
def test_updated_data_is_observed(
self, insert_data, api: BlockchainApi, genesis_utxo, random_key, new_value_hex_bytes, payment_key, new_value
self, api: BlockchainApi, genesis_utxo, random_key, new_value_hex_bytes, payment_key, new_value
):
api.partner_chains_node.smart_contracts.governed_map.update(genesis_utxo, random_key, new_value_hex_bytes, payment_key)
registered_change = api.subscribe_governed_map_change(key_value=(random_key, new_value))
logging.info(f"Registered change: {registered_change}")
actual_value = api.get_governed_map_key(random_key)
assert new_value == actual_value

def test_removed_data_is_observed(self, insert_data, api: BlockchainApi, genesis_utxo, random_key, payment_key):
@mark.usefixtures("insert_data")
def test_removed_data_is_observed(self, api: BlockchainApi, genesis_utxo, random_key, payment_key):
api.partner_chains_node.smart_contracts.governed_map.remove(genesis_utxo, random_key, payment_key)
registered_change = api.subscribe_governed_map_change(key_value=(random_key, None))
logging.info(f"Registered change: {registered_change}")
Expand All @@ -81,7 +85,8 @@ def test_removed_data_is_observed(self, insert_data, api: BlockchainApi, genesis

class TestReinitializeMap:
@fixture(scope="class")
def insert_data_and_wait_until_observed(self, insert_data, api: BlockchainApi, random_key, random_value):
@mark.usefixtures("insert_data")
def insert_data_and_wait_until_observed(self, api: BlockchainApi, random_key, random_value):
api.subscribe_governed_map_change(key_value=(random_key, random_value))
return api.get_governed_map()

Expand All @@ -95,15 +100,17 @@ def create_new_governed_map_address(self, api: BlockchainApi):
return new_address

@fixture(scope="class", autouse=True)
@mark.usefixtures("insert_data_and_wait_until_observed")
def set_new_governed_map_scripts(
self, create_new_governed_map_address, insert_data_and_wait_until_observed, api: BlockchainApi, policy_ids, sudo
self, create_new_governed_map_address, api: BlockchainApi, policy_ids, sudo
):
new_address = create_new_governed_map_address
tx = api.set_governed_map_main_chain_scripts(new_address, policy_ids["GovernedMap"], sudo)
return tx

@fixture(scope="class", autouse=True)
def observe_governed_map_reinitialization(self, api: BlockchainApi, set_new_governed_map_scripts):
@mark.usefixtures("set_new_governed_map_scripts")
def observe_governed_map_reinitialization(self, api: BlockchainApi):
result = api.subscribe_governed_map_initialization()
return result

Expand Down
23 changes: 15 additions & 8 deletions e2e-tests/tests/reserve/test_reserve_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ def init_bridge(api: BlockchainApi, genesis_utxo, payment_key):
return response

@fixture(scope="module", autouse=True)
def create_bridge_utxos(api: BlockchainApi, genesis_utxo, payment_key, init_bridge):
@mark.usefixtures("init_bridge")
def create_bridge_utxos(api: BlockchainApi, genesis_utxo, payment_key):
response = api.partner_chains_node.smart_contracts.bridge.create_utxos(genesis_utxo, 1, payment_key)
return response

@fixture(scope="module", autouse=True)
def init_reserve(api: BlockchainApi, genesis_utxo, payment_key, create_bridge_utxos):
@mark.usefixtures("create_bridge_utxos")
def init_reserve(api: BlockchainApi, genesis_utxo, payment_key):
response = api.partner_chains_node.smart_contracts.reserve.init(genesis_utxo, payment_key)
return response

Expand Down Expand Up @@ -58,13 +60,15 @@ def create_reserve(api: BlockchainApi, reserve, genesis_utxo, payment_key):


@fixture(scope="class")
def reserve_initial_balance(create_reserve, api: BlockchainApi, addresses, reserve_asset_id):
@mark.usefixtures("create_reserve")
def reserve_initial_balance(api: BlockchainApi, addresses, reserve_asset_id):
balance = api.get_mc_balance(addresses["ReserveValidator"], reserve_asset_id)
return balance


@fixture(scope="class")
def circulation_supply_initial_balance(create_reserve, api: BlockchainApi, reserve_asset_id, addresses):
@mark.usefixtures("create_reserve")
def circulation_supply_initial_balance(api: BlockchainApi, reserve_asset_id, addresses):
circulation_balance = api.get_mc_balance(addresses["IlliquidCirculationSupplyValidator"], reserve_asset_id)
return circulation_balance

Expand Down Expand Up @@ -105,10 +109,10 @@ def amount_to_release(self, reserve_initial_balance):
return random.randint(1, min(reserve_initial_balance, 100))

@fixture(scope="class", autouse=True)
@mark.usefixtures("circulation_supply_initial_balance")
def release_funds(
self,
amount_to_release,
circulation_supply_initial_balance,
api: BlockchainApi,
v_function: VFunction,
genesis_utxo,
Expand Down Expand Up @@ -162,7 +166,8 @@ def amount_to_deposit(self, reserve_initial_balance):
return random.randint(1, min(reserve_initial_balance, 100))

@fixture(scope="class", autouse=True)
def deposit_funds(self, native_token_balance, amount_to_deposit, api: BlockchainApi, genesis_utxo, payment_key):
@mark.usefixtures("native_token_balance")
def deposit_funds(self, amount_to_deposit, api: BlockchainApi, genesis_utxo, payment_key):
response = api.partner_chains_node.smart_contracts.reserve.deposit(
genesis_utxo,
amount=amount_to_deposit,
Expand Down Expand Up @@ -201,7 +206,8 @@ def new_v_function(self, v_function_factory, config: ApiConfig):
return v_function

@fixture(scope="class", autouse=True)
def update_v_function(self, create_reserve, new_v_function: VFunction, api: BlockchainApi, genesis_utxo, payment_key):
@mark.usefixtures("create_reserve")
def update_v_function(self, new_v_function: VFunction, api: BlockchainApi, genesis_utxo, payment_key):
response = api.partner_chains_node.smart_contracts.reserve.update_settings(
genesis_utxo,
v_function_hash=new_v_function.script_hash,
Expand Down Expand Up @@ -262,7 +268,8 @@ def test_lock_with_spending_ics_utxo(self, api: BlockchainApi, genesis_utxo, pay

class TestHandoverReserve:
@fixture(scope="class", autouse=True)
def handover_reserve(self, create_reserve, api: BlockchainApi, genesis_utxo, payment_key):
@mark.usefixtures("create_reserve")
def handover_reserve(self, api: BlockchainApi, genesis_utxo, payment_key):
response = api.partner_chains_node.smart_contracts.reserve.handover(genesis_utxo, payment_key)
return response

Expand Down
Loading