Skip to content

Commit

Permalink
feat: support missing electra spec test (#6765)
Browse files Browse the repository at this point in the history
Add spec test
  • Loading branch information
ensi321 authored and g11tech committed Aug 9, 2024
1 parent 359ba9c commit 8de6fb4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const epochTransitionFns: Record<string, EpochTransitionFn> = {
slashings_reset: epochFns.processSlashingsReset,
sync_committee_updates: epochFns.processSyncCommitteeUpdates as EpochTransitionFn,
historical_summaries_update: epochFns.processHistoricalSummariesUpdate as EpochTransitionFn,
pending_balance_deposits: epochFns.processPendingBalanceDeposits as EpochTransitionFn,
pending_consolidations: epochFns.processPendingConsolidations as EpochTransitionFn,
};

/**
Expand Down
17 changes: 17 additions & 0 deletions packages/beacon-node/test/spec/presets/operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ const operationFns: Record<string, BlockProcessFn<CachedBeaconStateAllForks>> =
withdrawals: (state, testCase: {execution_payload: capella.ExecutionPayload}) => {
blockFns.processWithdrawals(ForkSeq.capella, state as CachedBeaconStateCapella, testCase.execution_payload);
},

consolidation: (state, testCase: {consolidation: electra.SignedConsolidation}) => {
blockFns.processConsolidation(state as CachedBeaconStateElectra, testCase.consolidation);
},

execution_layer_withdrawal_request: (
state,
testCase: {execution_layer_withdrawal_request: electra.ExecutionLayerWithdrawalRequest}
) => {
blockFns.processExecutionLayerWithdrawalRequest(
ForkSeq.electra,
state as CachedBeaconStateElectra,
testCase.execution_layer_withdrawal_request
);
},
};

export type BlockProcessFn<T extends CachedBeaconStateAllForks> = (state: T, testCase: any) => void;
Expand Down Expand Up @@ -140,6 +155,8 @@ const operations: TestRunnerFn<OperationsTestCase, BeaconStateAllForks> = (fork,
: ssz.bellatrix.ExecutionPayload,
// Capella
address_change: ssz.capella.SignedBLSToExecutionChange,
consolidation: ssz.electra.SignedConsolidation,
execution_layer_withdrawal_request: ssz.electra.ExecutionLayerWithdrawalRequest,
},
shouldError: (testCase) => testCase.post === undefined,
getExpected: (testCase) => testCase.post,
Expand Down
1 change: 1 addition & 0 deletions packages/state-transition/src/block/processOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
processExecutionLayerWithdrawalRequest,
processBlsToExecutionChange,
processDepositRequest,
processConsolidation,
};

export function processOperations(
Expand Down

0 comments on commit 8de6fb4

Please sign in to comment.