Skip to content
Draft
Changes from all 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 packages/state-transition/test/unit/sanityCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const numValidators = 250000;
const targetStakeYWei = 7;
const targetStake = BigInt(targetStakeYWei) * BigInt(1) ** BigInt(15);
const targetStake = BigInt(targetStakeYWei) * BigInt(10) ** BigInt(15);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and use modern BigInt syntax, you can use n literals for BigInt values. This avoids multiple BigInt() constructor calls and makes the intent of calculating 10^15 clearer.

Suggested change
const targetStake = BigInt(targetStakeYWei) * BigInt(10) ** BigInt(15);
const targetStake = BigInt(targetStakeYWei) * (10n ** 15n);


beforeAll(() => {
expect(perfStateId).toEqualWithMessage(`${numValidators} vs - ${targetStakeYWei}PWei`, "perfStateId has changed");
Expand All @@ -33,7 +33,7 @@
const cache = beforeProcessEpoch(phase0State);
expect(
BigInt(cache.prevEpochUnslashedStake.targetStakeByIncrement) * BigInt(EFFECTIVE_BALANCE_INCREMENT) > targetStake
).toEqualWithMessage(

Check failure on line 36 in packages/state-transition/test/unit/sanityCheck.test.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (22)

packages/state-transition/test/unit/sanityCheck.test.ts > Perf test sanity check > targetStake is in the same range

Error: targetStake too low: 1000000000 > 7000000000000000 - Expected + Received - true + false ❯ packages/state-transition/test/unit/sanityCheck.test.ts:36:7
true,
`targetStake too low: ${
BigInt(cache.prevEpochUnslashedStake.targetStakeByIncrement) * BigInt(EFFECTIVE_BALANCE_INCREMENT)
Expand Down
Loading