Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 committed Nov 19, 2024
1 parent 72bcc4f commit 090417f
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions packages/state-transition/test/unit/cachedBeaconState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("CachedBeaconState", () => {
expect(state2.epochCtx.epoch).toBe(0);
});

it("Clone and mutate cache pre-Electra", () => {
it("Clone and mutate cache", () => {
const stateView = ssz.altair.BeaconState.defaultViewDU();
const state1 = createCachedBeaconStateTest(stateView);

Expand All @@ -52,40 +52,6 @@ describe("CachedBeaconState", () => {
expect(state2.epochCtx.getValidatorIndex(pubkey2)).toBe(index2);
});

it("Clone and mutate cache post-Electra", () => {
const stateView = ssz.electra.BeaconState.defaultViewDU();
const state1 = createCachedBeaconStateTest(
stateView,
createChainForkConfig({
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: 0,
}),
{skipSyncCommitteeCache: true, skipSyncPubkeys: true}
);

const pubkey1 = fromHexString(
"0x84105a985058fc8740a48bf1ede9d223ef09e8c6b1735ba0a55cf4a9ff2ff92376b778798365e488dab07a652eb04576"
);
const index1 = 123;
const pubkey2 = fromHexString(
"0xa41726266b1d83ef609d759ba7796d54cfe549154e01e4730a3378309bc81a7638140d7e184b33593c072595f23f032d"
);
const index2 = 456;

state1.epochCtx.addPubkey(index1, pubkey1);

const state2 = state1.clone();
state2.epochCtx.addPubkey(index2, pubkey2);

expect(state1.epochCtx.getValidatorIndex(pubkey1)).toBe(index1);
expect(state2.epochCtx.getValidatorIndex(pubkey1)).toBe(index1);
expect(state1.epochCtx.getValidatorIndex(pubkey2)).toBe(null);
expect(state2.epochCtx.getValidatorIndex(pubkey2)).toBe(index2);
});

it("Auto-commit on hashTreeRoot", () => {
// Use Checkpoint instead of BeaconState to speed up the test
const cp1 = ssz.phase0.Checkpoint.defaultViewDU();
Expand Down

0 comments on commit 090417f

Please sign in to comment.