Skip to content

Commit

Permalink
Remove special forks annotations (#271)
Browse files Browse the repository at this point in the history
* Remove special forks annotations

* take addresses from envs

* Add env

* Variables in README

* Move to other section

* Holesky only
  • Loading branch information
hweawer authored Oct 22, 2024
1 parent a180c7e commit a4a7fa4
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 71 deletions.
28 changes: 5 additions & 23 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,16 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Integration tests with pytest, holesky fork
run: |
poetry run pytest tests -m integration_holesky
env:
WEB3_RPC_ENDPOINTS: ${{ secrets.HOLESKY_WEB3_RPC_ENDPOINT }}
DEPOSIT_CONTRACT: "0x4242424242424242424242424242424242424242"
LIDO_LOCATOR: "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8"
MELLOW_CONTRACT_ADDRESS: "0x182Cb3A76B0EFaCb25255F9594B5807460882fa4"
ANVIL_PATH: ""

- name: Integration tests with pytest, chiado testnet
run: |
poetry run pytest tests -m integration_chiado
env:
WEB3_RPC_ENDPOINTS: "https://gnosis-chiado-rpc.publicnode.com"
ONCHAIN_TRANSPORT_RPC_ENDPOINTS: "https://gnosis-chiado-rpc.publicnode.com"
ONCHAIN_TRANSPORT_ADDRESS: "0x42E1DEfC18388E3AA1fCADa851499A11405cf37f"
DEPOSIT_CONTRACT: "0x4242424242424242424242424242424242424242"
LIDO_LOCATOR: "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8"
MELLOW_CONTRACT_ADDRESS: "0x182Cb3A76B0EFaCb25255F9594B5807460882fa4"
ANVIL_PATH: ""

- name: Integration tests with pytest, mainnet fork
- name: Integration tests with pytest
if: success() || failure()
run: |
poetry run pytest tests -m integration
env:
WEB3_RPC_ENDPOINTS: ${{ secrets.WEB3_RPC_ENDPOINT }}
TESTNET_WEB3_RPC_ENDPOINTS: 'https://ethereum-holesky-rpc.publicnode.com'
DEPOSIT_CONTRACT: "0x00000000219ab540356cBB839Cbe05303d7705Fa"
LIDO_LOCATOR: "0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb"
ONCHAIN_TRANSPORT_RPC_ENDPOINTS: "https://gnosis-chiado-rpc.publicnode.com"
ONCHAIN_TRANSPORT_ADDRESS: "0x42E1DEfC18388E3AA1fCADa851499A11405cf37f"
MELLOW_CONTRACT_ADDRESS: "0x182Cb3A76B0EFaCb25255F9594B5807460882fa4"
ANVIL_PATH: ""
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ Unvetting is the proces of decreasing approved depositable signing keys.

## Running Daemon

1. Create `.env` file
1. Create `.env` file
2. Setup variables
- Set WEB3_RPC_ENDPOINTS
- Set WALLET_PRIVATE_KEY
- Set CREATE_TRANSACTIONS to true
- Set MESSAGE_TRANSPORTS to rabbit
- Set RABBIT_MQ_URL, RABBIT_MQ_USERNAME and RABBIT_MQ_PASSWORD
- Set WEB3_RPC_ENDPOINTS
- Set WALLET_PRIVATE_KEY
- Set CREATE_TRANSACTIONS to true
- Set MESSAGE_TRANSPORTS to rabbit
- Set RABBIT_MQ_URL, RABBIT_MQ_USERNAME and RABBIT_MQ_PASSWORD
3. ```docker-compose up```
4. Send metrics and logs to grafana
5. Setup alerts
Expand Down Expand Up @@ -83,6 +83,7 @@ Unvetting is the proces of decreasing approved depositable signing keys.
| MAX_CYCLE_LIFETIME_IN_SECONDS | 1200 | Max lifetime of usual cycle. If cycle will not end in this time, bot will crush |
| MELLOW_CONTRACT_ADDRESS | None | If variable is set then deposit can go to predifined module |
| VAULT_DIRECT_DEPOSIT_THRESHOLD | 1 ether | If mellow vault has VAULT_DIRECT_DEPOSIT_THRESHOLD ethers then direct deposit will be sent |
| ONCHAIN_TRANSPORT_RPC_ENDPOINTS | - | RPC endpoint for the databus RPC, Gnosis at the moment |

## Metrics and logs

Expand Down Expand Up @@ -119,6 +120,8 @@ poetry run pytest tests -m unit

#### Run integration tests.

TESTNET_WEB3_RPC_ENDPOINTS - set this variable for the Ethereum EL testnet RPC, Holesky only.

Install Anvil

```bash
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ pythonpath = [
markers = [
"unit", # offline
"integration", # hardhat fork
"integration_holesky", # holesky fork
"integration_chiado", # chiado(gnosis testnet) run only
]

[tool.ruff]
Expand Down
2 changes: 2 additions & 0 deletions src/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# EL node
WEB3_RPC_ENDPOINTS = os.getenv('WEB3_RPC_ENDPOINTS', '').split(',')

TESTNET_WEB3_RPC_ENDPOINTS = os.getenv('TESTNET_WEB3_RPC_ENDPOINTS', '').split(',')

# Account private key
WALLET_PRIVATE_KEY = os.getenv('WALLET_PRIVATE_KEY', None)

Expand Down
8 changes: 7 additions & 1 deletion tests/blockchain/contracts/test_erc20.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import pytest
import variables

from tests.utils.contract_utils import check_contract
from tests.utils.regrex import check_value_type


@pytest.mark.integration_holesky
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[{'endpoint': variables.TESTNET_WEB3_RPC_ENDPOINTS[0]}],
indirect=['web3_provider_integration'],
)
def test_erc20(weth, simple_dvt_staking_strategy, caplog):
check_contract(
weth,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import pytest
import variables

from tests.utils.contract_utils import check_contract
from tests.utils.regrex import ADDRESS_REGREX, check_value_re


@pytest.mark.integration_holesky
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[{'endpoint': variables.TESTNET_WEB3_RPC_ENDPOINTS[0]}],
indirect=['web3_provider_integration'],
)
def test_simple_dvt_staking_strategy_contract_call(simple_dvt_staking_strategy, caplog):
check_contract(
simple_dvt_staking_strategy,
Expand Down
8 changes: 7 additions & 1 deletion tests/blockchain/contracts/test_staking_module.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import pytest
import variables

from tests.utils.contract_utils import check_contract
from tests.utils.regrex import ADDRESS_REGREX, check_value_re, check_value_type


@pytest.mark.integration_holesky
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[{'endpoint': variables.TESTNET_WEB3_RPC_ENDPOINTS[0]}],
indirect=['web3_provider_integration'],
)
def test_staking_module_contract_call(staking_module, caplog):
check_contract(
staking_module,
Expand Down
2 changes: 1 addition & 1 deletion tests/bots/test_depositor.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_get_quorum(depositor_bot, setup_deposit_message):
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration,module_id',
[[19628126, 1], [19628126, 2]],
[[{'block': 19628126}, 1], [{'block': 19628126}, 2]],
indirect=['web3_provider_integration'],
)
def test_depositor_bot_non_mellow_deposits(
Expand Down
3 changes: 1 addition & 2 deletions tests/bots/test_mellow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ def setup_mellow_env():
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration,module_id',
[[20529904, 2], [20529995, 2]],
[[{'block': 20529904}, 2], [{'block': 20529995}, 2]],
indirect=['web3_provider_integration'],
)
def test_depositor_bot_mellow_deposits(
web3_provider_integration,
web3_lido_integration,
deposit_transaction_sender_integration,
mellow_deposit_strategy_integration,
Expand Down
2 changes: 1 addition & 1 deletion tests/bots/test_pauser.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_pause_message_filtered_by_module_id(pause_bot, block_data, pause_messag
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration,module_id',
[[19628126, 1], [19628126, 2]],
[[{'block': 19628126}, 1], [{'block': 19628126}, 2]],
indirect=['web3_provider_integration'],
)
def test_pauser_bot(web3_lido_integration, web3_provider_integration, add_account_to_guardian, module_id, caplog):
Expand Down
6 changes: 5 additions & 1 deletion tests/bots/test_unvetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def get_unvet_message(web3) -> UnvetMessage:
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[19628126],
[
{
'block': 19628126,
}
],
indirect=['web3_provider_integration'],
)
def test_unvetter(web3_provider_integration, web3_lido_integration, caplog):
Expand Down
24 changes: 11 additions & 13 deletions tests/fixtures/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,32 @@ def web3_lido_unit() -> Web3:
# -- Integration fixtures --
@pytest.fixture
def web3_provider_integration(request) -> Web3:
block_num = getattr(request, 'param', None)
params = getattr(request, 'param', {})
rpc_endpoint = params.get('endpoint', variables.WEB3_RPC_ENDPOINTS[0])
block_num = params.get('block', None)
anvil_path = os.getenv('ANVIL_PATH', '')

with anvil_fork(
os.getenv('ANVIL_PATH', ''),
variables.WEB3_RPC_ENDPOINTS[0],
block_num,
):
with anvil_fork(anvil_path, rpc_endpoint, block_num):
web3 = Web3(HTTPProvider('http://127.0.0.1:8545', request_kwargs={'timeout': 3600}))
assert web3.is_connected()
assert web3.is_connected(), 'Failed to connect to the Web3 provider.'
yield web3


@pytest.fixture
def web3_lido_integration(web3_provider_integration: Web3) -> Web3:
def web3_transaction_integration(web3_provider_integration: Web3) -> Web3:
web3_provider_integration.attach_modules(
{
'lido': LidoContracts,
'transaction': TransactionUtils,
}
)
yield web3_provider_integration


@pytest.fixture
def web3_transaction_integration(web3_provider_integration: Web3) -> Web3:
web3_provider_integration.attach_modules(
def web3_lido_integration(web3_transaction_integration: Web3) -> Web3:
web3_transaction_integration.attach_modules(
{
'transaction': TransactionUtils,
'lido': LidoContracts,
}
)
yield web3_provider_integration
yield web3_transaction_integration
15 changes: 0 additions & 15 deletions tests/transport/test_base_provider.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
from unittest.mock import Mock

import pytest
from prometheus_client import Gauge
from schema import Or, Schema
from transport.msg_providers.common import BaseMessageProvider
from transport.msg_types.deposit import DepositMessageSchema


class FakeMessageProvider(BaseMessageProvider):
@property
def fetched_messages_metric(self) -> Gauge:
return Mock()

@property
def processed_messages_metric(self) -> Gauge:
return Mock()

@property
def valid_messages_metric(self) -> Gauge:
return Mock()

MAX_MESSAGES_RECEIVE = 1

def _fetch_messages(self) -> list:
Expand Down
28 changes: 24 additions & 4 deletions tests/transport/test_data_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
# NODE_HOST: 'http://127.0.0.1:8888',
# DATA_BUS_ADDRESS: '0x5FbDB2315678afecb367f032d93F642f64180aa3'
# }
@pytest.mark.integration_chiado
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[{'endpoint': variables.ONCHAIN_TRANSPORT_RPC_ENDPOINTS[0]}],
indirect=['web3_provider_integration'],
)
def test_data_bus_provider(
web3_transaction_integration,
):
Expand Down Expand Up @@ -61,7 +66,12 @@ def test_data_bus_provider(
assert messages


@pytest.mark.integration_chiado
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[{'endpoint': variables.ONCHAIN_TRANSPORT_RPC_ENDPOINTS[0]}],
indirect=['web3_provider_integration'],
)
def test_data_bus_provider_unvet(
web3_transaction_integration,
):
Expand Down Expand Up @@ -111,7 +121,12 @@ def test_data_bus_provider_unvet(
assert len(messages) == 1


@pytest.mark.integration_chiado
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[{'endpoint': variables.ONCHAIN_TRANSPORT_RPC_ENDPOINTS[0]}],
indirect=['web3_provider_integration'],
)
def test_data_bus_provider_pause_v2(
web3_transaction_integration,
):
Expand Down Expand Up @@ -157,7 +172,12 @@ def test_data_bus_provider_pause_v2(
assert len(messages) == 1


@pytest.mark.integration_chiado
@pytest.mark.integration
@pytest.mark.parametrize(
'web3_provider_integration',
[{'endpoint': variables.ONCHAIN_TRANSPORT_RPC_ENDPOINTS[0]}],
indirect=['web3_provider_integration'],
)
def test_data_bus_provider_pause_v3(
web3_transaction_integration,
):
Expand Down

0 comments on commit a4a7fa4

Please # to comment.