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
2 changes: 1 addition & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ mechanism.
#### Native Token Reserve Management

Please refer to
[native-token-reserve-management.md](./developer-guides/native-token-reserve-management.md) for
[native-token-reserve-management.md](./developer-guides/bridge-and-reserve.md) for
details on how to setting up and maintaining a native token reserve on Cardano to be used with a
partner chain.

Expand Down
24 changes: 12 additions & 12 deletions e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pytest -rP -v --blockchain substrate --env local --log-cli-level debug -vv -s -m
#### Run tests on the staging environment

```bash
pytest -rP -v --blockchain substrate --env staging --log-cli-level debug -vv -s -m "not probability"
pytest -rP -v --blockchain substrate --env staging --decrypt --log-cli-level debug -vv -s -m "not probability"
```

#### Run multisig governance tests
Expand Down Expand Up @@ -173,20 +173,20 @@ All test layers upload full logs, metrics, and test reports to GitHub Artifacts

#### **Delegator Rewards Tests**

| Test Name | Function | Purpose | Expected Result | Why This Test Matters | How Test is Run / RPC Example |
|:---------|:---------|:--------|:----------------|:----------------------|:------------------------------|
| Delegator Address Association | `test_delegator_can_associate_pc_address` | Bind stake address to sidechain | Association confirmed with valid signature | Enables rewards routing | `curl -d '{"jsonrpc":"2.0","method":"sidechain_getAddressAssociation","params":[stake_key_hash],"id":1}' http://localhost:9933` with signature validation |
| Block Production Log Pallet | `test_block_production_log_pallet` | Verify block production log is populated | Log entries match expected authors with correct SPO mapping | Ensures accurate block authorship tracking | `curl -d '{"jsonrpc":"2.0","method":"sidechain_getBlockProductionLog","params":[block_hash],"id":1}' http://localhost:9933` with SPO validation |
| Test Name | Function | Purpose | Expected Result | Why This Test Matters |
|:---------|:---------|:--------|:----------------|:----------------------|
| Delegator Address Association | `test_delegator_can_associate_pc_address` | Bind stake address to sidechain | Association confirmed with valid signature | Enables rewards routing |
| Block Production Log Pallet | `test_block_production_log_pallet` | Verify block production log is populated | Log entries match expected authors with correct SPO mapping | Ensures accurate block authorship tracking |

#### **Smart Contract Tests**

| Test Name | Function | Purpose | Expected Result | Why This Test Matters | How Test is Run / RPC Example |
|:---------|:---------|:--------|:----------------|:----------------------|:------------------------------|
| Init Reserve | `test_init_reserve` | Deploy reserve contracts | Contracts deployed with validator and policy scripts | Bootstraps economic layer | `curl -d '{"jsonrpc":"2.0","method":"sidechain_initReserve","params":[payment_key],"id":1}' http://localhost:9933` with script validation |
| Create Reserve | `test_create_reserve` | Initialize reserve with funds | Reserve funded with correct initial deposit | Starts token issuance | `curl -d '{"jsonrpc":"2.0","method":"sidechain_createReserve","params":[v_function_hash,initial_deposit,token,payment_key],"id":1}' http://localhost:9933` with balance validation |
| Release Funds | `test_release_funds` | Move tokens to circulation | Tokens released with correct reference UTXO | Enables token spending | `curl -d '{"jsonrpc":"2.0","method":"sidechain_releaseFunds","params":[reference_utxo,amount,payment_key],"id":1}' http://localhost:9933` with UTXO validation |
| Deposit Funds | `test_deposit_funds` | Return tokens to reserve | Tokens deposited with correct amount | Supports token locking | `curl -d '{"jsonrpc":"2.0","method":"sidechain_depositFunds","params":[amount,payment_key],"id":1}' http://localhost:9933` with balance validation |
| Handover Reserve | `test_handover_reserve` | Transfer entire reserve | Reserve transferred with zero balance | Handles lifecycle events | `curl -d '{"jsonrpc":"2.0","method":"sidechain_handoverReserve","params":[payment_key],"id":1}' http://localhost:9933` with balance validation |
| Test Name | Function | Purpose | Expected Result | Why This Test Matters |
|:---------|:---------|:--------|:----------------|:----------------------|
| Init Reserve | `test_init_reserve` | Deploy reserve contracts | Contracts deployed with validator and policy scripts | Bootstraps economic layer |
| Create Reserve | `test_create_reserve` | Initialize reserve with funds | Reserve funded with correct initial deposit | Starts token issuance |
| Release Funds | `test_release_funds` | Move tokens to circulation | Tokens released with correct reference UTXO | Enables token spending |
| Deposit Funds | `test_deposit_funds` | Return tokens to reserve | Tokens deposited with correct amount | Supports token locking |
| Handover Reserve | `test_handover_reserve` | Transfer entire reserve | Reserve transferred with zero balance | Handles lifecycle events |


