Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/val-1556-move…
Browse files Browse the repository at this point in the history
…-vebo-legacy-tests
  • Loading branch information
Amuhar committed Jan 15, 2025
2 parents 8fa4443 + 2d11786 commit 3ac9843
Show file tree
Hide file tree
Showing 12 changed files with 347 additions and 251 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MAINNET_RPC_URL=http://localhost:8545

# RPC URL for Hardhat Network forking, required for running tests on mainnet fork with tracing (Infura, Alchemy, etc.)
# https://hardhat.org/hardhat-network/docs/guides/forking-other-networks#forking-other-networks
HARDHAT_FORKING_URL=
HARDHAT_FORKING_URL=https://eth.drpc.org

# https://docs.lido.fi/deployed-contracts
MAINNET_LOCATOR_ADDRESS=0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-integration-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

services:
hardhat-node:
image: ghcr.io/lidofinance/hardhat-node:2.22.12
image: ghcr.io/lidofinance/hardhat-node:2.22.17
ports:
- 8545:8545
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-integration-scratch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

services:
hardhat-node:
image: ghcr.io/lidofinance/hardhat-node:2.22.12-scratch
image: ghcr.io/lidofinance/hardhat-node:2.22.17-scratch
ports:
- 8555:8545

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ mainnet environment, allowing you to run integration tests with trace logging.
> [!NOTE]
> Ensure that `HARDHAT_FORKING_URL` is set to Ethereum Mainnet RPC and `MAINNET_*` environment variables are set in the
> `.env` file (refer to `.env.example` for guidance).
> `.env` file (refer to `.env.example` for guidance). Otherwise, the tests will run against the Scratch deployment.
```bash
# Run all integration tests
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is the core repository of the Lido on Ethereum protocol. The entire codebas
---

<div>
<img alt="Lido" src="https://img.shields.io/badge/v2-version?label=lido&labelColor=rgb(91%2C%20162%2C%20252)&color=white"/>
<img alt="Lido" src="https://img.shields.io/badge/v2.1-version?label=lido&labelColor=rgb(91%2C%20162%2C%20252)&color=white"/>
<img alt="GitHub license" src="https://img.shields.io/github/license/lidofinance/lido-dao?labelColor=orange&color=white"/>
<img alt="Solidity" src="https://img.shields.io/badge/multiver-s?style=flat&label=solidity&labelColor=rgb(86%2C%2085%2C%20212)&color=white"/>
<img alt="Aragon OS" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Flidofinance%2Fcore%2Fmaster%2Fpackage.json&query=%24.dependencies%5B'%40aragon%2Fos'%5D&style=flat&label=aragon%2Fos&labelColor=rgb(70%2C%20100%2C%20246)&color=white"/>
Expand All @@ -14,7 +14,9 @@ This is the core repository of the Lido on Ethereum protocol. The entire codebas
<img alt="Hardhat" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Flidofinance%2Fcore%2Fmaster%2Fpackage.json&query=%24.devDependencies.hardhat&style=flat&label=hardhat&labelColor=rgb(251%2C%20240%2C%2056)&color=white" />
<img alt="Ethers" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Flidofinance%2Fcore%2Fmaster%2Fpackage.json&query=%24.devDependencies.ethers&style=flat&label=ethers&labelColor=rgb(51%2C%2077%2C%20121)&color=white" />
<br/>
<img alt="GitHub tests" src="https://img.shields.io/github/actions/workflow/status/lidofinance/core/tests.yml?label=tests">
<img alt="GitHub unit tests" src="https://img.shields.io/github/actions/workflow/status/lidofinance/core/tests-unit.yml?label=tests:unit">
<img alt="GitHub integration tests (scratch)" src="https://img.shields.io/github/actions/workflow/status/lidofinance/core/tests-integration-scratch.yml?label=tests:integration:scratch">
<img alt="GitHub integration tests (mainnet-fork)" src="https://img.shields.io/github/actions/workflow/status/lidofinance/core/tests-integration-mainnet.yml?label=tests:integration:mainnet-fork">
<img alt="GitHub linters" src="https://img.shields.io/github/actions/workflow/status/lidofinance/core/linters.yml?label=linters">
<img alt="GitHub code analysis" src="https://img.shields.io/github/actions/workflow/status/lidofinance/core/analyse.yml?label=code analysis">
</div>
Expand Down
47 changes: 4 additions & 43 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { existsSync, readFileSync } from "node:fs";
import path from "node:path";
import * as process from "node:process";

import "@nomicfoundation/hardhat-chai-matchers";
import "@nomicfoundation/hardhat-toolbox";
Expand All @@ -12,41 +11,15 @@ import "hardhat-tracer";
import "hardhat-watcher";
import "hardhat-ignore-warnings";
import "hardhat-contract-sizer";
import { globSync } from "glob";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
import { HardhatUserConfig, subtask } from "hardhat/config";
import { HardhatUserConfig } from "hardhat/config";

import { mochaRootHooks } from "test/hooks";

import "./tasks";

const RPC_URL: string = process.env.RPC_URL || "";
const ACCOUNTS_PATH = "./accounts.json";

const HARDHAT_FORKING_URL = process.env.HARDHAT_FORKING_URL || "";

const INTEGRATION_WITH_SCRATCH_DEPLOY = process.env.INTEGRATION_WITH_SCRATCH_DEPLOY || "off";

/* Determines the forking configuration for Hardhat */
function getHardhatForkingConfig() {
if (INTEGRATION_WITH_SCRATCH_DEPLOY === "on" || !HARDHAT_FORKING_URL) {
return undefined;
}
return { url: HARDHAT_FORKING_URL };
}
import { getHardhatForkingConfig, loadAccounts } from "./hardhat.helpers";

function loadAccounts(networkName: string) {
// TODO: this plaintext accounts.json private keys management is a subject
// of rework to a solution with the keys stored encrypted
if (!existsSync(ACCOUNTS_PATH)) {
return [];
}
const content = JSON.parse(readFileSync(ACCOUNTS_PATH, "utf-8"));
if (!content.eth) {
return [];
}
return content.eth[networkName] || [];
}
const RPC_URL: string = process.env.RPC_URL || "";

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
Expand Down Expand Up @@ -185,16 +158,4 @@ const config: HardhatUserConfig = {
},
};

// a workaround for having an additional source directory for compilation
// see, https://github.com/NomicFoundation/hardhat/issues/776#issuecomment-1713584386
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, hre, runSuper) => {
const paths = await runSuper();

const otherDirectoryGlob = path.join(hre.config.paths.root, "test", "**", "*.sol");
// Don't need to compile test, helper and script files that are not part of the contracts for Hardhat.
const otherPaths = globSync(otherDirectoryGlob).filter((x) => !/\.([ths]\.sol)$/.test(x));

return [...paths, ...otherPaths];
});

export default config;
32 changes: 32 additions & 0 deletions hardhat.helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { existsSync, readFileSync } from "node:fs";

/* Determines the forking configuration for Hardhat */
export function getHardhatForkingConfig() {
const forkingUrl = process.env.HARDHAT_FORKING_URL || "";

if (!forkingUrl) {
// Scratch deploy, need to disable CSM
process.env.INTEGRATION_ON_SCRATCH = "on";
process.env.INTEGRATION_WITH_CSM = "off";
return undefined;
}

return { url: forkingUrl };
}

// TODO: this plaintext accounts.json private keys management is a subject
// of rework to a solution with the keys stored encrypted
export function loadAccounts(networkName: string) {
const accountsPath = "./accounts.json";

if (!existsSync(accountsPath)) {
return [];
}

const content = JSON.parse(readFileSync(accountsPath, "utf-8"));
if (!content.eth) {
return [];
}

return content.eth[networkName] || [];
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"ethers": "^6.13.4",
"glob": "^11.0.0",
"globals": "^15.9.0",
"hardhat": "^2.22.16",
"hardhat": "^2.22.17",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-gas-reporter": "^1.0.10",
"hardhat-ignore-warnings": "^0.2.12",
Expand Down
Loading

0 comments on commit 3ac9843

Please sign in to comment.