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

feat: add test for modules on network fork #561

Open
wants to merge 15 commits into
base: feat/oracle-v5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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
56 changes: 56 additions & 0 deletions .github/workflows/fork_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Fork Tests

on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this

- closed
branches:
- main
- develop
paths:
- "src/**"

permissions:
contents: read
security-events: write

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Setup poetry
run: >
curl -sSL https://install.python-poetry.org | python - &&
echo "$POETRY_HOME/bin" >> "$GITHUB_PATH"
env:
POETRY_HOME: "/opt/poetry"
POETRY_VERSION: 1.3.2

- name: Install Python dependencies
run: |
poetry install --no-interaction --with=dev

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Fork tests
run: poetry run pytest -m 'fork' tests
env:
EXECUTION_CLIENT_URI: ${{ secrets.EXECUTION_CLIENT_URI }}
CONSENSUS_CLIENT_URI: ${{ secrets.CONSENSUS_CLIENT_URI }}
KEYS_API_URI: ${{ secrets.KEYS_API_URI }}
LIDO_LOCATOR_ADDRESS: "0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb"
CSM_MODULE_ADDRESS: "0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F"

2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
poetry install --no-interaction --with=dev

- name: Test with pytest
run: poetry run pytest --cov=src tests
run: poetry run pytest -m 'not fork' --cov=src tests
env:
EXECUTION_CLIENT_URI: ${{ secrets.EXECUTION_CLIENT_URI }}
CONSENSUS_CLIENT_URI: ${{ secrets.CONSENSUS_CLIENT_URI }}
Expand Down
2 changes: 1 addition & 1 deletion assets/HashConsensus.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/modules/accounting/accounting.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _get_slots_elapsed_from_last_report(self, blockstamp: ReferenceBlockStamp):
if last_ref_slot:
slots_elapsed = blockstamp.ref_slot - last_ref_slot
else:
slots_elapsed = blockstamp.ref_slot - frame_config.initial_epoch * chain_conf.slots_per_epoch
slots_elapsed = max(blockstamp.ref_slot - frame_config.initial_epoch * chain_conf.slots_per_epoch, 0)

return slots_elapsed

Expand Down
4 changes: 1 addition & 3 deletions src/modules/csm/csm.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,7 @@ def converter(self, blockstamp: BlockStamp) -> Web3Converter:
return Web3Converter(self.get_chain_config(blockstamp), self.get_frame_config(blockstamp))

def _get_module_id(self) -> StakingModuleId:
modules: list[StakingModule] = self.w3.lido_contracts.staking_router.get_staking_modules(
self._receive_last_finalized_slot().block_hash
)
modules: list[StakingModule] = self.w3.lido_contracts.staking_router.get_staking_modules()

for mod in modules:
if mod.staking_module_address == self.w3.csm.module.address:
Expand Down
Empty file added tests/fork/__init__.py
Empty file.
Loading
Loading