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

test: pytest log verbosity #298

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions .github/actions/tests/local-environment-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ runs:
keyword: "test_get_status or test_get_params"
blockchain: substrate
local-environment: "true"
log_level: debug
- name: Wait for epoch 2
uses: ./.github/actions/tests/wait-for-epoch
with:
Expand All @@ -133,6 +134,7 @@ runs:
blockchain: substrate
markers: "not active_flow and not passive_flow and not probability and not rpc"
local-environment: "true"
log_level: debug
- name: Wait for epoch 3
if: ${{ inputs.tests == 'postmerge' }}
uses: ./.github/actions/tests/wait-for-epoch
Expand All @@ -149,6 +151,7 @@ runs:
init_timestamp: ${{ env.INIT_TIMESTAMP }}
blockchain: substrate
local-environment: "true"
log_level: debug
- name: Wait for epoch 4
if: ${{ inputs.tests == 'postmerge' }}
uses: ./.github/actions/tests/wait-for-epoch
Expand All @@ -166,6 +169,7 @@ runs:
init_timestamp: ${{ env.INIT_TIMESTAMP }}
blockchain: substrate
local-environment: "true"
log_level: debug
- name: Check if no skipped tests
if: ${{ inputs.tests == 'postmerge' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/actions/tests/run-e2e-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ runs:
${decrypt_switch} \
--json-report \
--json-report-summary \
--tb=short \
--junitxml=junit_report.xml"

if [[ "${{ inputs.local-environment }}" == "true" ]]; then
Expand Down
97 changes: 63 additions & 34 deletions E2E-tests/tests/committee/test_registrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,70 @@ def test_register_candidate(candidate: Candidates, api: BlockchainApi, db: Sessi
* wait for next partner chain block
* check that registered candidate appeared in the partner_chain_getAriadneParameters() response
"""
logging.info(f"Registering {candidate}")
result, next_status_epoch = api.register_candidate(candidate.name)
assert result, f"Registration of candidate {candidate.name} failed."

registered_candidate = Candidates()
registered_candidate.name = candidate.name
registered_candidate.next_status = "active"
registered_candidate.next_status_epoch = next_status_epoch
db.add(registered_candidate)
db.commit()
logging.info("Starting test: test_register_candidate")
logging.info(f"Candidate: {candidate}, API: {api}, DB: {db}, Config: {config}")

# TODO: split into separate test
# Get registration status from RPC
api.wait_for_next_pc_block()
candidate_registrations = api.get_trustless_candidates(next_status_epoch, valid_only=False)
spo_public_key = config.nodes_config.nodes[candidate.name].keys_files.spo_public_key
registered_mc_pub_key = f"0x{api._read_cardano_key_file(spo_public_key)}"
# FIXME: ETCM-7370 handle multiple registrations for a single spo
registration = candidate_registrations[registered_mc_pub_key][0]
registered_pc_pub_key = config.nodes_config.nodes[candidate.name].public_key
registered_aura_pub_key = config.nodes_config.nodes[candidate.name].aura_public_key
registered_grandpa_pub_key = config.nodes_config.nodes[candidate.name].grandpa_public_key
assert (
registered_pc_pub_key == registration["sidechainPubKey"]
), f"Could not find SC public key {registered_pc_pub_key} registered for MC epoch {next_status_epoch}"
assert (
registered_mc_pub_key == registration["mainchainPubKey"]
), f"Could not find MC public key {registered_mc_pub_key} registered for MC epoch {next_status_epoch}"
assert (
registered_aura_pub_key == registration["auraPubKey"]
), f"Could not find Aura public key {registered_aura_pub_key} registered for MC epoch {next_status_epoch}"
assert (
registered_grandpa_pub_key == registration["grandpaPubKey"]
), f"Could not find Grandpa public key {registered_grandpa_pub_key} registered for MC epoch {next_status_epoch}"
assert registration["isValid"], f"Registered candidate {candidate.name} is not valid"
try:
# Step 1: Register the candidate
logging.info(f"Registering candidate {candidate.name}")
result, next_status_epoch = api.register_candidate(candidate.name)
logging.info(f"Registration result: {result}, next status epoch: {next_status_epoch}")
assert result, f"Registration of candidate {candidate.name} failed."

# Step 2: Commit the registration to the database
logging.info("Committing candidate registration to the database.")
registered_candidate = Candidates()
registered_candidate.name = candidate.name
registered_candidate.next_status = "active"
registered_candidate.next_status_epoch = next_status_epoch
db.add(registered_candidate)
db.commit()
logging.info("Candidate successfully committed to the database.")

# Step 3: Wait for the next partner chain block
logging.info("Waiting for the next partner chain block.")
api.wait_for_next_pc_block()

# Step 4: Get registration status from RPC
logging.info(f"Fetching trustless candidates for epoch {next_status_epoch}")
candidate_registrations = api.get_trustless_candidates(next_status_epoch, valid_only=False)
spo_public_key = config.nodes_config.nodes[candidate.name].keys_files.spo_public_key
registered_mc_pub_key = f"0x{api._read_cardano_key_file(spo_public_key)}"
logging.info(f"MC public key: {registered_mc_pub_key}")

# FIXME: ETCM-7370 handle multiple registrations for a single SPO
registration = candidate_registrations[registered_mc_pub_key][0]
logging.info(f"Fetched registration: {registration}")

registered_pc_pub_key = config.nodes_config.nodes[candidate.name].public_key
registered_aura_pub_key = config.nodes_config.nodes[candidate.name].aura_public_key
registered_grandpa_pub_key = config.nodes_config.nodes[candidate.name].grandpa_public_key

# Step 5: Validate keys and status
logging.info("Validating registration keys and status.")
assert (
registered_pc_pub_key == registration["sidechainPubKey"]
), f"Could not find SC public key {registered_pc_pub_key} registered for MC epoch {next_status_epoch}"
assert (
registered_mc_pub_key == registration["mainchainPubKey"]
), f"Could not find MC public key {registered_mc_pub_key} registered for MC epoch {next_status_epoch}"
assert (
registered_aura_pub_key == registration["auraPubKey"]
), f"Could not find Aura public key {registered_aura_pub_key} registered for MC epoch {next_status_epoch}"
assert (
registered_grandpa_pub_key == registration["grandpaPubKey"]
), f"Could not find Grandpa public key {registered_grandpa_pub_key} registered for MC epoch {next_status_epoch}"
assert registration["isValid"], f"Registered candidate {candidate.name} is not valid"

logging.info("Test completed successfully: test_register_candidate")
except AssertionError as e:
logging.error(f"Test failed: {e}")
raise
except Exception as e:
logging.error(f"Unexpected error during test: {e}")
raise
finally:
logging.info("Test execution finished: test_register_candidate")


@mark.skip_blockchain("pc_evm", reason="not implemented yet")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading