Allow preset overrides - #4601
Conversation
|
|
| this.timeout(30_000); | ||
|
|
||
| it("Should correctly override preset", async () => { | ||
| await exec(`${tsNodeBinary} ${path.join(__dirname, scriptNames.ok)}`); |
Check warning
Code scanning / CodeQL
Shell command built from environment values
| }); | ||
|
|
||
| it("Should throw trying to override preset in the wrong order", async () => { | ||
| await expect(exec(`${tsNodeBinary} ${path.join(__dirname, scriptNames.error)}`)).to.be.rejectedWith( |
Check warning
Code scanning / CodeQL
Shell command built from environment values
There was a problem hiding this comment.
Can you change this test to instead be split into two different files that does the same thing (one pass, one fail)?
Wanting to prevent an exec here if possible.
There was a problem hiding this comment.
I've tried to do it, but params/src/index.ts gets imported during test setup and freezes preset, so if I call setCustomPreset from the same thread - it fails
| setCustomPreset(PresetName.minimal, {SLOTS_PER_EPOCH: 2}); | ||
|
|
||
| // 2. Import from any other @lodestar/params paths | ||
| import {expect} from "chai"; |
There was a problem hiding this comment.
Just use node:assert equals to keep the scripts simple https://nodejs.org/api/assert.html#assertequalactual-expected-message
| export function setCustomPreset(presetName: PresetName, overrides: Partial<BeaconPreset>): void { | ||
| setActivePreset(presetName); | ||
| userOverrides = overrides; | ||
| } |
There was a problem hiding this comment.
Why not extend setActivePreset() function above?
There was a problem hiding this comment.
good idea. and make overrides optional.
|
@daniildxb I pushed some updates here, hoping to get this merged asap |
wemeetagain
left a comment
There was a problem hiding this comment.
this LGTM
Can someone else also give sanity check @ChainSafe/lodestar
dapplion
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the contribution ❤️
Motivation
This PR allows users to override preset values (i.e. for use in ephemerals)
Description
Adds
setCustomPreset(presetName: PresetName, overrides: Partial<BeaconPreset>)method that allows users to pass preset base and override objectCloses #4598
Steps to test or reproduce
Added e2e test to params package to verify it works