Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '22'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/tests_and_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,30 @@ jobs:
- name: Set up node
uses: actions/setup-node@v3.5.0
with:
node-version: '16'
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Run lint
run: yarn lint
- name: Run tests
run: yarn test
e2e:
name: E2e tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2.4.0
- name: Set up node
uses: actions/setup-node@v3.5.0
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Run e2e tests
run: yarn test:e2e
env:
# Optional repo secret with an archive-capable mainnet RPC; when
# absent the configs fall back to a public node
EXECUTION_NODE: ${{ secrets.EDF_E2E_EXECUTION_NODE }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ dist
.jest
jwt.hex
/.idea
artifacts
artifacts
# hardhat fork node cache (e2e)
cache
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine as building
FROM node:22-alpine as building

WORKDIR /app

Expand All @@ -11,7 +11,7 @@ COPY ./src ./src
COPY ./encryptor ./encryptor
RUN yarn build

FROM node:16-alpine
FROM node:22-alpine

WORKDIR /app

Expand Down
21 changes: 21 additions & 0 deletions hardhat.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Minimal config for the e2e mainnet fork node, spawned by
// src/test/hardhat-server.ts. EXECUTION_NODE mirrors the default RPC of the
// existing e2e suite.
require('dotenv').config()

module.exports = {
// Test doubles for the e2e suite; `hardhat node` compiles them on start
solidity: '0.8.24',
paths: {
sources: './src/test/contracts',
},
networks: {
hardhat: {
forking: {
// An unset CI secret arrives as an empty string, which must also
// fall back to the public node
url: process.env.EXECUTION_NODE || 'https://ethereum-rpc.publicnode.com',
},
},
},
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"eslint": "8.29.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"hardhat": "2.26.3",
"nock": "13.3.1",
"prettier": "2.8.0",
"ts-node": "10.9.1",
Expand Down
25 changes: 17 additions & 8 deletions src/services/consensus-api/cl.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ describe('makeConsensusApi e2e', () => {

it('should handle batch size correctly with large index array e2e', async () => {
const indices = Array.from({ length: 3000 }, (_, i) => (i + 1).toString())
const count = await api.getExitingValidatorsCount(indices, 1000, 11724253)
expect(count).toStrictEqual(1226)
// An exit epoch never unsets, so this count only grows over time;
// it was 1226 at slot 11724253
const count = await api.getExitingValidatorsCount(
indices,
1000,
'finalized'
)
expect(count).toBeGreaterThanOrEqual(1226)
expect(count).toBeLessThanOrEqual(3000)
})

it('should validate public keys e2e', async () => {
Expand All @@ -61,29 +68,31 @@ describe('makeConsensusApi e2e', () => {
const validIndices = await api.validatePublicKeys(
validatorData,
1000,
11724253
'finalized'
)
expect(validIndices.size).toEqual(2)
})

it('should fetch validators batch e2e', async () => {
const indices = ['1', '2']
const validators = await api.fetchValidatorsBatch(indices, 1000, 11724253)
const validators = await api.fetchValidatorsBatch(
indices,
1000,
'finalized'
)

expect(validators).toHaveLength(2)

expect(validators[0].index).toBe('1')
expect(validators[0].status).toBe('active_ongoing')
expect(validators[0].status).toBeTruthy()
expect(validators[0].validator.pubkey).toBe(
'0xa1d1ad0714035353258038e964ae9675dc0252ee22cea896825c01458e1807bfad2f9969338798548d9858a571f7425c'
)
expect(validators[0].validator.exit_epoch).toBe('18446744073709551615')

expect(validators[1].index).toBe('2')
expect(validators[1].status).toBe('active_ongoing')
expect(validators[1].status).toBeTruthy()
expect(validators[1].validator.pubkey).toBe(
'0xb2ff4716ed345b05dd1dfc6a5a9fa70856d8c75dcc9e881dd2f766d5f891326f0d10e96f3a444ce6c912b69c22c6754d'
)
expect(validators[1].validator.exit_epoch).toBe('18446744073709551615')
})
})
1 change: 1 addition & 0 deletions src/services/exit-logs/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const txDTO = (json: unknown) =>
(json) => ({
result: obj(json.result, (result) => ({
from: str(result.from),
blockNumber: optional(() => str(result.blockNumber)),
gas: str(result.gas),
Comment on lines 34 to 36
gasPrice: optional(() => str(result.gasPrice)),
maxFeePerGas: optional(() => str(result.maxFeePerGas)),
Expand Down
9 changes: 6 additions & 3 deletions src/services/exit-logs/exit-logs.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ describe('exitLogs e2e', () => {

beforeEach(async () => {
const nodes = {
EXECUTION_NODE: process.env.EXECUTION_NODE ?? 'https://eth.drpc.org',
EXECUTION_NODE: process.env.EXECUTION_NODE || 'https://eth.drpc.org',
CONSENSUS_NODE:
process.env.CONSENSUS_NODE ??
process.env.CONSENSUS_NODE ||
'https://ethereum-beacon-api.publicnode.com',
}

Expand Down Expand Up @@ -139,6 +139,7 @@ describe('exitLogs e2e', () => {

const frame1 = await api.getLogs(frame1Block)

// 40 mainnet exit requests for operators 0-2 in blocks 22024255..22044254
expect(frame1.length).toBe(40)

config.EJECTOR_SCOPE = [{ stakingModuleId: '1', operatorIds: [0, 1] }]
Expand All @@ -149,6 +150,8 @@ describe('exitLogs e2e', () => {

const frame2 = await api.getLogs(frame2Block)

expect(frame2.length).toBe(62)
// 22 mainnet exit requests for operators 0-1 in blocks 22044255..22064254.
// loadServices() rebuilt the cache, so frame1 events are not included
expect(frame2.length).toBe(22)
})
})
Loading
Loading