-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
test: move withdrawal tests to sim tests #6507
Conversation
if (!payloadId) throw Error("InvalidPayloadId"); | ||
|
||
// 2. Get the payload | ||
const payloadWithValue = await executionEngine.getPayload(ForkName.capella, payloadId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's testing the engine API from the execution engine. Which should not be in our test suite.
The behavior passively is tested in sim tests anyway.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6507 +/- ##
============================================
- Coverage 61.72% 61.46% -0.27%
============================================
Files 555 556 +1
Lines 58204 58850 +646
Branches 1844 1850 +6
============================================
+ Hits 35927 36171 +244
- Misses 22238 22638 +400
- Partials 39 41 +2 |
Performance Report✔️ no performance regression detected 🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an expert in sim tests, but overall the approach sounds sensible to me. And always 👍 removing complexity :)
*/ | ||
const result = [`Slot,${nodes.map((n) => n.beacon.id).join(", ,")}`]; | ||
result.push(`,${nodes.map((_) => "Withdrawal Amount,Withdrawal Count").join(",")}`); | ||
for (let s = 1; s <= slot; s++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use const, not let?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then TS would not allow to use s++
, you can't mutate a const declared primitive.
let row = `${s}`; | ||
for (const node of nodes) { | ||
const {withdrawalAmount, withdrawalCount} = store[node.beacon.id][s] ?? {}; | ||
row += `,${withdrawalAmount ?? "-"},${withdrawalCount ?? "-"}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some combination of Array#join
and Array#map
could be used here. Just for reference, for this PR looks ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This iteration approach looks more readable.
const validators: WithdrawalsData["validators"] = {}; | ||
|
||
for (const withdrawal of withdrawals) { | ||
withdrawalCount++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it can only ever end up being withdrawals.length
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. was using different approach earlier so this variable left as counter.
return { | ||
id: `withdrawals_${nodeId}`, | ||
match({forkConfig, epoch, node}) { | ||
if (nodeId === node.id && epoch === forkConfig.CAPELLA_FORK_EPOCH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this line pass lints (no curly brasses).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was actually written as single line, but prettier changed it to this format. And our ESlint don't complaint on Prettier formatting.
@@ -0,0 +1,98 @@ | |||
/* eslint-disable @typescript-eslint/naming-convention */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to lints, this directive is useless.
@@ -71,39 +71,6 @@ jobs: | |||
ENGINE_PORT: 8551 | |||
ETH_PORT: 8661 | |||
|
|||
- name: Pull geth withdrawals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we need to remove the whole file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet, one other PR in progress then we can remove this file and a lot of utility code along it.
let withdrawalAmount = BigInt(0); | ||
const validators: WithdrawalsData["validators"] = {}; | ||
|
||
for (const withdrawal of withdrawals) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if it's empty withdrawals
? is it scanned through assert()
function below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the assertion works on this logic.
if (nodeId === node.id && epoch === forkConfig.CAPELLA_FORK_EPOCH)
return AssertionMatch.Capture | AssertionMatch.Assert;
So even if the above line withdrawals are empty, the assertion will still trigger and results in empty errors array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, spent some time to see how capture()
and assert()
works. Nice work in SimulationTracker @nazarhussain . It's difficult for me to debug it through.
Both works based on the |
🎉 This PR is included in v1.18.0 🎉 |
Motivation
Remove redundant tests
Description
Steps to test or reproduce