For more details on how to implement Native Token Reserve Management in a partner chain, refer to the [Native Token Migration Guide](docs/developer-guides/native-token-migration-guide.md)
Expand Down
7 changes: 4 additions & 3 deletions e2e-tests/tests/committee/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@mark.xdist_group("faucet_tx")
@mark.ci
@mark.staging
@mark.test_key('ETCM-12429')
def test_block_producer_can_update_their_metadata(genesis_utxo, api: BlockchainApi, get_wallet: Wallet, write_file):
logger.info("Signing block producer metadata...")
skey, vkey_hex, vkey_hash = api.cardano_cli.generate_cross_chain_keys()
Expand Down Expand Up @@ -64,11 +65,11 @@ def test_block_producer_can_update_their_metadata(genesis_utxo, api: BlockchainA
@mark.xdist_group("faucet_tx")
@mark.ci
@mark.staging
@mark.test_key('ETCM-12430')
def test_block_producer_can_delete_their_metadata(genesis_utxo, api: BlockchainApi, get_wallet: Wallet, write_file):
logger.info("Signing block producer metadata...")
skey, vkey_hex, vkey_hash = api.cardano_cli.generate_cross_chain_keys()


logger.info("Starting upsert")
metadata = {
"url": "http://test.example",
Expand Down Expand Up @@ -106,10 +107,10 @@ def test_block_producer_can_delete_their_metadata(genesis_utxo, api: BlockchainA

logger.info(f"Public key: {vkey_hex}")
storage_metadata = api.get_block_producer_metadata(vkey_hash)
assert storage_metadata == None, "Block producer metadata not deleted from storage"
assert storage_metadata is None, "Block producer metadata not deleted from storage"

rpc_metadata = api.partner_chain_rpc.partner_chain_get_block_producer_metadata(vkey_hex).result
assert rpc_metadata == None, "RPC returned block producer metadata after deletion"
assert rpc_metadata is None, "RPC returned block producer metadata after deletion"


@mark.skip_on_new_chain
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/tests/committee/test_committee.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _t_candidates_seats(pc_epoch):

@mark.xdist_group("governance_action")
@mark.usefixtures("governance_skey_with_cli")
@mark.test_key('ETCM-9013')
def test_update_d_param(
self,
genesis_utxo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from src.blockchain_api import BlockchainApi
from config.api_config import ApiConfig
import logging
from pytest import mark


@mark.test_key('ETCM-8358')
def test_block_production_log_pallet(api: BlockchainApi, config: ApiConfig):
block = api.get_block()
block_no = block["header"]["number"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


@mark.xdist_group("faucet_tx")
@mark.test_key('ETCM-8359')
def test_delegator_can_associate_pc_address(genesis_utxo, api: BlockchainApi, new_wallet: Wallet, get_wallet: Wallet):
logging.info("Signing address association...")
stake_skey, stake_vkey = api.cardano_cli.generate_stake_keys()
Expand Down
6 changes: 6 additions & 0 deletions e2e-tests/tests/delegator_rewards/test_spo_journey.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def _count_blocks(mc_epoch, producer):
@mark.dependency(name="participation_data")
@mark.xdist_group("block_participation")
@mark.staging
@mark.test_key("ETCM-12432")
def test_block_participation_data_is_not_empty(block_participation):
assert block_participation
assert block_participation["up_to_moment"]
Expand All @@ -122,6 +123,7 @@ def test_block_participation_data_is_not_empty(block_participation):
@mark.dependency(name="pro_bono_participation")
@mark.xdist_group("block_participation")
@mark.staging
@mark.test_key("ETCM-12433")
def test_pro_bono_participation(
mc_epochs: range, api: BlockchainApi, initial_pc_epoch_included, count_blocks: int, block_participation
):
Expand Down Expand Up @@ -156,6 +158,7 @@ def test_pro_bono_participation(
@mark.dependency(name="spo_participation")
@mark.xdist_group("block_participation")
@mark.staging
@mark.test_key("ETCM-12434")
def test_spo_participation(
mc_epochs: range, api: BlockchainApi, count_blocks: int, block_participation, db_sync: Session
):
Expand Down Expand Up @@ -205,6 +208,7 @@ def test_spo_participation(
@mark.dependency(depends=["pro_bono_participation", "spo_participation"])
@mark.xdist_group("block_participation")
@mark.staging
@mark.test_key("ETCM-12435")
def test_no_unexpected_producers(block_participation):
assert not block_participation["producer_participation"], "Unexpected producer participation data"

Expand All @@ -222,10 +226,12 @@ def set_margin_fee(self, api: BlockchainApi, get_wallet: Wallet, random_margin_f
result = api.set_block_producer_margin_fee(random_margin_fee, wallet=get_wallet)
return result

@mark.test_key("ETCM-12436")
def test_set_margin_fee(self, set_margin_fee: Transaction):
logging.info(f"Margin fee set: {set_margin_fee}")
assert set_margin_fee._receipt.is_success

@mark.test_key("ETCM-12437")
def test_get_margin_fee(self, api: BlockchainApi, get_wallet: Wallet, random_margin_fee):
response = api.partner_chain_rpc.partner_chain_get_block_producer_fees()
account_id = get_wallet.address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@

@mark.staging
class TestGet:
@mark.test_key("ETCM-10357")
def test_insert_returncode(self, insert_data):
assert 0 == insert_data.returncode

@mark.usefixtures("insert_data")
@mark.test_key("ETCM-10358")
def test_get_returncode(self, api: BlockchainApi, genesis_utxo, random_key):
result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
assert 0 == result.returncode

@mark.usefixtures("insert_data")
@mark.test_key("ETCM-10359")
def test_get_value(self, api: BlockchainApi, genesis_utxo, random_key, random_value):
result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
value = hex_bytes_to_string(result.json)
assert random_value == value, "Data mismatch in governed map retrieval"

@mark.test_key("ETCM-10360")
def test_get_non_existent_key(self, api: BlockchainApi, genesis_utxo):
result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, "non_existent_key")
assert {} == result.json
assert 0 == result.returncode

@mark.usefixtures("insert_data")
@mark.test_key("ETCM-10361")
def test_list_whole_map(self, api: BlockchainApi, genesis_utxo, random_key, random_value):
result = api.partner_chains_node.smart_contracts.governed_map.list(genesis_utxo)
expected_value = string_to_hex_bytes(random_value)
Expand All @@ -51,23 +56,27 @@ def insert_twice_with_different_value(
result = api.partner_chains_node.smart_contracts.governed_map.insert(genesis_utxo, random_key, hex_data, payment_key)
return result

@mark.test_key("ETCM-10362")
def test_insert_with_the_same_value(self, insert_twice_with_the_same_value):
result = insert_twice_with_the_same_value
assert 0 == result.returncode
assert {} == result.json

@mark.test_key("ETCM-10363")
def test_value_remains_the_same(
self, api: BlockchainApi, insert_twice_with_the_same_value, 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)
assert random_value == value

@mark.test_key("ETCM-10364")
def test_insert_with_different_value(self, insert_twice_with_different_value):
result = insert_twice_with_different_value
assert 1 == result.returncode
assert "There is already a value stored for key" in result.stderr

@mark.test_key("ETCM-10365")
def test_value_was_not_updated(
self, api: BlockchainApi, insert_twice_with_different_value, genesis_utxo, random_key, random_value
):
Expand All @@ -84,14 +93,17 @@ def remove_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key,
result = api.partner_chains_node.smart_contracts.governed_map.remove(genesis_utxo, random_key, payment_key)
return result

@mark.test_key("ETCM-10366")
def test_remove_returncode(self, remove_data):
assert 0 == remove_data.returncode

@mark.test_key("ETCM-10367")
def test_get_after_remove(self, api: BlockchainApi, remove_data, 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

@mark.test_key("ETCM-10368")
def test_remove_non_existent_key(self, api: BlockchainApi, genesis_utxo, payment_key):
result = api.partner_chains_node.smart_contracts.governed_map.remove(genesis_utxo, "non_existent_key", payment_key)
assert 0 == result.returncode
Expand Down
12 changes: 12 additions & 0 deletions e2e-tests/tests/governed_map/smart_contracts/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key,
)
return result

@mark.test_key("ETCM-10369")
def test_update_returncode(self, update_data):
assert update_data.returncode == 0

@mark.test_key("ETCM-10370")
def test_update_value(self, api: BlockchainApi, genesis_utxo, random_key, new_value_hex_bytes):
get_result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
assert new_value_hex_bytes == get_result.json, "Data mismatch after update in governed map retrieval"
Expand All @@ -37,10 +39,12 @@ def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key,
)
return result

@mark.test_key("ETCM-10371")
def test_update_response(self, update_data):
assert update_data.returncode == 0
assert update_data.json == {}

@mark.test_key("ETCM-10372")
def test_value_remains_the_same(self, api: BlockchainApi, genesis_utxo, random_key, random_value):
get_result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
assert string_to_hex_bytes(random_value) == get_result.json
Expand All @@ -59,9 +63,11 @@ def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key,
)
return result

@mark.test_key("ETCM-10373")
def test_update_returncode(self, update_data):
assert update_data.returncode == 0

@mark.test_key("ETCM-10374")
def test_update_value(self, api: BlockchainApi, genesis_utxo, random_key, new_value_hex_bytes):
get_result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
assert new_value_hex_bytes == get_result.json, "Data mismatch after update in governed map retrieval"
Expand All @@ -80,10 +86,12 @@ def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key,
)
return result

@mark.test_key("ETCM-10375")
def test_update_response(self, update_data):
assert update_data.returncode == 0
assert update_data.json == {}

@mark.test_key("ETCM-10376")
def test_value_remains_the_same(self, api: BlockchainApi, genesis_utxo, random_key, random_value):
get_result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
assert string_to_hex_bytes(random_value) == get_result.json
Expand All @@ -102,10 +110,12 @@ def update_data(self, api: BlockchainApi, insert_data, genesis_utxo, random_key,
)
return result

@mark.test_key("ETCM-10377")
def test_update_returncode_and_message(self, update_data, random_key):
assert update_data.returncode == 1
assert f"Value for key '{random_key}' is set to a different value than expected" in update_data.stderr

@mark.test_key("ETCM-10378")
def test_update_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)
assert (
Expand All @@ -125,9 +135,11 @@ def update_data(self, api: BlockchainApi, genesis_utxo, random_key, new_value_he
)
return result

@mark.test_key("ETCM-10379")
def test_update_returncode(self, update_data):
assert update_data.returncode == 1

@mark.test_key("ETCM-10380")
def test_update_value(self, api: BlockchainApi, genesis_utxo, random_key):
get_result = api.partner_chains_node.smart_contracts.governed_map.get(genesis_utxo, random_key)
assert {} == get_result.json
Loading
Loading