Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETCM-8543 Fix test_block_headers_have_mc_hash #505

Merged
merged 1 commit into from
Feb 19, 2025
Merged
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
20 changes: 11 additions & 9 deletions e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Partner Chains Tests

Welcome to `Partner Chains Tests`, a powerful and flexible test automation framework for system and end-to-end (E2E) tests for partner chains.
Welcome to `Partner Chains Tests`, a powerful and flexible test automation framework for system and end-to-end (E2E) tests for partner chains.

## Features

Expand All @@ -10,23 +10,25 @@ Welcome to `Partner Chains Tests`, a powerful and flexible test automation frame

## Partner Chains Tests - Infrastructure

![Test Infrastructure](/docs/pc-tests-infra.png)
![Test Infrastructure](/e2e-tests/docs/pc-tests-infra.png)

## Installation

1. Install `python 3.12` and `pip`.
2. Create and activate virtual environment

```bash
$ pip install virtualenv
$ python -m venv venv
$ source venv/bin/active
pip install virtualenv
python -m venv venv
source venv/bin/activate
```

3. Install requirements `pip install -r requirements.txt`.
4. Install sops to [manage keys](/docs/secrets.md). You can also configure [your own keys with sops](/docs/configure-sops.md)
4. Install sops to [manage keys](/e2e-tests/docs/secrets.md). You can also configure [your own keys with sops](/e2e-tests/docs/configure-sops.md)

## Getting Started

- Choose an environment to run tests. You have an option to run on [local](/docs/run-tests-on-local-env.md) or [your own custom](/docs/run-tests-on-new-env.md) environments
- Choose an environment to run tests. You have an option to run on [local](/e2e-tests/docs/run-tests-on-local-env.md) or [your own custom](/e2e-tests/docs/run-tests-on-new-env.md) environments
- Run `pytest -h` to see all available options, or simply `pytest` to execute all tests.

### Execution Options
Expand Down Expand Up @@ -56,5 +58,5 @@ Custom options:
### Run tests on the local environment

```bash
$ pytest -rP -v --blockchain substrate --env local --stack local --log-cli-level debug -vv -s -m "not active_flow and not passive_flow and not probability"
```
pytest -rP -v --blockchain substrate --env local --stack local --log-cli-level debug -vv -s -m "not active_flow and not passive_flow and not probability"
```
29 changes: 16 additions & 13 deletions e2e-tests/docs/run-tests-on-local-env.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
# How to run system tests on a partner-chains local environment
# How to run system tests on a partner-chains local environment

## Prerequisites

- Docker Desktop, lazydocker
- python3, pip

## Steps
## Steps

1. Configure partner-chains local environment by running [setup.sh](https://github.com/input-output-hk/partner-chains/blob/master/dev/local-environment/setup.sh)
* If you want to use a pre-configured postgres password from /secrets/local/local.json: `$ ./setup.sh -p <PASSWORD>`
* If you want to use generated password from local env: run `$ ./setup.sh -n`. Password is saved in `.env` file, you will need it later
1. Configure partner-chains local environment by running [setup.sh](/dev/local-environment/setup.sh)
- If you want to use a pre-configured postgres password from /e2e-tests/secrets/substrate/local/local.json: `$ ./setup.sh -p <PASSWORD>`
- If you want to use generated password from local env: run `$ ./setup.sh -n`. Password is saved in `.env` file, you will need it later
2. Run local environment: `$ docker-compose up -d` and wait until the partner chains nodes finish syncing
3. Get initial_timestamp value: `$ docker exec cardano-node-1 cat /shared/cardano.start`
4. Set postgres passwords
* If you used a pre-configured password, skip this step
* If you used a generated password - update db and dbSync password values in `secrets/substrate/local/local.json` with the POSTGRES_PASSWORD env variable value from the `.env` file
5. Update `main_chain.init_timestamp` at config/substrate/local_nodes.json to the resulting value of `docker exec cardano-node-1 cat /shared/cardano.start`
- If you used a pre-configured password, skip this step
- If you used a generated password - update db and dbSync password values in `secrets/substrate/local/local.json` with the POSTGRES_PASSWORD env variable value from the `.env` file
5. Update `main_chain.init_timestamp` at config/substrate/local_nodes.json to the resulting value of `docker exec cardano-node-1 cat /shared/cardano.start` or alteratively pass it directly to `pytest` with `--init-timestamp=1234567890`
6. Create and activate virtual environment

```bash
$ pip install virtualenv
$ python -m venv venv
$ source venv/bin/active
pip install virtualenv
python -m venv venv
source venv/bin/active
```

1. Install project dependencies: `$ pip install -r requirements.txt`
2. Run partner-chains tests on partner-chains local environment

```bash
$ pytest -rP -v --blockchain substrate --env local --stack local --log-cli-level debug -vv -s -m "not active_flow and not passive_flow and not probability"
pytest -rP -v --blockchain substrate --env local --stack local --log-cli-level debug -vv -s -m "not active_flow and not passive_flow and not probability"
```

## Substrate Portal

After you start the node locally, you can interact with it using the hosted version of the [Polkadot/Substrate Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9945) front-end by connecting to the local node endpoint.
After you start the node locally, you can interact with it using the hosted version of the [Polkadot/Substrate Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9945) front-end by connecting to the local node endpoint.
7 changes: 6 additions & 1 deletion e2e-tests/tests/committee/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def test_block_headers_have_mc_hash(api: BlockchainApi, config: ApiConfig, pc_ep

logger.debug(f"Difference between latest and stable mc block: {latest_stable_block_diff} for block {block_no}")

OFFSET = 1

assert (
latest_stable_block_diff >= config.main_chain.security_param + config.main_chain.block_stability_margin
latest_stable_block_diff + OFFSET >= config.main_chain.security_param + config.main_chain.block_stability_margin
), f"Unexpected stable block number saved in header of block {block_no}"

if latest_stable_block_diff < config.main_chain.security_param + config.main_chain.block_stability_margin:
logger.warning(f"Unexpected (but within offset) stable block number saved in header of block {block_no}")
Loading